本文整理汇总了Java中org.springframework.jms.listener.SimpleMessageListenerContainer类的典型用法代码示例。如果您正苦于以下问题:Java SimpleMessageListenerContainer类的具体用法?Java SimpleMessageListenerContainer怎么用?Java SimpleMessageListenerContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleMessageListenerContainer类属于org.springframework.jms.listener包,在下文中一共展示了SimpleMessageListenerContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleMessageListener
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void simpleMessageListener() throws Exception {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
Config.class, SimpleMessageListenerTestBean.class);
JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
assertEquals("One container should have been registered", 1, factory.getListenerContainers().size());
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
JmsListenerEndpoint endpoint = container.getEndpoint();
assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass());
MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass());
assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod());
assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod());
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
methodEndpoint.setupListenerContainer(listenerContainer);
assertNotNull(listenerContainer.getMessageListener());
assertTrue("Should have been started " + container, container.isStarted());
context.close(); // Close and stop the listeners
assertTrue("Should have been stopped " + container, container.isStopped());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:JmsListenerAnnotationBeanPostProcessorTests.java
示例2: createSimpleContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void createSimpleContainer() {
SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
setDefaultJmsConfig(factory);
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);
endpoint.setDestination("myQueue");
SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint);
assertDefaultJmsConfig(container);
assertEquals(messageListener, container.getMessageListener());
assertEquals("myQueue", container.getDestinationName());
}
示例3: configureSimpleMessageListenerContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
private void configureSimpleMessageListenerContainer(SimpleMessageListenerContainer listenerContainer) {
if (maxConcurrentConsumers > 0) {
if (maxConcurrentConsumers < concurrentConsumers) {
throw new IllegalArgumentException("Property maxConcurrentConsumers: " + maxConcurrentConsumers + " must be higher than concurrentConsumers: "
+ concurrentConsumers);
}
listenerContainer.setConcurrency(concurrentConsumers + "-" + maxConcurrentConsumers);
} else if (concurrentConsumers >= 0) {
listenerContainer.setConcurrentConsumers(concurrentConsumers);
}
listenerContainer.setPubSubNoLocal(pubSubNoLocal);
if (taskExecutor != null) {
listenerContainer.setTaskExecutor(taskExecutor);
}
}
示例4: testJmsHandlerMethodFactoryConfiguration
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
/**
* Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
* in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
*
* The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException}
*/
public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
JmsListenerContainerTestFactory simpleFactory =
context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
assertEquals(1, simpleFactory.getListenerContainers().size());
MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint)
simpleFactory.getListenerContainers().get(0).getEndpoint();
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
endpoint.setupListenerContainer(container);
MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener();
listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class));
}
示例5: processFromTopicAndReplyWithSendToQueue
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void processFromTopicAndReplyWithSendToQueue() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setPubSubDomain(true);
container.setReplyPubSubDomain(false);
MessagingMessageListenerAdapter listener = createInstance(this.factory,
getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, false);
assertListenerMethodInvocation(sample, methodName);
}
示例6: processAndReplyWithSendToTopic
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void processAndReplyWithSendToTopic() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setPubSubDomain(true);
MessagingMessageListenerAdapter listener = createInstance(this.factory,
getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, true);
assertListenerMethodInvocation(sample, methodName);
}
示例7: processFromQueueAndReplyWithSendToTopic
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void processFromQueueAndReplyWithSendToTopic() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setReplyPubSubDomain(true);
MessagingMessageListenerAdapter listener = createInstance(this.factory,
getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, true);
assertListenerMethodInvocation(sample, methodName);
}
示例8: setupConcurrencySimpleContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void setupConcurrencySimpleContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setConcurrency("5-10"); // simple implementation only support max value
endpoint.setMessageListener(messageListener);
endpoint.setupListenerContainer(container);
assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
}
示例9: processAndReplyWithSendToQueue
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void processAndReplyWithSendToQueue() throws JMSException {
String methodName = "processAndReplyWithSendTo";
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
MessagingMessageListenerAdapter listener = createInstance(this.factory,
getListenerMethod(methodName, String.class), container);
processAndReplyWithSendTo(listener, false);
assertListenerMethodInvocation(sample, methodName);
}
示例10: test
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void test() throws Exception {
AbstractMessageListenerContainer container = TestUtils.getPropertyValue(this.endpoint, "listenerContainer",
AbstractMessageListenerContainer.class);
assertThat(container, instanceOf(SimpleMessageListenerContainer.class));
assertEquals(Session.DUPS_OK_ACKNOWLEDGE, TestUtils.getPropertyValue(container, "sessionAcknowledgeMode"));
assertFalse(TestUtils.getPropertyValue(container, "sessionTransacted", Boolean.class));
assertEquals("client", TestUtils.getPropertyValue(container, "clientId"));
assertEquals("topic", TestUtils.getPropertyValue(container, "destination"));
assertEquals("JMSCorrelationId=foo", TestUtils.getPropertyValue(container, "messageSelector"));
assertFalse(TestUtils.getPropertyValue(container, "subscriptionDurable", Boolean.class));
assertFalse(TestUtils.getPropertyValue(container, "subscriptionShared", Boolean.class));
assertEquals(3, TestUtils.getPropertyValue(container, "concurrentConsumers"));
assertTrue(TestUtils.getPropertyValue(container, "pubSubDomain", Boolean.class));
}
示例11: messageListenerContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer messageListenerContainer(
ConnectionFactory connectionFactory,
MessageListener messageListener
) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestinationName(resultDestination);
container.setMessageListener(messageListener);
return container;
}
示例12: outMessageListenerContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer outMessageListenerContainer(
ConnectionFactory outConnectionFactory,
MessageListener outMessageListener
) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(outConnectionFactory);
container.setDestinationName(resultDestination);
container.setMessageListener(outMessageListener);
return container;
}
示例13: fileServerMessageListenerContainer
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer fileServerMessageListenerContainer(
ConnectionFactory serverConnectionFactory,
MessageListener fileServerMessageListener
) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(serverConnectionFactory);
container.setDestinationName(fileDestination);
container.setMessageListener(fileServerMessageListener);
return container;
}
示例14: setContainerTaskExecutor
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
private void setContainerTaskExecutor(AbstractMessageListenerContainer listenerContainer, Executor executor) {
if (listenerContainer instanceof SimpleMessageListenerContainer) {
((SimpleMessageListenerContainer) listenerContainer).setTaskExecutor(executor);
} else if (listenerContainer instanceof DefaultMessageListenerContainer) {
((DefaultMessageListenerContainer) listenerContainer).setTaskExecutor(executor);
}
}
示例15: testCreateSimpleMessageListener
import org.springframework.jms.listener.SimpleMessageListenerContainer; //导入依赖的package包/类
@Test
public void testCreateSimpleMessageListener() throws Exception {
JmsEndpoint endpoint = resolveMandatoryEndpoint("jms:Foo.Bar?consumerType=Simple", JmsEndpoint.class);
JmsConsumer consumer = endpoint.createConsumer(dummyProcessor);
AbstractMessageListenerContainer container = consumer.getListenerContainer();
assertTrue("Should have been a SimpleMessageListenerContainer", container instanceof SimpleMessageListenerContainer);
}