Search in sources :

Example 91 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class SimpleWebServiceOutboundGatewayTests method testWsOutboundGatewayInsideChain.

// INT-1029
@Test
public void testWsOutboundGatewayInsideChain() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("WebServiceOutboundGatewayInsideChainTests-context.xml", this.getClass());
    MessageChannel channel = context.getBean("wsOutboundGatewayInsideChain", MessageChannel.class);
    channel.send(MessageBuilder.withPayload("<test>foo</test>").build());
    PollableChannel replyChannel = context.getBean("replyChannel", PollableChannel.class);
    Message<?> replyMessage = replyChannel.receive();
    assertThat(replyMessage.getPayload().toString(), Matchers.endsWith(response));
    context.close();
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 92 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class RecipientListRouterParserTests method noSelectorMatchRouter.

@Test
public void noSelectorMatchRouter() {
    context.start();
    Message<?> message = new GenericMessage<Integer>(1);
    noSelectorMatchInput.send(message);
    PollableChannel chanel1 = (PollableChannel) context.getBean("channel1");
    PollableChannel chanel2 = (PollableChannel) context.getBean("channel2");
    Message<?> output = chanel1.receive(0);
    assertNotNull(output);
    assertTrue(output.getPayload().equals(1));
    assertNull(chanel2.receive(0));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 93 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class RecipientListRouterParserTests method simpleDynamicRouter.

@Test
public void simpleDynamicRouter() {
    context.start();
    Message<?> message = new GenericMessage<Integer>(1);
    simpleDynamicInput.send(message);
    PollableChannel chanel1 = (PollableChannel) context.getBean("channel1");
    PollableChannel chanel2 = (PollableChannel) context.getBean("channel2");
    assertTrue(chanel1.receive(0).getPayload().equals(1));
    assertNull(chanel2.receive(0));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 94 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class SplitterAggregatorTests method testSplitterAndAggregator.

@Test
public void testSplitterAndAggregator() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("splitterAggregatorTests.xml", this.getClass());
    MessageChannel inputChannel = (MessageChannel) context.getBean("numbers");
    PollableChannel outputChannel = (PollableChannel) context.getBean("results");
    inputChannel.send(new GenericMessage<Numbers>(this.nextTen()));
    Message<?> result1 = outputChannel.receive(1000);
    assertNotNull(result1);
    assertEquals(Integer.class, result1.getPayload().getClass());
    assertEquals(55, result1.getPayload());
    inputChannel.send(new GenericMessage<Numbers>(this.nextTen()));
    Message<?> result2 = outputChannel.receive(1000);
    assertNotNull(result2);
    assertEquals(Integer.class, result2.getPayload().getClass());
    assertEquals(155, result2.getPayload());
    context.close();
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 95 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class JdbcPollingChannelAdapterParserTests method setupMessagingTemplate.

protected void setupMessagingTemplate() {
    PollableChannel pollableChannel = this.appCtx.getBean("target", PollableChannel.class);
    this.messagingTemplate = new MessagingTemplate();
    this.messagingTemplate.setDefaultDestination(pollableChannel);
    this.messagingTemplate.setReceiveTimeout(10000);
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) PollableChannel(org.springframework.messaging.PollableChannel)

Aggregations

PollableChannel (org.springframework.messaging.PollableChannel)210 Test (org.junit.Test)190 MessageChannel (org.springframework.messaging.MessageChannel)89 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)82 QueueChannel (org.springframework.integration.channel.QueueChannel)52 GenericMessage (org.springframework.messaging.support.GenericMessage)52 Message (org.springframework.messaging.Message)40 BeanFactory (org.springframework.beans.factory.BeanFactory)25 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)20 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)19 MessagingException (org.springframework.messaging.MessagingException)16 SourcePollingChannelAdapter (org.springframework.integration.endpoint.SourcePollingChannelAdapter)13 MessagingTemplate (org.springframework.integration.core.MessagingTemplate)12 ErrorMessage (org.springframework.messaging.support.ErrorMessage)12 Document (org.w3c.dom.Document)12 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 Matchers.containsString (org.hamcrest.Matchers.containsString)11 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 MessageHistory (org.springframework.integration.history.MessageHistory)9