Search in sources :

Example 16 with JmsMessageDrivenEndpoint

use of org.springframework.integration.jms.JmsMessageDrivenEndpoint in project spring-integration by spring-projects.

the class JmsMessageDrivenChannelAdapterParserTests method testAdapterWithIdleConsumerLimit.

@Test
public void testAdapterWithIdleConsumerLimit() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithContainerSettings.xml", this.getClass());
    JmsMessageDrivenEndpoint adapter = (JmsMessageDrivenEndpoint) context.getBean("adapterWithIdleConsumerLimit.adapter");
    adapter.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(adapter).getPropertyValue("listenerContainer");
    assertEquals(33, new DirectFieldAccessor(container).getPropertyValue("idleConsumerLimit"));
    assertEquals(3, new DirectFieldAccessor(container).getPropertyValue("cacheLevel"));
    adapter.stop();
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 17 with JmsMessageDrivenEndpoint

use of org.springframework.integration.jms.JmsMessageDrivenEndpoint in project spring-integration by spring-projects.

the class JmsMessageDrivenChannelAdapterParserTests method adapterWithDurableSubscription.

@Test
public void adapterWithDurableSubscription() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithDurableSubscription.xml", this.getClass());
    JmsMessageDrivenEndpoint endpoint = context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
    DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
    assertEquals(Boolean.TRUE, container.isPubSubDomain());
    assertEquals(Boolean.TRUE, container.isSubscriptionDurable());
    assertEquals("testDurableSubscriptionName", container.getDurableSubscriptionName());
    assertEquals("testClientId", container.getClientId());
    assertTrue(container.isSubscriptionShared());
    endpoint.stop();
    context.close();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Example 18 with JmsMessageDrivenEndpoint

use of org.springframework.integration.jms.JmsMessageDrivenEndpoint in project spring-integration by spring-projects.

the class JmsMessageDrivenChannelAdapterParserTests method testAdapterWithRecoveryInterval.

@Test
public void testAdapterWithRecoveryInterval() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithContainerSettings.xml", this.getClass());
    JmsMessageDrivenEndpoint adapter = (JmsMessageDrivenEndpoint) context.getBean("adapterWithRecoveryInterval.adapter");
    adapter.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(adapter).getPropertyValue("listenerContainer");
    Object recoveryInterval;
    try {
        recoveryInterval = TestUtils.getPropertyValue(container, "recoveryInterval");
    } catch (NotReadablePropertyException e) {
        recoveryInterval = TestUtils.getPropertyValue(container, "backOff.interval");
    }
    assertEquals(2222L, recoveryInterval);
    adapter.stop();
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) NotReadablePropertyException(org.springframework.beans.NotReadablePropertyException) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 19 with JmsMessageDrivenEndpoint

use of org.springframework.integration.jms.JmsMessageDrivenEndpoint in project spring-integration by spring-projects.

the class JmsMessageDrivenChannelAdapterParserTests method testAdapterWithContainerClass.

@Test
public void testAdapterWithContainerClass() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithContainerClass.xml", this.getClass());
    JmsMessageDrivenEndpoint adapter = context.getBean("adapterWithIdleConsumerLimit.adapter", JmsMessageDrivenEndpoint.class);
    MessageChannel channel = context.getBean("adapterWithIdleConsumerLimit", MessageChannel.class);
    assertSame(channel, TestUtils.getPropertyValue(adapter, "listener.gatewayDelegate.requestChannel"));
    adapter.start();
    FooContainer container = TestUtils.getPropertyValue(adapter, "listenerContainer", FooContainer.class);
    assertSame(container, context.getBean("adapterWithIdleConsumerLimit.container"));
    assertEquals(33, new DirectFieldAccessor(container).getPropertyValue("idleConsumerLimit"));
    assertEquals(3, new DirectFieldAccessor(container).getPropertyValue("cacheLevel"));
    assertSame(context.getBean("adapterWithIdleConsumerLimit.listener"), TestUtils.getPropertyValue(container, "messageListener"));
    adapter.stop();
    adapter = context.getBean("adapterWithIdleConsumerLimit2.adapter", JmsMessageDrivenEndpoint.class);
    channel = context.getBean("adapterWithIdleConsumerLimit2", MessageChannel.class);
    assertSame(channel, TestUtils.getPropertyValue(adapter, "listener.gatewayDelegate.requestChannel"));
    adapter.start();
    container = TestUtils.getPropertyValue(adapter, "listenerContainer", FooContainer.class);
    assertSame(container, context.getBean("adapterWithIdleConsumerLimit2.container"));
    assertEquals(33, new DirectFieldAccessor(container).getPropertyValue("idleConsumerLimit"));
    assertEquals(3, new DirectFieldAccessor(container).getPropertyValue("cacheLevel"));
    adapter.stop();
    adapter = context.getBean("org.springframework.integration.jms.JmsMessageDrivenEndpoint#0", JmsMessageDrivenEndpoint.class);
    channel = context.getBean("in", MessageChannel.class);
    assertSame(channel, TestUtils.getPropertyValue(adapter, "listener.gatewayDelegate.requestChannel"));
    adapter.start();
    container = TestUtils.getPropertyValue(adapter, "listenerContainer", FooContainer.class);
    assertSame(container, context.getBean("org.springframework.integration.jms.JmsMessageDrivenEndpoint#0.container"));
    assertEquals(33, new DirectFieldAccessor(container).getPropertyValue("idleConsumerLimit"));
    assertEquals(3, new DirectFieldAccessor(container).getPropertyValue("cacheLevel"));
    adapter.stop();
    context.close();
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Example 20 with JmsMessageDrivenEndpoint

use of org.springframework.integration.jms.JmsMessageDrivenEndpoint in project spring-integration by spring-projects.

the class JmsInboundGatewayParserTests method testGatewayWithMessageConverter.

@Test
public void testGatewayWithMessageConverter() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithMessageConverter.xml", this.getClass());
    PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
    assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
    context.start();
    Message<?> message = channel.receive(10000);
    assertNotNull("message should not be null", message);
    assertEquals("converted-test-message", message.getPayload());
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)22 JmsMessageDrivenEndpoint (org.springframework.integration.jms.JmsMessageDrivenEndpoint)22 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)15 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)7 PollableChannel (org.springframework.messaging.PollableChannel)5 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)3 Properties (java.util.Properties)2 NotReadablePropertyException (org.springframework.beans.NotReadablePropertyException)2 MessageHistory (org.springframework.integration.history.MessageHistory)2 ConnectionFactory (javax.jms.ConnectionFactory)1 SmartLifecycle (org.springframework.context.SmartLifecycle)1 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1 JmsDestinationAccessor (org.springframework.jms.support.destination.JmsDestinationAccessor)1 MessageChannel (org.springframework.messaging.MessageChannel)1