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


Java DefaultMessageListenerContainer.setMessageListener方法代码示例

本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.setMessageListener方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.setMessageListener方法的具体用法?Java DefaultMessageListenerContainer.setMessageListener怎么用?Java DefaultMessageListenerContainer.setMessageListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jms.listener.DefaultMessageListenerContainer的用法示例。


在下文中一共展示了DefaultMessageListenerContainer.setMessageListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpClass

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@BeforeClass
public void setUpClass() {
  JmsConnector jmsConnector = ActiveMQTestUtils.createTestJmsConnector();
  
  _factory = new JmsSenderFactory(jmsConnector);
  _mdd = MarketDataDistributorTest.getTestDistributor(_factory);
  
  _collectingReceiver = new CollectingByteArrayMessageReceiver();
  JmsByteArrayMessageDispatcher messageDispatcher = new JmsByteArrayMessageDispatcher(_collectingReceiver);
  
  _container = new DefaultMessageListenerContainer();
  _container.setConnectionFactory(jmsConnector.getConnectionFactory());
  _container.setMessageListener(messageDispatcher);
  _container.setDestinationName(_mdd.getDistributionSpec().getJmsTopic());
  _container.setPubSubDomain(true);
  _container.afterPropertiesSet();
  _container.start();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:JmsSenderTest.java

示例2: adminRequestJmsContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer adminRequestJmsContainer(ClientRequestDelegator delegator, ClientRequestErrorHandler errorHandler) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();

  String adminRequestQueue = properties.getJms().getAdminRequestQueue();
  container.setDestination(new ActiveMQQueue(adminRequestQueue));

  container.setConnectionFactory(adminSingleConnectionFactory());
  container.setMessageListener(delegator);
  container.setConcurrentConsumers(1);
  container.setMaxConcurrentConsumers(2);
  container.setMaxMessagesPerTask(1);
  container.setReceiveTimeout(1000);
  container.setIdleTaskExecutionLimit(600);
  container.setSessionTransacted(false);
  container.setTaskExecutor(clientExecutor);
  container.setErrorHandler(errorHandler);
  container.setAutoStartup(false);
  container.setPhase(ServerConstants.PHASE_INTERMEDIATE);
  return container;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:22,代码来源:AdminJmsConfig.java

示例3: responder

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer responder() {
	DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
	container.setConnectionFactory(connectionFactory());
	container.setDestinationName("test.out");
	MessageListenerAdapter adapter = new MessageListenerAdapter(new Object() {

		@SuppressWarnings("unused")
		public String handleMessage(String in) {
			return in.toUpperCase();
		}

	});
	container.setMessageListener(adapter);
	return container;
}
 
开发者ID:snicoll,项目名称:scratches,代码行数:17,代码来源:JmsRequestReply.java

示例4: taskMessageListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
@Autowired
public DefaultMessageListenerContainer taskMessageListenerContainer(JmsExternalCommandListener externalTaskListener
        , ConnectionFactory connectionFactory
        , ActiveMQQueue taskQueue) {
    DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
    listenerContainer.setMessageListener(externalTaskListener);
    listenerContainer.setDestination(taskQueue);
    listenerContainer.setConnectionFactory(connectionFactory);

    listenerContainer.setAcceptMessagesWhileStopping(false);
    listenerContainer.setSessionTransacted(true);
    listenerContainer.setConcurrentConsumers(concurrentConsumers);
    listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask);
    listenerContainer.setReceiveTimeout(receiveTimeout);
    LOG.debug("DefaultMessageListenerContainer for queue [{}] with message selector [{}] was started", listenerContainer.getDestination(), listenerContainer.getMessageSelector());
    return listenerContainer;
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:19,代码来源:JmsExternalCommandListenerConfig.java

示例5: taskMessageListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
@Autowired
public DefaultMessageListenerContainer taskMessageListenerContainer(JmsExternalTaskListener externalTaskListener
        , ConnectionFactory receiverConnectionFactory
        , ActiveMQQueue taskQueue) {
    DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
    listenerContainer.setMessageListener(externalTaskListener);
    listenerContainer.setDestination(taskQueue);
    listenerContainer.setConnectionFactory(receiverConnectionFactory);

    listenerContainer.setAcceptMessagesWhileStopping(false);
    listenerContainer.setSessionTransacted(true);
    listenerContainer.setConcurrentConsumers(concurrentConsumers);
    listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask);
    listenerContainer.setReceiveTimeout(receiveTimeout);
    return listenerContainer;
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:18,代码来源:JmsExternalTaskReceiverConfig.java

示例6: clientRequestJmsContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer clientRequestJmsContainer(ClientRequestDelegator delegator, ClientRequestErrorHandler errorHandler) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();

  String clientRequestQueue = properties.getJms().getRequestQueue();
  container.setDestination(new ActiveMQQueue(clientRequestQueue));

  container.setConnectionFactory(clientSingleConnectionFactory());
  container.setMessageListener(delegator);
  container.setConcurrentConsumers(properties.getJms().getInitialConsumers());
  container.setMaxConcurrentConsumers(properties.getJms().getMaxConsumers());
  container.setMaxMessagesPerTask(1);
  container.setReceiveTimeout(1000);
  container.setIdleTaskExecutionLimit(600);
  container.setSessionTransacted(false);
  container.setTaskExecutor(clientExecutor());
  container.setErrorHandler(errorHandler);
  container.setAutoStartup(false);
  container.setPhase(ServerConstants.PHASE_INTERMEDIATE);
  return container;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:22,代码来源:ClientJmsConfig.java

示例7: configRequestJmsContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer configRequestJmsContainer(ConfigurationRequestHandler requestHandler) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();

  String configRequestQueue = properties.getJms().getConfigRequestQueue();
  container.setDestination(new ActiveMQQueue(configRequestQueue));

  container.setConnectionFactory(clientSingleConnectionFactory);
  container.setMessageListener(requestHandler);
  container.setConcurrentConsumers(1);
  container.setMaxConcurrentConsumers(1);
  container.setSessionTransacted(false);
  container.setTaskExecutor(clientExecutor);
  container.setPhase(ServerConstants.PHASE_START_LAST);
  return container;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:17,代码来源:ConfigRequestJmsConfig.java

示例8: subscribe

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
/**
 * Returns the container so that it can be started manually when added during
 * server runtime.
 * @param process the Process to create a container for
 * @param consumersMax the max number of consumers (at start-up subscribe with less)
 * @return the JMS container that was created
 */
private DefaultMessageListenerContainer subscribe(final Process process, final int consumersMax) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setConnectionFactory(updateConnectionFactory);
  container.setDestination(new ActiveMQQueue(properties.getJms().getQueuePrefix() + ".update." + process.getName()));
  container.setMessageListener(listener);
  container.setConcurrentConsumers(properties.getJms().getUpdate().getInitialConsumers());
  container.setMaxConcurrentConsumers(consumersMax);
  container.setSessionTransacted(properties.getJms().getUpdate().isTransacted());
  container.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
  container.setAutoStartup(false);
  container.setPhase(ServerConstants.PHASE_START_LAST);
  container.setMaxMessagesPerTask(properties.getJms().getUpdate().getMaxMessagesPerTask());
  container.setReceiveTimeout(properties.getJms().getUpdate().getReceiveTimeout());
  container.setIdleTaskExecutionLimit(properties.getJms().getUpdate().getIdleTaskExecutionLimit());
  container.setBeanName(process.getName() + " update JMS container");
  container.setTaskExecutor(daqThreadPoolTaskExecutor);
  container.setAcceptMessagesWhileStopping(false);
  jmsContainers.put(process.getId(), container);
  container.initialize();
  return container;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:29,代码来源:JmsContainerManagerImpl.java

示例9: messageListener

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer messageListener() {
	DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
	container.setConnectionFactory(this.connectionFactory);
	container.setDestinationName("testQueue");
	container.setMessageListener(new MessageListener() {
		@Override
		public void onMessage(Message message) {
			try {
				System.out.println(message.getBody(Object.class));
			}
			catch (JMSException ex) {
				ex.printStackTrace();
			}
		}
	});
	return container;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:SampleHornetQApplication.java

示例10: hornetQMessageListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的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

示例11: init

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  
  final AnalyticServiceServer server = new AnalyticServiceServer(getViewProcessor(), getPositionMaster(), getPortfolioMaster(), getConfigSource());
  server.setUser(getUser());
  server.setViewName(getViewName());
  server.setProviderIdName(getProviderIdName());
  
  AnalyticServiceTradeProducer tradeProducer = new AnalyticServiceTradeProducer();
  
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setMessageListener(
      new JmsByteArrayMessageDispatcher(
          new ByteArrayFudgeMessageReceiver(tradeProducer)));
  container.setDestinationName(getListenTopicName());
  container.setPubSubDomain(false);
  container.setConnectionFactory(getListenJmsConnector().getConnectionFactory());
  
  JmsAnalyticsDistributor analyticsDistributor = new JmsAnalyticsDistributor(new DefaultJmsTopicNameResolver(getPositionSource()), OpenGammaFudgeContext.getInstance(), _listenJmsConnector);
  server.setAnalyticResultReceiver(analyticsDistributor);
  
  server.setTradeProducer(tradeProducer);
  repo.registerLifecycle(server);
  repo.registerLifecycle(container);
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:AnalyticServiceServerFactory.java

示例12: startListener

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
public void startListener() {
    MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter();
    messageListenerAdapter.setDelegate(this);
    messageListenerAdapter.setMessageConverter(mqMessageConverter);

    DefaultMessageListenerContainer mqListener = new DefaultMessageListenerContainer();
    mqListener.setConnectionFactory(mqConnectionFactory.getFactory());
    mqListener.setDestinationName(appConfig.getMqQueueName());
    mqListener.setMessageListener(messageListenerAdapter);
    mqListener.setConcurrency("4-8");
    mqListener.setSessionTransacted(true);

    mqListener.initialize();
    mqListener.start();
}
 
开发者ID:phpdragon,项目名称:JavaSamples,代码行数:16,代码来源:MqConsumer.java

示例13: registerMessageListener

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
public void registerMessageListener(MessageListener listener,
                                    String destinationName)
{
  log.info("registerMessageListener(" + destinationName + ", " + listener + ")");
  container = new DefaultMessageListenerContainer();
  container.setConnectionFactory(connectionFactory);
  container.setDestinationName(destinationName);
  container.setMessageListener(listener);
  container.setTaskExecutor(taskExecutor);
  container.afterPropertiesSet();
  container.start();
  
  listenerContainerMap.put(listener, container);
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:15,代码来源:JmsManagementService.java

示例14: messageListener

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer messageListener() {
	DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
	container.setConnectionFactory(this.connectionFactory);
	container.setDestinationName(queue);
	container.setMessageListener(new Consumer());
	return container;
}
 
开发者ID:Apress,项目名称:pro-spring-boot,代码行数:9,代码来源:MessagingConfig.java

示例15: mockServerListener

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的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


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