Search in sources :

Example 1 with AbstractBatchingMessageGroupStore

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

the class AbstractMongoDbMessageGroupStoreTests method testAddAndRemoveMessagesFromMessageGroup.

@Test
@MongoDbAvailable
public void testAddAndRemoveMessagesFromMessageGroup() throws Exception {
    MessageGroupStore messageStore = (MessageGroupStore) this.getMessageStore();
    String groupId = "X";
    messageStore.removeMessageGroup("X");
    ((AbstractBatchingMessageGroupStore) messageStore).setRemoveBatchSize(10);
    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);
    }
    MessageGroup group = messageStore.getMessageGroup(groupId);
    assertEquals(25, group.size());
    messageStore.removeMessagesFromGroup(groupId, messages);
    group = messageStore.getMessageGroup(groupId);
    assertEquals(0, group.size());
}
Also used : AbstractBatchingMessageGroupStore(org.springframework.integration.store.AbstractBatchingMessageGroupStore) MessageGroupStore(org.springframework.integration.store.MessageGroupStore) AbstractBatchingMessageGroupStore(org.springframework.integration.store.AbstractBatchingMessageGroupStore) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) ArrayList(java.util.ArrayList) MessageGroup(org.springframework.integration.store.MessageGroup) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Aggregations

ArrayList (java.util.ArrayList)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)1 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)1 MessageGroup (org.springframework.integration.store.MessageGroup)1 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)1 Message (org.springframework.messaging.Message)1 GenericMessage (org.springframework.messaging.support.GenericMessage)1