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

Field Summary
 java.util.concurrent.BlockingQueue<Message<?>> marked
           
 java.util.concurrent.BlockingQueue<Message<?>> unmarked
           
 
Constructor Summary
SimpleMessageGroup(java.util.Collection<? extends Message<?>> unmarked, java.util.Collection<? extends Message<?>> marked, java.lang.Object groupId, long timestamp, boolean complete)
           
SimpleMessageGroup(java.util.Collection<? extends Message<?>> unmarked, java.lang.Object groupId)
           
SimpleMessageGroup(MessageGroup template)
           
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()
           
 int getLastReleasedMessageSequenceNumber()
          Returns the sequenceNumber of the last released message.
 java.util.Collection<Message<?>> getMarked()
           
 Message<?> getOne()
           
 int getSequenceSize()
           
 long getTimestamp()
           
 java.util.Collection<Message<?>> getUnmarked()
           
 boolean isComplete()
           
 void mark(Message<?> messageToMark)
          Mark the given message in this group.
 void markAll()
           
 void remove(Message<?> message)
           
 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

marked

public final java.util.concurrent.BlockingQueue<Message<?>> marked

unmarked

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

SimpleMessageGroup

public SimpleMessageGroup(java.lang.Object groupId)

SimpleMessageGroup

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

SimpleMessageGroup

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

SimpleMessageGroup

public SimpleMessageGroup(MessageGroup template)
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

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

getUnmarked

public java.util.Collection<Message<?>> getUnmarked()
Specified by:
getUnmarked in interface MessageGroup
Returns:
unmarked messages in the group at time of the invocation

setLastReleasedMessageSequenceNumber

public void setLastReleasedMessageSequenceNumber(int sequenceNumber)

getMarked

public java.util.Collection<Message<?>> getMarked()
Specified by:
getMarked in interface MessageGroup
Returns:
marked messages in the group at the time of the invocation

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

mark

public void mark(Message<?> messageToMark)
Mark the given message in this group. If the message is not part of this group then this call has no effect.


markAll

public void markAll()

size

public int size()
Specified by:
size in interface MessageGroup
Returns:
the total number of messages (marked and unmarked) 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