Java Code Examples for org.springframework.jms.listener.SimpleMessageListenerContainer
The following examples show how to use
org.springframework.jms.listener.SimpleMessageListenerContainer.
These examples are extracted from open source projects.
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 Project: spring-analysis-note Author: Vip-Augus File: JmsListenerAnnotationBeanPostProcessorTests.java License: 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 Project: spring-analysis-note Author: Vip-Augus File: JmsListenerContainerFactoryTests.java License: 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 Project: java-technology-stack Author: codeEngraver File: JmsListenerAnnotationBeanPostProcessorTests.java License: 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 #4
Source Project: java-technology-stack Author: codeEngraver File: JmsListenerContainerFactoryTests.java License: 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 #5
Source Project: spring4-understanding Author: langtianya File: JmsListenerAnnotationBeanPostProcessorTests.java License: 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 #6
Source Project: spring4-understanding Author: langtianya File: JmsListenerContainerFactoryTests.java License: 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 #7
Source Project: spring-analysis-note Author: Vip-Augus File: AbstractJmsAnnotationDrivenTests.java License: 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 #8
Source Project: spring-analysis-note Author: Vip-Augus File: JmsListenerEndpointTests.java License: 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 #9
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #10
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #11
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #12
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #13
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #14
Source Project: spring-analysis-note Author: Vip-Augus File: MethodJmsListenerEndpointTests.java License: 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 #15
Source Project: java-technology-stack Author: codeEngraver File: AbstractJmsAnnotationDrivenTests.java License: 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 #16
Source Project: java-technology-stack Author: codeEngraver File: JmsListenerEndpointTests.java License: 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 #17
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #18
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #19
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #20
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #21
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #22
Source Project: java-technology-stack Author: codeEngraver File: MethodJmsListenerEndpointTests.java License: 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 #23
Source Project: spring-jms Author: code-not-found File: ReceiverConfig.java License: 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 #24
Source Project: spring-jms Author: code-not-found File: InboundGatewayConfig.java License: MIT License | 5 votes |
@Bean public SimpleMessageListenerContainer simpleMessageListenerContainer( ConnectionFactory connectionFactory) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestinationName(orderRequestDestination); return container; }
Example #25
Source Project: spring-jms Author: code-not-found File: ConsumingChannelConfig.java License: MIT License | 5 votes |
@Bean public SimpleMessageListenerContainer simpleMessageListenerContainer( ConnectionFactory connectionFactory) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestinationName(integrationDestination); return container; }
Example #26
Source Project: spring4-understanding Author: langtianya File: AbstractJmsAnnotationDrivenTests.java License: 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 #27
Source Project: spring4-understanding Author: langtianya File: JmsListenerEndpointTests.java License: 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 #28
Source Project: spring4-understanding Author: langtianya File: MethodJmsListenerEndpointTests.java License: 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 #29
Source Project: spring4-understanding Author: langtianya File: MethodJmsListenerEndpointTests.java License: 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 #30
Source Project: spring4-understanding Author: langtianya File: MethodJmsListenerEndpointTests.java License: 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); }