private SimpleJmsListenerEndpoint createEndpoint(String id, String destinationName) { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId(id); endpoint.setDestination(destinationName); return endpoint; }
@Override public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId("myCustomEndpointId"); endpoint.setDestination("myQueue"); endpoint.setMessageListener(messageListener); registrar.registerEndpoint(endpoint); }
@Test public void registerEmptyEndpointId() { SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId(""); this.thrown.expect(IllegalArgumentException.class); this.registrar.registerEndpoint(endpoint, this.containerFactory); }
@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()); }
@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(); }
private void registerListenerEndpoint(JmsListenerEndpointRegistrar aRegistrar, String aQueueName, int aConcurrency, Object aDelegate, String aMethodName) { logger.info("Registring JMS Listener: {} -> {}:{}", aQueueName, aDelegate.getClass().getName(), aMethodName); MessageListenerAdapter messageListener = new NoReplyMessageListenerAdapter(aDelegate); messageListener.setMessageConverter(jacksonJmsMessageConverter(objectMapper)); messageListener.setDefaultListenerMethod(aMethodName); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); endpoint.setId(aQueueName+"Endpoint"); endpoint.setDestination(aQueueName); endpoint.setMessageListener(messageListener); aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency)); }