当前位置: 首页>>代码示例>>Java>>正文


Java SimpleMessageListenerContainer类代码示例

本文整理汇总了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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:JmsListenerContainerFactoryTests.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JmsConfiguration.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AbstractJmsAnnotationDrivenTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:MethodJmsListenerEndpointTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:MethodJmsListenerEndpointTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:MethodJmsListenerEndpointTests.java

示例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"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JmsListenerEndpointTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:MethodJmsListenerEndpointTests.java

示例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));
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:jms,代码行数:16,代码来源:JmsSourceTests.java

示例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;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:JmsFileClientConfig.java

示例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;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:JmsBridgeOutputConfig.java

示例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;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:JmsServerConfig.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:JmsEndpoint.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:JmsEndpointConfigurationTest.java


注:本文中的org.springframework.jms.listener.SimpleMessageListenerContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。