Spring Integration

org.springframework.integration.store
Class SimpleMessageGroup

java.lang.Object
  extended by org.springframework.integration.store.SimpleMessageGroup
All Implemented Interfaces:
MessageGroup

public class SimpleMessageGroup
extends java.lang.Object
implements MessageGroup

Represents a mutable group of correlated messages that is bound to a certain MessageStore and group id. The group will grow during its lifetime, when messages are added to it. This MessageGroup is thread safe.

Since:
2.0
Author:
Iwein Fuld, Oleg Zhurakousky, Dave Syer

Field Summary
 java.util.concurrent.BlockingQueue<Message<?>> messages
           
 
Constructor Summary
SimpleMessageGroup(java.util.Collection<? extends Message<?>> messages, java.lang.Object groupId)
           
SimpleMessageGroup(java.util.Collection<? extends Message<?>> messages, java.lang.Object groupId, long timestamp, boolean complete)
           
SimpleMessageGroup(MessageGroup messageGroup)
           
SimpleMessageGroup(java.lang.Object groupId)
           
 
Method Summary
 void add(Message<?> message)
           
 boolean canAdd(Message<?> message)
          Query if the message can be added.
 void clear()
           
 void complete()
           
 java.lang.Object getGroupId()
           
 long getLastModified()
           
 int getLastReleasedMessageSequenceNumber()
          Returns the sequenceNumber of the last released message.
 java.util.Collection<Message<?>> getMessages()
          Returns all available Messages from the group at the time of invocation
 Message<?> getOne()
           
 int getSequenceSize()
           
 long getTimestamp()
           
 boolean isComplete()
           
 void remove(Message<?> message)
           
 void setLastModified(long lastModified)
           
 void setLastReleasedMessageSequenceNumber(int sequenceNumber)
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messages

public final java.util.concurrent.BlockingQueue<Message<?>> messages
Constructor Detail

SimpleMessageGroup

public SimpleMessageGroup(java.lang.Object groupId)

SimpleMessageGroup

public SimpleMessageGroup(java.util.Collection<? extends Message<?>> messages,
                          java.lang.Object groupId)

SimpleMessageGroup

public SimpleMessageGroup(java.util.Collection<? extends Message<?>> messages,
                          java.lang.Object groupId,
                          long timestamp,
                          boolean complete)

SimpleMessageGroup

public SimpleMessageGroup(MessageGroup messageGroup)
Method Detail

getTimestamp

public long getTimestamp()
Specified by:
getTimestamp in interface MessageGroup
Returns:
the timestamp (milliseconds since epoch) associated with the creation of this group

setLastModified

public void setLastModified(long lastModified)

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface MessageGroup
Returns:
the timestamp (milliseconds since epoch) associated with the time this group was last updated

canAdd

public boolean canAdd(Message<?> message)
Description copied from interface: MessageGroup
Query if the message can be added.

Specified by:
canAdd in interface MessageGroup

add

public void add(Message<?> message)

remove

public void remove(Message<?> message)

getLastReleasedMessageSequenceNumber

public int getLastReleasedMessageSequenceNumber()
Description copied from interface: MessageGroup
Returns the sequenceNumber of the last released message. Used in Resequencer use cases only

Specified by:
getLastReleasedMessageSequenceNumber in interface MessageGroup

getMessages

public java.util.Collection<Message<?>> getMessages()
Description copied from interface: MessageGroup
Returns all available Messages from the group at the time of invocation

Specified by:
getMessages in interface MessageGroup

setLastReleasedMessageSequenceNumber

public void setLastReleasedMessageSequenceNumber(int sequenceNumber)

getGroupId

public java.lang.Object getGroupId()
Specified by:
getGroupId in interface MessageGroup
Returns:
the key that links these messages together

isComplete

public boolean isComplete()
Specified by:
isComplete in interface MessageGroup
Returns:
true if the group is complete (i.e. no more messages are expected to be added)

complete

public void complete()
Specified by:
complete in interface MessageGroup

getSequenceSize

public int getSequenceSize()
Specified by:
getSequenceSize in interface MessageGroup
Returns:
the size of the sequence expected 0 if unknown

size

public int size()
Specified by:
size in interface MessageGroup
Returns:
the total number of messages in this group

getOne

public Message<?> getOne()
Specified by:
getOne in interface MessageGroup
Returns:
a single message from the group

clear

public void clear()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Spring Integration