use of org.springframework.jms.listener.endpoint.JmsMessageEndpointManager in project spring-framework by spring-projects.
the class DefaultJcaListenerContainerFactory method createListenerContainer.
@Override
public JmsMessageEndpointManager createListenerContainer(JmsListenerEndpoint endpoint) {
if (this.destinationResolver != null && this.activationSpecFactory != null) {
throw new IllegalStateException("Specify either 'activationSpecFactory' or " + "'destinationResolver', not both. If you define a dedicated JmsActivationSpecFactory bean, " + "specify the custom DestinationResolver there (if possible)");
}
JmsMessageEndpointManager instance = createContainerInstance();
if (this.resourceAdapter != null) {
instance.setResourceAdapter(this.resourceAdapter);
}
if (this.activationSpecFactory != null) {
instance.setActivationSpecFactory(this.activationSpecFactory);
}
if (this.destinationResolver != null) {
instance.setDestinationResolver(this.destinationResolver);
}
if (this.transactionManager != null) {
instance.setTransactionManager(this.transactionManager);
}
if (this.phase != null) {
instance.setPhase(this.phase);
}
instance.setActivationSpecConfig(this);
endpoint.setupListenerContainer(instance);
return instance;
}
use of org.springframework.jms.listener.endpoint.JmsMessageEndpointManager in project spring-framework by spring-projects.
the class JmsListenerEndpointTests method setupJcaMessageContainerFullConfig.
@Test
public void setupJcaMessageContainerFullConfig() {
JmsMessageEndpointManager container = new JmsMessageEndpointManager();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setDestination("myQueue");
endpoint.setSelector("foo = 'bar'");
endpoint.setSubscription("mySubscription");
endpoint.setConcurrency("10");
endpoint.setMessageListener(messageListener);
endpoint.setupListenerContainer(container);
JmsActivationSpecConfig config = container.getActivationSpecConfig();
assertEquals("myQueue", config.getDestinationName());
assertEquals("foo = 'bar'", config.getMessageSelector());
assertEquals("mySubscription", config.getSubscriptionName());
assertEquals(10, config.getMaxConcurrency());
assertEquals(messageListener, container.getMessageListener());
}
use of org.springframework.jms.listener.endpoint.JmsMessageEndpointManager in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryTests method createJcaContainerFullConfig.
@Test
public void createJcaContainerFullConfig() {
DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
setDefaultJcaConfig(factory);
factory.setConcurrency("10");
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);
endpoint.setDestination("myQueue");
JmsMessageEndpointManager container = factory.createListenerContainer(endpoint);
assertDefaultJcaConfig(container);
assertEquals(10, container.getActivationSpecConfig().getMaxConcurrency());
assertEquals(messageListener, container.getMessageListener());
assertEquals("myQueue", container.getActivationSpecConfig().getDestinationName());
}
use of org.springframework.jms.listener.endpoint.JmsMessageEndpointManager in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testJcaContainerConfiguration.
@Test
public void testJcaContainerConfiguration() throws Exception {
Map<String, JmsMessageEndpointManager> containers = context.getBeansOfType(JmsMessageEndpointManager.class);
assertTrue("listener3 not found", containers.containsKey("listener3"));
JmsMessageEndpointManager listener3 = containers.get("listener3");
assertEquals("Wrong resource adapter", context.getBean("testResourceAdapter"), listener3.getResourceAdapter());
assertEquals("Wrong activation spec factory", context.getBean("testActivationSpecFactory"), new DirectFieldAccessor(listener3).getPropertyValue("activationSpecFactory"));
Object endpointFactory = new DirectFieldAccessor(listener3).getPropertyValue("endpointFactory");
Object messageListener = new DirectFieldAccessor(endpointFactory).getPropertyValue("messageListener");
assertEquals("Wrong message listener", MessageListenerAdapter.class, messageListener.getClass());
MessageListenerAdapter adapter = (MessageListenerAdapter) messageListener;
DirectFieldAccessor adapterFieldAccessor = new DirectFieldAccessor(adapter);
assertEquals("Message converter not set properly", context.getBean("testMessageConverter"), adapterFieldAccessor.getPropertyValue("messageConverter"));
assertEquals("Wrong delegate", context.getBean("testBean1"), adapterFieldAccessor.getPropertyValue("delegate"));
assertEquals("Wrong method name", "setName", adapterFieldAccessor.getPropertyValue("defaultListenerMethod"));
}
use of org.springframework.jms.listener.endpoint.JmsMessageEndpointManager in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testJcaContainerFactoryConfiguration.
@Test
public void testJcaContainerFactoryConfiguration() {
Map<String, DefaultJcaListenerContainerFactory> containers = context.getBeansOfType(DefaultJcaListenerContainerFactory.class);
DefaultJcaListenerContainerFactory factory = containers.get("testJcaFactory");
assertNotNull("No factory registered with testJcaFactory id", factory);
JmsMessageEndpointManager container = factory.createListenerContainer(createDummyEndpoint());
assertEquals("explicit resource adapter not set", context.getBean("testResourceAdapter"), container.getResourceAdapter());
assertEquals("explicit message converter not set", context.getBean("testMessageConverter"), container.getActivationSpecConfig().getMessageConverter());
assertEquals("Wrong pub/sub", true, container.isPubSubDomain());
assertEquals("wrong concurrency", 5, container.getActivationSpecConfig().getMaxConcurrency());
assertEquals("Wrong prefetch", 50, container.getActivationSpecConfig().getPrefetchSize());
assertEquals("Wrong phase", 77, container.getPhase());
}
Aggregations