Search in sources :

Example 91 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundGatewayParserTests method gatewayWithDestName.

@Test
public void gatewayWithDestName() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDestName");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    assertEquals("replyQueueName", accessor.getPropertyValue("replyDestinationName"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 92 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundGatewayParserTests method gatewayWithDestBeanRefExpression.

@Test
public void gatewayWithDestBeanRefExpression() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDestExpressionBeanRef");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor", ExpressionEvaluatingMessageProcessor.class);
    Expression expression = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor.expression", Expression.class);
    assertEquals("@replyQueue", expression.getExpressionString());
    assertSame(context.getBean("replyQueue"), processor.processMessage(null));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Expression(org.springframework.expression.Expression) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 93 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundGatewayParserTests method gatewayWithDest.

@Test
public void gatewayWithDest() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDest");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    assertSame(context.getBean("replyQueue"), accessor.getPropertyValue("replyDestination"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 94 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundGatewayParserTests method testWithDeliveryPersistentAttribute.

@Test
public void testWithDeliveryPersistentAttribute() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithDeliveryPersistent.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGateway");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    int deliveryMode = (Integer) accessor.getPropertyValue("deliveryMode");
    assertEquals(DeliveryMode.PERSISTENT, deliveryMode);
    assertTrue(TestUtils.getPropertyValue(gateway, "async", Boolean.class));
    DefaultMessageListenerContainer container = TestUtils.getPropertyValue(gateway, "replyContainer", DefaultMessageListenerContainer.class);
    assertEquals(4, TestUtils.getPropertyValue(container, "concurrentConsumers"));
    assertEquals(5, TestUtils.getPropertyValue(container, "maxConcurrentConsumers"));
    assertEquals(10, TestUtils.getPropertyValue(container, "maxMessagesPerTask"));
    assertEquals(2000L, TestUtils.getPropertyValue(container, "receiveTimeout"));
    Object recoveryInterval;
    try {
        recoveryInterval = TestUtils.getPropertyValue(container, "recoveryInterval");
    } catch (NotReadablePropertyException e) {
        recoveryInterval = TestUtils.getPropertyValue(container, "backOff.interval");
    }
    assertEquals(10000L, recoveryInterval);
    assertEquals(7, TestUtils.getPropertyValue(container, "idleConsumerLimit"));
    assertEquals(2, TestUtils.getPropertyValue(container, "idleTaskExecutionLimit"));
    assertEquals(3, TestUtils.getPropertyValue(container, "cacheLevel"));
    assertTrue(container.isSessionTransacted());
    assertSame(context.getBean("exec"), TestUtils.getPropertyValue(container, "taskExecutor"));
    assertEquals(1234000L, TestUtils.getPropertyValue(gateway, "idleReplyContainerTimeout"));
    context.close();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) NotReadablePropertyException(org.springframework.beans.NotReadablePropertyException) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 95 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class MongoDbOutboundGatewayXmlTests method testSingleQuery.

@Test
@MongoDbAvailable
public void testSingleQuery() throws Exception {
    EventDrivenConsumer consumer = context.getBean("gatewaySingleQuery", EventDrivenConsumer.class);
    PollableChannel outChannel = context.getBean("out", PollableChannel.class);
    Message<String> message = MessageBuilder.withPayload("").build();
    consumer.getHandler().handleMessage(message);
    Message<?> result = outChannel.receive(10000);
    Person person = getPerson(result);
    assertEquals("Xavi", person.getName());
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Aggregations

EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)106 Test (org.junit.Test)96 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)29 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)27 DirectChannel (org.springframework.integration.channel.DirectChannel)19 PollableChannel (org.springframework.messaging.PollableChannel)19 GenericMessage (org.springframework.messaging.support.GenericMessage)18 MessageChannel (org.springframework.messaging.MessageChannel)16 QueueChannel (org.springframework.integration.channel.QueueChannel)14 MessageHandler (org.springframework.messaging.MessageHandler)12 List (java.util.List)9 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)9 Message (org.springframework.messaging.Message)8 SmartLifecycle (org.springframework.context.SmartLifecycle)6 JmsOutboundGateway (org.springframework.integration.jms.JmsOutboundGateway)6 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)6 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)6 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)5 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)5 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)5