Search in sources :

Example 36 with PollableChannel

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

the class PollerWithErrorChannelTests method testWithErrorChannel.

@Test
public void testWithErrorChannel() throws Exception {
    ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
    SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannel", SourcePollingChannelAdapter.class);
    adapter.start();
    PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class);
    assertNotNull(errorChannel.receive(10000));
    adapter.stop();
    ac.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Example 37 with PollableChannel

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

the class GatewayParserTests method testAsyncDisabledGateway.

@Test
public void testAsyncDisabledGateway() throws Exception {
    PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
    MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
    this.startResponder(requestChannel, replyChannel);
    TestService service = context.getBean("asyncOff", TestService.class);
    Future<Message<?>> result = service.async("futureSync");
    Message<?> reply = result.get(10, TimeUnit.SECONDS);
    assertEquals("futureSync", reply.getPayload());
    Object serviceBean = context.getBean("&asyncOff");
    assertNull(TestUtils.getPropertyValue(serviceBean, "asyncExecutor"));
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) TestService(org.springframework.integration.gateway.TestService) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 38 with PollableChannel

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

the class GatewayParserTests method testRequestReply.

@Test
public void testRequestReply() {
    PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
    MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
    this.startResponder(requestChannel, replyChannel);
    TestService service = (TestService) context.getBean("requestReply");
    String result = service.requestReply("foo");
    assertEquals("foo", result);
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) TestService(org.springframework.integration.gateway.TestService) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 39 with PollableChannel

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

the class GatewayParserTests method testMonoGateway.

@Test
public void testMonoGateway() throws Exception {
    PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class);
    MessageChannel replyChannel = context.getBean("replyChannel", MessageChannel.class);
    this.startResponder(requestChannel, replyChannel);
    TestService service = context.getBean("promise", TestService.class);
    Mono<Message<?>> result = service.promise("foo");
    Message<?> reply = result.block(Duration.ofSeconds(1));
    assertEquals("foo", reply.getPayload());
    assertNotNull(TestUtils.getPropertyValue(context.getBean("&promise"), "asyncExecutor"));
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) TestService(org.springframework.integration.gateway.TestService) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 40 with PollableChannel

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

the class GatewayParserTests method testSolicitResponse.

@Test
public void testSolicitResponse() {
    PollableChannel channel = (PollableChannel) context.getBean("replyChannel");
    channel.send(new GenericMessage<String>("foo"));
    TestService service = (TestService) context.getBean("solicitResponse");
    String result = service.solicitResponse();
    assertEquals("foo", result);
}
Also used : TestService(org.springframework.integration.gateway.TestService) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

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