/** * Test for {@link FullBean} discovery. In this case, no default is set because * all endpoints provide a default registry. This shows that the default factory * is only retrieved if it needs to be. */ public void testFullConfiguration(ApplicationContext context) { JmsListenerContainerTestFactory simpleFactory = context.getBean("simpleFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); assertEquals("listener1", endpoint.getId()); assertEquals("queueIn", endpoint.getDestination()); assertEquals("mySelector", endpoint.getSelector()); assertEquals("mySubscription", endpoint.getSubscription()); assertEquals("1-10", endpoint.getConcurrency()); Method m = ReflectionUtils.findMethod(endpoint.getClass(), "getDefaultResponseDestination"); ReflectionUtils.makeAccessible(m); Object destination = ReflectionUtils.invokeMethod(m, endpoint); assertEquals("queueOut", destination); }
@Test public void composedJmsListeners() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) { JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertEquals(2, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer( "first").getEndpoint(); assertEquals("first", first.getId()); assertEquals("orderQueue", first.getDestination()); assertNull(first.getConcurrency()); MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer( "second").getEndpoint(); assertEquals("second", second.getId()); assertEquals("billingQueue", second.getDestination()); assertEquals("2-10", second.getConcurrency()); } }
/** * Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the * {@code @JmsListener} annotation is repeatable and generate one specific container per annotation. */ public void testJmsListenerRepeatable(ApplicationContext context) { JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertEquals(2, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer("first").getEndpoint(); assertEquals("first", first.getId()); assertEquals("myQueue", first.getDestination()); assertEquals(null, first.getConcurrency()); MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint(); assertEquals("second", second.getId()); assertEquals("anotherQueue", second.getDestination()); assertEquals("2-10", second.getConcurrency()); }
dest.setSubscription(source.getSubscription()); dest.setSelector(source.getSelector()); dest.setConcurrency(source.getConcurrency());
dest.setSubscription(source.getSubscription()); dest.setSelector(source.getSelector()); dest.setConcurrency(source.getConcurrency());