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


Java DefaultMessageListenerContainer类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: init

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
/**
 * init - configuration / defaults
 */
public void init() {
  dataDir = new File(config.getDataDir());
  checkFreeSpace();
  logger.info(this);

  Runtime.getRuntime().addShutdownHook(new Thread(() -> {
    DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) applicationContext
        .getBean("listenerContainer");
    logger.info("Stopping listener container...");
    listenerContainer.stop();
    while (activeThreads.get() > 0) {
      logger.info("Shutdown in progress. sleeping for 10sec. activeThreads: " + activeThreads);
      try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        logger.info("Got InterruptedException, but will still let the activeThreads complete.");
      }
    }
    logger.info("Shutdown done.");
  }));

  File testDir = new File(dataDir, "../test");
  logger.info("Verification test directory created: " + testDir.mkdirs());
}
 
开发者ID:oneops,项目名称:oneops,代码行数:28,代码来源:Listener.java

示例6: testContainerConfiguration

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void testContainerConfiguration() throws Exception {
	Map<String, DefaultMessageListenerContainer> containers = context.getBeansOfType(DefaultMessageListenerContainer.class);
	ConnectionFactory defaultConnectionFactory = context.getBean(DEFAULT_CONNECTION_FACTORY, ConnectionFactory.class);
	ConnectionFactory explicitConnectionFactory = context.getBean(EXPLICIT_CONNECTION_FACTORY, ConnectionFactory.class);

	int defaultConnectionFactoryCount = 0;
	int explicitConnectionFactoryCount = 0;

	for (DefaultMessageListenerContainer container : containers.values()) {
		if (container.getConnectionFactory().equals(defaultConnectionFactory)) {
			defaultConnectionFactoryCount++;
		}
		else if (container.getConnectionFactory().equals(explicitConnectionFactory)) {
			explicitConnectionFactoryCount++;
		}
	}

	assertEquals("1 container should have the default connectionFactory", 1, defaultConnectionFactoryCount);
	assertEquals("2 containers should have the explicit connectionFactory", 2, explicitConnectionFactoryCount);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JmsNamespaceHandlerTests.java

示例7: testJmsContainerFactoryConfiguration

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void testJmsContainerFactoryConfiguration() {
	Map<String, DefaultJmsListenerContainerFactory> containers =
			context.getBeansOfType(DefaultJmsListenerContainerFactory.class);
	DefaultJmsListenerContainerFactory factory = containers.get("testJmsFactory");
	assertNotNull("No factory registered with testJmsFactory id", factory);

	DefaultMessageListenerContainer container =
			factory.createListenerContainer(createDummyEndpoint());
	assertEquals("explicit connection factory not set",
			context.getBean(EXPLICIT_CONNECTION_FACTORY), container.getConnectionFactory());
	assertEquals("explicit destination resolver not set",
			context.getBean("testDestinationResolver"), container.getDestinationResolver());
	assertEquals("explicit message converter not set",
			context.getBean("testMessageConverter"), container.getMessageConverter());
	assertEquals("Wrong pub/sub", true, container.isPubSubDomain());
	assertEquals("Wrong durable flag", true, container.isSubscriptionDurable());
	assertEquals("wrong cache", DefaultMessageListenerContainer.CACHE_CONNECTION, container.getCacheLevel());
	assertEquals("wrong concurrency", 3, container.getConcurrentConsumers());
	assertEquals("wrong concurrency", 5, container.getMaxConcurrentConsumers());
	assertEquals("wrong prefetch", 50, container.getMaxMessagesPerTask());
	assertEquals("Wrong phase", 99, container.getPhase());
	assertSame(context.getBean("testBackOff"), new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:JmsNamespaceHandlerTests.java

示例8: testResponseDestination

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void testResponseDestination() {
	// JMS
	DefaultMessageListenerContainer listener1 = this.context
			.getBean("listener1", DefaultMessageListenerContainer.class);
	DefaultMessageListenerContainer listener2 = this.context
			.getBean("listener2", DefaultMessageListenerContainer.class);
	assertEquals("Wrong destination type on listener1", true, listener1.isPubSubDomain());
	assertEquals("Wrong destination type on listener2", true, listener2.isPubSubDomain());
	assertEquals("Wrong response destination type on listener1", false, listener1.isReplyPubSubDomain());
	assertEquals("Wrong response destination type on listener2", false, listener2.isReplyPubSubDomain());

	// JCA
	JmsMessageEndpointManager listener3 = this.context
			.getBean("listener3", JmsMessageEndpointManager.class);
	JmsMessageEndpointManager listener4 = this.context
			.getBean("listener4", JmsMessageEndpointManager.class);
	assertEquals("Wrong destination type on listener3", true, listener3.isPubSubDomain());
	assertEquals("Wrong destination type on listener4", true, listener4.isPubSubDomain());
	assertEquals("Wrong response destination type on listener3", false, listener3.isReplyPubSubDomain());
	assertEquals("Wrong response destination type on listener4", false, listener4.isReplyPubSubDomain());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:JmsNamespaceHandlerTests.java

示例9: testComponentRegistration

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void testComponentRegistration() {
	assertTrue("Parser should have registered a component named 'listener1'",
			context.containsComponentDefinition("listener1"));
	assertTrue("Parser should have registered a component named 'listener2'",
			context.containsComponentDefinition("listener2"));
	assertTrue("Parser should have registered a component named 'listener3'",
			context.containsComponentDefinition("listener3"));
	assertTrue("Parser should have registered a component named '"
			+ DefaultMessageListenerContainer.class.getName() + "#0'",
			context.containsComponentDefinition(DefaultMessageListenerContainer.class.getName() + "#0"));
	assertTrue("Parser should have registered a component named '"
			+ JmsMessageEndpointManager.class.getName() + "#0'",
			context.containsComponentDefinition(JmsMessageEndpointManager.class.getName() + "#0"));
	assertTrue("Parser should have registered a component named 'testJmsFactory",
			context.containsComponentDefinition("testJmsFactory"));
	assertTrue("Parser should have registered a component named 'testJcaFactory",
			context.containsComponentDefinition("testJcaFactory"));
	assertTrue("Parser should have registered a component named 'testJcaFactory",
			context.containsComponentDefinition("onlyJmsFactory"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JmsNamespaceHandlerTests.java

示例10: setupJmsMessageContainerFullConfig

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void setupJmsMessageContainerFullConfig() {
	DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
	MessageListener messageListener = new MessageListenerAdapter();
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setDestination("myQueue");
	endpoint.setSelector("foo = 'bar'");
	endpoint.setSubscription("mySubscription");
	endpoint.setConcurrency("5-10");
	endpoint.setMessageListener(messageListener);

	endpoint.setupListenerContainer(container);
	assertEquals("myQueue", container.getDestinationName());
	assertEquals("foo = 'bar'", container.getMessageSelector());
	assertEquals("mySubscription", container.getSubscriptionName());
	assertEquals(5, container.getConcurrentConsumers());
	assertEquals(10, container.getMaxConcurrentConsumers());
	assertEquals(messageListener, container.getMessageListener());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:JmsListenerEndpointTests.java

示例11: createJmsContainerFullConfig

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
@Test
public void createJmsContainerFullConfig() {
	DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
	setDefaultJmsConfig(factory);
	factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
	factory.setConcurrency("3-10");
	factory.setMaxMessagesPerTask(5);

	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	MessageListener messageListener = new MessageListenerAdapter();
	endpoint.setMessageListener(messageListener);
	endpoint.setDestination("myQueue");
	DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);

	assertDefaultJmsConfig(container);
	assertEquals(DefaultMessageListenerContainer.CACHE_CONSUMER, container.getCacheLevel());
	assertEquals(3, container.getConcurrentConsumers());
	assertEquals(10, container.getMaxConcurrentConsumers());
	assertEquals(5, container.getMaxMessagesPerTask());

	assertEquals(messageListener, container.getMessageListener());
	assertEquals("myQueue", container.getDestinationName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JmsListenerContainerFactoryTests.java

示例12: 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

示例13: 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

示例14: 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

示例15: stop

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入依赖的package包/类
/**
   * Permanent shutdown.
   */
  @Override
  public synchronized void stop() {
    try {
      LOGGER.info("Stopping JMS update containers listening for tag updates from the DAQ layer.");
      subscriptionChecker.cancel();
      ThreadPoolExecutor shutdownExecutor = new ThreadPoolExecutor(10, 10, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), r -> {
        String threadName = "StopDaqUpdate";
        return new Thread(r, threadName);
      });
      Collection<ContainerShutdownTask> containerTasks = new ArrayList<ContainerShutdownTask>();
      for (Map.Entry<Long, DefaultMessageListenerContainer> entry : jmsContainers.entrySet()) {
        ContainerShutdownTask containerShutdownTask = new ContainerShutdownTask(entry.getValue());
        containerTasks.add(containerShutdownTask);
      }
      shutdownExecutor.invokeAll(containerTasks, 60, TimeUnit.SECONDS);
      shutdownExecutor.shutdown();
      jmsContainers.clear();
      daqThreadPoolTaskExecutor.shutdown();
//      LOGGER.info("Stopping JMS connections to DAQs");
//      updateConnectionFactory.stop(); //closes all JMS connections in the pool
    } catch (Exception e) {
      LOGGER.error("Exception caught while closing down the Spring listener/JMS thread pool", e);
    }
  }
 
开发者ID:c2mon,项目名称:c2mon,代码行数:28,代码来源:JmsContainerManagerImpl.java


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