org.springframework.jms.listener.SimpleMessageListenerContainer Java Examples
The following examples show how to use
org.springframework.jms.listener.SimpleMessageListenerContainer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example #2
Source File: JmsListenerContainerFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void createSimpleContainer() { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); setDefaultJmsConfig(factory); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); MessageListener messageListener = new MessageListenerAdapter(); endpoint.setMessageListener(messageListener); endpoint.setDestination("myQueue"); SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint); assertDefaultJmsConfig(container); assertEquals(messageListener, container.getMessageListener()); assertEquals("myQueue", container.getDestinationName()); }
Example #3
Source File: JmsListenerContainerFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void createSimpleContainer() { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); setDefaultJmsConfig(factory); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); MessageListener messageListener = new MessageListenerAdapter(); endpoint.setMessageListener(messageListener); endpoint.setDestination("myQueue"); SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint); assertDefaultJmsConfig(container); assertEquals(messageListener, container.getMessageListener()); assertEquals("myQueue", container.getDestinationName()); }
Example #4
Source File: JmsListenerContainerFactoryTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void createSimpleContainer() { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); setDefaultJmsConfig(factory); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); MessageListener messageListener = new MessageListenerAdapter(); endpoint.setMessageListener(messageListener); endpoint.setDestination("myQueue"); SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint); assertDefaultJmsConfig(container); assertEquals(messageListener, container.getMessageListener()); assertEquals("myQueue", container.getDestinationName()); }
Example #5
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example #6
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example #7
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void processFromQueueAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyPubSubDomain(true); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", true); assertListenerMethodInvocation(this.sample, methodName); }
Example #8
Source File: JmsServer.java From tutorials with MIT License | 5 votes |
@Bean SimpleMessageListenerContainer listener(ConnectionFactory factory, JmsInvokerServiceExporter exporter) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(factory); container.setDestinationName("remotingQueue"); container.setConcurrentConsumers(1); container.setMessageListener(exporter); return container; }
Example #9
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void processAndReplyWithCustomReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); QosSettings replyQosSettings = new QosSettings(1, 6, 6000); container.setReplyQosSettings(replyQosSettings); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false, replyQosSettings); assertListenerMethodInvocation(this.sample, methodName); }
Example #10
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void processAndReplyWithNullReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyQosSettings(null); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false); assertListenerMethodInvocation(this.sample, methodName); }
Example #11
Source File: ReceiverConfig.java From spring-jms with MIT License | 5 votes |
@Bean public SimpleMessageListenerContainer statusMessageListenerContainer() { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setMessageListener(new StatusMessageListener("SMLC")); endpoint.setDestination(status2Destination); return orderSimpleJmsListenerContainerFactory() .createListenerContainer(endpoint); }
Example #12
Source File: InboundGatewayConfig.java From spring-jms with MIT License | 5 votes |
@Bean public SimpleMessageListenerContainer simpleMessageListenerContainer( ConnectionFactory connectionFactory) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestinationName(orderRequestDestination); return container; }
Example #13
Source File: ConsumingChannelConfig.java From spring-jms with MIT License | 5 votes |
@Bean public SimpleMessageListenerContainer simpleMessageListenerContainer( ConnectionFactory connectionFactory) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestinationName(integrationDestination); return container; }
Example #14
Source File: AbstractJmsAnnotationDrivenTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }
Example #15
Source File: JmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setupConcurrencySimpleContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); MessageListener messageListener = new MessageListenerAdapter(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setConcurrency("5-10"); // simple implementation only support max value endpoint.setMessageListener(messageListener); endpoint.setupListenerContainer(container); assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers")); }
Example #16
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void processAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, false); assertListenerMethodInvocation(sample, methodName); }
Example #17
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void processFromTopicAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); container.setReplyPubSubDomain(false); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, false); assertListenerMethodInvocation(sample, methodName); }
Example #18
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void processAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, true); assertListenerMethodInvocation(sample, methodName); }
Example #19
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void processFromQueueAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyPubSubDomain(true); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, true); assertListenerMethodInvocation(sample, methodName); }
Example #20
Source File: JmsSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { AbstractMessageListenerContainer container = TestUtils.getPropertyValue(this.endpoint, "listenerContainer", AbstractMessageListenerContainer.class); assertThat(container, instanceOf(SimpleMessageListenerContainer.class)); assertEquals(Session.DUPS_OK_ACKNOWLEDGE, TestUtils.getPropertyValue(container, "sessionAcknowledgeMode")); assertFalse(TestUtils.getPropertyValue(container, "sessionTransacted", Boolean.class)); assertEquals("client", TestUtils.getPropertyValue(container, "clientId")); assertEquals("topic", TestUtils.getPropertyValue(container, "destination")); assertEquals("JMSCorrelationId=foo", TestUtils.getPropertyValue(container, "messageSelector")); assertFalse(TestUtils.getPropertyValue(container, "subscriptionDurable", Boolean.class)); assertFalse(TestUtils.getPropertyValue(container, "subscriptionShared", Boolean.class)); assertEquals(3, TestUtils.getPropertyValue(container, "concurrentConsumers")); assertTrue(TestUtils.getPropertyValue(container, "pubSubDomain", Boolean.class)); }
Example #21
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void processFromTopicAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); container.setReplyPubSubDomain(false); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false); assertListenerMethodInvocation(this.sample, methodName); }
Example #22
Source File: AbstractJmsAnnotationDrivenTests.java From spring-analysis-note with MIT License | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }
Example #23
Source File: JmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setupConcurrencySimpleContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); MessageListener messageListener = new MessageListenerAdapter(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setConcurrency("5-10"); // simple implementation only support max value endpoint.setMessageListener(messageListener); endpoint.setupListenerContainer(container); assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers")); }
Example #24
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false); assertListenerMethodInvocation(this.sample, methodName); }
Example #25
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processFromTopicAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); container.setReplyPubSubDomain(false); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false); assertListenerMethodInvocation(this.sample, methodName); }
Example #26
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", true); assertListenerMethodInvocation(this.sample, methodName); }
Example #27
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processFromQueueAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyPubSubDomain(true); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", true); assertListenerMethodInvocation(this.sample, methodName); }
Example #28
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processAndReplyWithCustomReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); QosSettings replyQosSettings = new QosSettings(1, 6, 6000); container.setReplyQosSettings(replyQosSettings); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false, replyQosSettings); assertListenerMethodInvocation(this.sample, methodName); }
Example #29
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void processAndReplyWithNullReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyQosSettings(null); MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container); processAndReplyWithSendTo(listener, "replyDestination", false); assertListenerMethodInvocation(this.sample, methodName); }
Example #30
Source File: AbstractJmsAnnotationDrivenTests.java From java-technology-stack with MIT License | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }