Search in sources :

Example 6 with AbstractMessageSplitter

use of org.springframework.integration.splitter.AbstractMessageSplitter in project spring-integration by spring-projects.

the class CollectionAndArrayTests method setWithSplittingHandler.

@Test
public void setWithSplittingHandler() {
    AbstractMessageSplitter handler = new AbstractMessageSplitter() {

        @Override
        protected Object splitMessage(Message<?> message) {
            return new HashSet<String>(Arrays.asList(new String[] { "foo", "bar" }));
        }
    };
    QueueChannel channel = new QueueChannel();
    Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(channel).build();
    handler.handleMessage(message);
    Message<?> reply1 = channel.receive(0);
    Message<?> reply2 = channel.receive(0);
    assertNotNull(reply1);
    assertNotNull(reply2);
    assertEquals(String.class, reply1.getPayload().getClass());
    assertEquals(String.class, reply2.getPayload().getClass());
}
Also used : Message(org.springframework.messaging.Message) QueueChannel(org.springframework.integration.channel.QueueChannel) AbstractMessageSplitter(org.springframework.integration.splitter.AbstractMessageSplitter) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AbstractMessageSplitter (org.springframework.integration.splitter.AbstractMessageSplitter)6 Test (org.junit.Test)3 QueueChannel (org.springframework.integration.channel.QueueChannel)3 Message (org.springframework.messaging.Message)3 MessageHandler (org.springframework.messaging.MessageHandler)2 HashSet (java.util.HashSet)1 Bean (org.springframework.context.annotation.Bean)1 DefaultMessageSplitter (org.springframework.integration.splitter.DefaultMessageSplitter)1 MethodInvokingSplitter (org.springframework.integration.splitter.MethodInvokingSplitter)1