/** * Register a new {@link JmsListenerEndpoint} using the default * {@link JmsListenerContainerFactory} to create the underlying container. * @see #setContainerFactory(JmsListenerContainerFactory) * @see #registerEndpoint(JmsListenerEndpoint, JmsListenerContainerFactory) */ public void registerEndpoint(JmsListenerEndpoint endpoint) { registerEndpoint(endpoint, null); }
this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName); if (this.registrar.getEndpointRegistry() == null) { JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME, JmsListenerEndpointRegistry.class); this.registrar.setEndpointRegistry(this.endpointRegistry); MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory(); if (handlerMethodFactory != null) { this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory); this.registrar.afterPropertiesSet();
@Before public void setup() { this.registrar.setEndpointRegistry(this.registry); this.registrar.setBeanFactory(new StaticListableBeanFactory()); }
@Test public void registerNullContainerFactoryIsAllowed() throws Exception { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId("some id"); this.registrar.setContainerFactory(this.containerFactory); this.registrar.registerEndpoint(endpoint, null); this.registrar.afterPropertiesSet(); assertNotNull("Container not created", this.registry.getListenerContainer("some id")); assertEquals(1, this.registry.getListenerContainers().size()); assertEquals("some id", this.registry.getListenerContainerIds().iterator().next()); }
@Override public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) { registrar.setEndpointRegistry(customRegistry()); // Also register a custom endpoint SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId("myCustomEndpointId"); endpoint.setDestination("myQueue"); endpoint.setMessageListener(simpleMessageListener()); registrar.registerEndpoint(endpoint); }
@Test public void registerNullContainerFactoryWithNoDefault() throws Exception { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId("some id"); this.registrar.registerEndpoint(endpoint, null); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage(endpoint.toString()); this.registrar.afterPropertiesSet(); }
/** Setup the tracing endpoint registry */ @Bean JmsListenerConfigurer configureTracing(JmsTracing jmsTracing, CurrentTraceContext current) { return registrar -> registrar.setEndpointRegistry( new TracingJmsListenerEndpointRegistry(jmsTracing, current)); }
/** * Making a {@link BeanFactory} available is optional; if not set, * {@link JmsListenerConfigurer} beans won't get autodetected and an * {@link #setEndpointRegistry endpoint registry} has to be explicitly configured. */ @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (beanFactory instanceof ConfigurableBeanFactory) { this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory); } this.registrar.setBeanFactory(beanFactory); }
protected void registerAllEndpoints() { Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); synchronized (this.mutex) { for (JmsListenerEndpointDescriptor descriptor : this.endpointDescriptors) { this.endpointRegistry.registerListenerContainer( descriptor.endpoint, resolveContainerFactory(descriptor)); } this.startImmediately = true; // trigger immediate startup } }
@Override public void afterPropertiesSet() { registerAllEndpoints(); }
@Test public void registerContainerWithoutFactory() throws Exception { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId("myEndpoint"); this.registrar.setContainerFactory(this.containerFactory); this.registrar.registerEndpoint(endpoint); this.registrar.afterPropertiesSet(); assertNotNull("Container not created", this.registry.getListenerContainer("myEndpoint")); assertEquals(1, this.registry.getListenerContainers().size()); assertEquals("myEndpoint", this.registry.getListenerContainerIds().iterator().next()); }
/** Setup the tracing endpoint registry */ @Bean JmsListenerConfigurer configureTracing(JmsTracing jmsTracing, CurrentTraceContext current) { return registrar -> registrar.setEndpointRegistry( new TracingJmsListenerEndpointRegistry(jmsTracing, current)); }
/** * Making a {@link BeanFactory} available is optional; if not set, * {@link JmsListenerConfigurer} beans won't get autodetected and an * {@link #setEndpointRegistry endpoint registry} has to be explicitly configured. */ @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (beanFactory instanceof ConfigurableBeanFactory) { this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory); } this.registrar.setBeanFactory(beanFactory); }
/** * Register a new {@link JmsListenerEndpoint} alongside the * {@link JmsListenerContainerFactory} to use to create the underlying container. * <p>The {@code factory} may be {@code null} if the default factory has to be * used for that endpoint. */ public void registerEndpoint(JmsListenerEndpoint endpoint, @Nullable JmsListenerContainerFactory<?> factory) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.hasText(endpoint.getId(), "Endpoint id must be set"); // Factory may be null, we defer the resolution right before actually creating the container JmsListenerEndpointDescriptor descriptor = new JmsListenerEndpointDescriptor(endpoint, factory); synchronized (this.mutex) { if (this.startImmediately) { // register and start immediately Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); this.endpointRegistry.registerListenerContainer(descriptor.endpoint, resolveContainerFactory(descriptor), true); } else { this.endpointDescriptors.add(descriptor); } } }
@Override public void afterPropertiesSet() { registerAllEndpoints(); }
this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName); if (this.registrar.getEndpointRegistry() == null) { JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME, JmsListenerEndpointRegistry.class); this.registrar.setEndpointRegistry(this.endpointRegistry); MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory(); if (handlerMethodFactory != null) { this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory); this.registrar.afterPropertiesSet();
@Test public void registerNullEndpoint() { this.thrown.expect(IllegalArgumentException.class); this.registrar.registerEndpoint(null, this.containerFactory); }
/** * Making a {@link BeanFactory} available is optional; if not set, * {@link JmsListenerConfigurer} beans won't get autodetected and an * {@link #setEndpointRegistry endpoint registry} has to be explicitly configured. */ @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (beanFactory instanceof ConfigurableBeanFactory) { this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory); } this.registrar.setBeanFactory(beanFactory); }
protected void registerAllEndpoints() { Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); synchronized (this.mutex) { for (JmsListenerEndpointDescriptor descriptor : this.endpointDescriptors) { this.endpointRegistry.registerListenerContainer( descriptor.endpoint, resolveContainerFactory(descriptor)); } this.startImmediately = true; // trigger immediate startup } }
@Override public void afterPropertiesSet() { registerAllEndpoints(); }