本文整理汇总了Java中org.springframework.jms.listener.MessageListenerContainer类的典型用法代码示例。如果您正苦于以下问题:Java MessageListenerContainer类的具体用法?Java MessageListenerContainer怎么用?Java MessageListenerContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageListenerContainer类属于org.springframework.jms.listener包,在下文中一共展示了MessageListenerContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerListenerContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* Create a message listener container for the given {@link JmsListenerEndpoint}.
* <p>This create the necessary infrastructure to honor that endpoint
* with regards to its configuration.
* <p>The {@code startImmediately} flag determines if the container should be
* started immediately.
* @param endpoint the endpoint to add
* @param factory the listener factory to use
* @param startImmediately start the container immediately if necessary
* @see #getListenerContainers()
* @see #getListenerContainer(String)
*/
public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory,
boolean startImmediately) {
Assert.notNull(endpoint, "Endpoint must not be null");
Assert.notNull(factory, "Factory must not be null");
String id = endpoint.getId();
Assert.notNull(id, "Endpoint id must not be null");
synchronized (this.listenerContainers) {
Assert.state(!this.listenerContainers.containsKey(id),
"Another endpoint is already registered with id '" + id + "'");
MessageListenerContainer container = createListenerContainer(endpoint, factory);
this.listenerContainers.put(id, container);
if (startImmediately) {
startIfNecessary(container);
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:JmsListenerEndpointRegistry.java
示例2: createListenerContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* Create and start a new container using the specified factory.
*/
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
JmsListenerContainerFactory<?> factory) {
MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);
if (listenerContainer instanceof InitializingBean) {
try {
((InitializingBean) listenerContainer).afterPropertiesSet();
}
catch (Exception ex) {
throw new BeanInitializationException("Failed to initialize message listener container", ex);
}
}
int containerPhase = listenerContainer.getPhase();
if (containerPhase < Integer.MAX_VALUE) { // a custom phase value
if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
throw new IllegalStateException("Encountered phase mismatch between container factory definitions: " +
this.phase + " vs " + containerPhase);
}
this.phase = listenerContainer.getPhase();
}
return listenerContainer;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:JmsListenerEndpointRegistry.java
示例3: setupMessageContainerUnsupportedContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Test
public void setupMessageContainerUnsupportedContainer() {
MessageListenerContainer container = mock(MessageListenerContainer.class);
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setMessageListener(new MessageListenerAdapter());
thrown.expect(IllegalArgumentException.class);
endpoint.setupListenerContainer(container);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:JmsListenerEndpointTests.java
示例4: hornetQMessageListenerContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Bean
public MessageListenerContainer hornetQMessageListenerContainer() {
Map<String, Object> map = new HashMap<String, Object>();
map.put(TransportConstants.HOST_PROP_NAME, hornetq_host);
map.put(TransportConstants.PORT_PROP_NAME, hornetq_port);
TransportConfiguration transportConfiguration =new TransportConfiguration(
NettyConnectorFactory.class.getName(), map);
HornetQConnectionFactory hornetQConnectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(
JMSFactoryType.CF, transportConfiguration);
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory((ConnectionFactory) hornetQConnectionFactory);
container.setDestination(HornetQJMSClient.createTopic(IMConstant.GATEWAY_USERREGISTER_TOPIC));
container.setPubSubDomain(true);
container.setPubSubNoLocal(true);
container.setMessageListener(userRegisterListener);
container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
return container;
}
开发者ID:projectsrepos,项目名称:jim,代码行数:21,代码来源:GatewayUserRegisterConfig.java
示例5: setupListenerContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Override
public void setupListenerContainer(MessageListenerContainer listenerContainer) {
if (listenerContainer instanceof AbstractMessageListenerContainer) {
setupJmsListenerContainer((AbstractMessageListenerContainer) listenerContainer);
}
else {
new JcaEndpointConfigurer().configureEndpoint(listenerContainer);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AbstractJmsListenerEndpoint.java
示例6: destroy
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Override
public void destroy() {
for (MessageListenerContainer listenerContainer : getListenerContainers()) {
if (listenerContainer instanceof DisposableBean) {
try {
((DisposableBean) listenerContainer).destroy();
}
catch (Throwable ex) {
logger.warn("Failed to destroy message listener container", ex);
}
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:JmsListenerEndpointRegistry.java
示例7: stop
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Override
public void stop(Runnable callback) {
Collection<MessageListenerContainer> listenerContainers = getListenerContainers();
AggregatingCallback aggregatingCallback = new AggregatingCallback(listenerContainers.size(), callback);
for (MessageListenerContainer listenerContainer : listenerContainers) {
listenerContainer.stop(aggregatingCallback);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:JmsListenerEndpointRegistry.java
示例8: isRunning
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Override
public boolean isRunning() {
for (MessageListenerContainer listenerContainer : getListenerContainers()) {
if (listenerContainer.isRunning()) {
return true;
}
}
return false;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:JmsListenerEndpointRegistry.java
示例9: createMessageListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Override
protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) {
Assert.state(this.messageHandlerMethodFactory != null,
"Could not create message listener - MessageHandlerMethodFactory not set");
MessagingMessageListenerAdapter messageListener = createMessageListenerInstance();
InvocableHandlerMethod invocableHandlerMethod =
this.messageHandlerMethodFactory.createInvocableHandlerMethod(getBean(), getMethod());
messageListener.setHandlerMethod(invocableHandlerMethod);
String responseDestination = getDefaultResponseDestination();
if (StringUtils.hasText(responseDestination)) {
if (container.isReplyPubSubDomain()) {
messageListener.setDefaultResponseTopicName(responseDestination);
}
else {
messageListener.setDefaultResponseQueueName(responseDestination);
}
}
MessageConverter messageConverter = container.getMessageConverter();
if (messageConverter != null) {
messageListener.setMessageConverter(messageConverter);
}
DestinationResolver destinationResolver = container.getDestinationResolver();
if (destinationResolver != null) {
messageListener.setDestinationResolver(destinationResolver);
}
return messageListener;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:MethodJmsListenerEndpoint.java
示例10: createInstance
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
private MessagingMessageListenerAdapter createInstance(
DefaultMessageHandlerMethodFactory factory, Method method, MessageListenerContainer container) {
MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
endpoint.setBean(sample);
endpoint.setMethod(method);
endpoint.setMessageHandlerMethodFactory(factory);
return endpoint.createMessageListener(container);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:MethodJmsListenerEndpointTests.java
示例11: mockServerListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Bean
public MessageListenerContainer mockServerListener(ActiveMQConnectionFactory connectionFactory) {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestination(new ActiveMQQueue("c2mon.client.request"));
container.setMessageListener((SessionAwareMessageListener) (message, session) -> {
session.createProducer(message.getJMSReplyTo()).send(session.createTextMessage("[]"));
});
return container;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:11,代码来源:MockServerConfig.java
示例12: mqMessageReceiver
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* 配置基于发布订阅模式的消息监听容器,用于接收MQ转发过来的消息
*
* @return
*/
@Bean
public MessageListenerContainer mqMessageReceiver(ImBrokerMessageListener imBrokerMessageListener) {
MessageListenerContainer container = mqMessageReceiver(IMConstant.MQ_FORWARD_TOPIC_NAME, imBrokerMessageListener);
logger.info("Message listener based on pub-sub mode was created!");
return container;
}
开发者ID:projectsrepos,项目名称:jim,代码行数:12,代码来源:BrokerRpcConfig.java
示例13: buildListenerContainer
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* 构建基于队列模式的消息监听容器
*
* @param queueName 队列名字
* @param rpcServiceExport 服务暴露接口
* @return
*/
protected MessageListenerContainer buildListenerContainer(JmsInvokerServiceExporter rpcServiceExport,
String queueName) {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(jmsConnectionFactory());
container.setDestinationName(queueName);
container.setMessageConverter(messageConverter());
container.setMessageListener(rpcServiceExport);
container.setConcurrentConsumers(Runtime.getRuntime().availableProcessors());
return container;
}
开发者ID:projectsrepos,项目名称:jim,代码行数:18,代码来源:GenericMQConfig.java
示例14: mqMessageReceiver
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* 配置基于发布订阅模式的消息监听容器,用于接收MQ转发过来的消息
*
* @param topicName
* @param messageListener
* @return
*/
public MessageListenerContainer mqMessageReceiver(String topicName, MessageListener messageListener) {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(jmsConnectionFactory());
container.setDestinationName(topicName);
container.setPubSubDomain(true);
container.setPubSubNoLocal(true);
container.setMessageListener(messageListener);
container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
return container;
}
开发者ID:projectsrepos,项目名称:jim,代码行数:18,代码来源:GenericMQConfig.java
示例15: controlSearchIndexUpdateJmsMessageListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* Periodically check the configuration and apply the action to the storage policy processor JMS message listener service, if needed.
*/
@Scheduled(fixedDelay = 60000)
public void controlSearchIndexUpdateJmsMessageListener()
{
try
{
// Get the configuration setting.
Boolean jmsMessageListenerEnabled = Boolean.valueOf(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED));
// Get the registry bean.
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
// Get the search index update JMS message listener container.
MessageListenerContainer jmsMessageListenerContainer =
registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE);
// Get the current JMS message listener status and the configuration value.
LOGGER.debug("controlSearchIndexUpdateJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}",
ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED.getKey(), jmsMessageListenerEnabled, jmsMessageListenerContainer.isRunning());
// Apply the relative action if needed.
if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning())
{
LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Stopping the search index update JMS message listener ...");
jmsMessageListenerContainer.stop();
LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Done");
}
else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning())
{
LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Starting the search index update JMS message listener ...");
jmsMessageListenerContainer.start();
LOGGER.info("controlSearchIndexUpdateJmsMessageListener(): Done");
}
}
catch (Exception e)
{
LOGGER.error("controlSearchIndexUpdateJmsMessageListener(): Failed to control the search index update Jms message listener service.", e);
}
}
开发者ID:FINRAOS,项目名称:herd,代码行数:43,代码来源:SearchIndexUpdateJmsMessageListener.java
示例16: controlHerdJmsMessageListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
/**
* Periodically check the configuration and apply the action to the herd JMS message listener service, if needed.
*/
@Scheduled(fixedDelay = 60000)
public void controlHerdJmsMessageListener()
{
try
{
// Get the configuration setting.
Boolean jmsMessageListenerEnabled = Boolean.valueOf(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED));
// Get the registry bean.
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
// Get the herd JMS message listener container.
MessageListenerContainer jmsMessageListenerContainer = registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING);
// Get the current JMS message listener status and the configuration value.
LOGGER.debug("controlHerdJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}", ConfigurationValue.JMS_LISTENER_ENABLED.getKey(),
jmsMessageListenerEnabled, jmsMessageListenerContainer.isRunning());
// Apply the relative action if needed.
if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning())
{
LOGGER.info("controlHerdJmsMessageListener(): Stopping the herd JMS message listener ...");
jmsMessageListenerContainer.stop();
LOGGER.info("controlHerdJmsMessageListener(): Done");
}
else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning())
{
LOGGER.info("controlHerdJmsMessageListener(): Starting the herd JMS message listener ...");
jmsMessageListenerContainer.start();
LOGGER.info("controlHerdJmsMessageListener(): Done");
}
}
catch (Exception e)
{
LOGGER.error("controlHerdJmsMessageListener(): Failed to control the herd Jms message listener service.", e);
}
}
开发者ID:FINRAOS,项目名称:herd,代码行数:42,代码来源:HerdJmsMessageListener.java
示例17: testControlListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Test
public void testControlListener()
{
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(sampleDataJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
//The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE)).thenReturn(mockMessageListenerContainer);
//the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer).stop();
//The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("true");
//the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
开发者ID:FINRAOS,项目名称:herd,代码行数:35,代码来源:SampleDataJmsMessageListenerTest.java
示例18: testControlListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Test
public void testControlListener()
{
ReflectionTestUtils.setField(searchIndexUpdateJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
// The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE)).thenReturn(mockMessageListenerContainer);
// The listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
searchIndexUpdateJmsMessageListener.controlSearchIndexUpdateJmsMessageListener();
verify(mockMessageListenerContainer, times(0)).stop();
verify(mockMessageListenerContainer, times(0)).start();
// The listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
searchIndexUpdateJmsMessageListener.controlSearchIndexUpdateJmsMessageListener();
verify(mockMessageListenerContainer, times(1)).stop();
// The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.SEARCH_INDEX_UPDATE_JMS_LISTENER_ENABLED)).thenReturn("true");
// The listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
searchIndexUpdateJmsMessageListener.controlSearchIndexUpdateJmsMessageListener();
verify(mockMessageListenerContainer, times(0)).start();
// The listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
searchIndexUpdateJmsMessageListener.controlSearchIndexUpdateJmsMessageListener();
verify(mockMessageListenerContainer, times(1)).start();
}
开发者ID:FINRAOS,项目名称:herd,代码行数:37,代码来源:SearchIndexUpdateJmsMessageListenerTest.java
示例19: testControlListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Test
public void testControlListener()
{
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(herdJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
//The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING)).thenReturn(mockMessageListenerContainer);
//the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer).stop();
//The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED)).thenReturn("true");
//the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
开发者ID:FINRAOS,项目名称:herd,代码行数:35,代码来源:HerdJmsMessageListenerTest.java
示例20: testControlListener
import org.springframework.jms.listener.MessageListenerContainer; //导入依赖的package包/类
@Test
public void testControlListener()
{
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(storagePolicyProcessorJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
//The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_PROCESSOR_JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
.getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE))
.thenReturn(mockMessageListenerContainer);
//the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer).stop();
//The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_PROCESSOR_JMS_LISTENER_ENABLED)).thenReturn("true");
//the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
开发者ID:FINRAOS,项目名称:herd,代码行数:36,代码来源:StoragePolicyProcessorJmsMessageListenerTest.java
注:本文中的org.springframework.jms.listener.MessageListenerContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论