@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); }
/** * Register a new {@link RabbitListenerEndpoint} using the default * {@link RabbitListenerContainerFactory} to create the underlying container. * @param endpoint the {@link RabbitListenerEndpoint} instance to register. * @see #setContainerFactory(RabbitListenerContainerFactory) * @see #registerEndpoint(RabbitListenerEndpoint, RabbitListenerContainerFactory) */ public void registerEndpoint(RabbitListenerEndpoint endpoint) { registerEndpoint(endpoint, null); }
@Override public void afterSingletonsInstantiated() { this.registrar.setBeanFactory(this.beanFactory); if (this.registrar.getEndpointRegistry() == null) { if (this.endpointRegistry == null) { Assert.state(this.beanFactory != null, RabbitListenerEndpointRegistry.class); this.registrar.setEndpointRegistry(this.endpointRegistry); this.registrar.setContainerFactoryBeanName(this.defaultContainerFactoryBeanName); MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory(); if (handlerMethodFactory != null) { this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory); this.registrar.afterPropertiesSet();
@Test public void registerContainerWithoutFactory() throws Exception { SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId("myEndpoint"); registrar.setContainerFactory(containerFactory); registrar.registerEndpoint(endpoint); registrar.afterPropertiesSet(); assertNotNull("Container not created", registry.getListenerContainer("myEndpoint")); assertEquals("myEndpoint", registry.getListenerContainerIds().iterator().next()); assertEquals(1, registry.getListenerContainers().size()); }
@Test public void registerNullContainerFactoryWithNoDefault() throws Exception { SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId("some id"); registrar.registerEndpoint(endpoint, null); thrown.expect(IllegalStateException.class); thrown.expectMessage(endpoint.toString()); registrar.afterPropertiesSet(); }
@Override public void configureRabbitListeners(RabbitListenerEndpointRegistrar registrar) { registrar.setEndpointRegistry(customRegistry()); // Also register a custom endpoint SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId("myCustomEndpointId"); endpoint.setQueueNames("myQueue"); endpoint.setMessageListener(simpleMessageListener()); registrar.registerEndpoint(endpoint); }
@Before public void setup() { registrar.setEndpointRegistry(registry); registrar.setBeanFactory(new StaticListableBeanFactory()); }
@Override public void afterPropertiesSet() { registerAllEndpoints(); }
@Test public void registerNullContainerFactoryIsAllowed() throws Exception { SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId("some id"); registrar.setContainerFactory(containerFactory); registrar.registerEndpoint(endpoint, null); registrar.afterPropertiesSet(); assertNotNull("Container not created", registry.getListenerContainer("some id")); assertEquals("some id", registry.getListenerContainerIds().iterator().next()); assertEquals(1, registry.getListenerContainers().size()); }
@Override public void afterPropertiesSet() { registerAllEndpoints(); }
@Override public void afterSingletonsInstantiated() { this.registrar.setBeanFactory(this.beanFactory); if (this.registrar.getEndpointRegistry() == null) { if (this.endpointRegistry == null) { Assert.state(this.beanFactory != null, RabbitListenerEndpointRegistry.class); this.registrar.setEndpointRegistry(this.endpointRegistry); this.registrar.setContainerFactoryBeanName(this.defaultContainerFactoryBeanName); MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory(); if (handlerMethodFactory != null) { this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory); this.registrar.afterPropertiesSet();
@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); }
/** * Register a new {@link RabbitListenerEndpoint} using the default * {@link RabbitListenerContainerFactory} to create the underlying container. * @param endpoint the {@link RabbitListenerEndpoint} instance to register. * @see #setContainerFactory(RabbitListenerContainerFactory) * @see #registerEndpoint(RabbitListenerEndpoint, RabbitListenerContainerFactory) */ public void registerEndpoint(RabbitListenerEndpoint endpoint) { registerEndpoint(endpoint, null); }
@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); } }
@Test public void registerNullEndpoint() { thrown.expect(IllegalArgumentException.class); registrar.registerEndpoint(null, containerFactory); }
@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); }
@Test public void registerNullEndpointId() { thrown.expect(IllegalArgumentException.class); registrar.registerEndpoint(new SimpleRabbitListenerEndpoint(), containerFactory); }
@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); }
@Test public void registerEmptyEndpointId() { SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId(""); thrown.expect(IllegalArgumentException.class); registrar.registerEndpoint(endpoint, containerFactory); }
@Override public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) { registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory()); }