Search in sources :

Example 1 with MessageGroupMetadata

use of org.springframework.integration.store.MessageGroupMetadata in project spring-integration by spring-projects.

the class GemfireMessageStoreTests method testAddAndRemoveMessagesFromMessageGroupWithPrefix.

@Test
public void testAddAndRemoveMessagesFromMessageGroupWithPrefix() throws Exception {
    GemfireMessageStore messageStore = new GemfireMessageStore(region, "foo_");
    String groupId = "X";
    List<Message<?>> messages = new ArrayList<Message<?>>();
    for (int i = 0; i < 25; i++) {
        Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
        messageStore.addMessagesToGroup(groupId, message);
        messages.add(message);
    }
    MessageGroupMetadata messageGroupMetadata = (MessageGroupMetadata) region.get("foo_" + "MESSAGE_GROUP_" + groupId);
    assertNotNull(messageGroupMetadata);
    assertEquals(25, messageGroupMetadata.size());
    messageStore.removeMessagesFromGroup(groupId, messages);
    MessageGroup group = messageStore.getMessageGroup(groupId);
    assertEquals(0, group.size());
}
Also used : Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) ArrayList(java.util.ArrayList) MessageGroupMetadata(org.springframework.integration.store.MessageGroupMetadata) MessageGroup(org.springframework.integration.store.MessageGroup) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 MessageGroup (org.springframework.integration.store.MessageGroup)1 MessageGroupMetadata (org.springframework.integration.store.MessageGroupMetadata)1 Message (org.springframework.messaging.Message)1 GenericMessage (org.springframework.messaging.support.GenericMessage)1