本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.initialize方法的具体用法?Java DefaultMessageListenerContainer.initialize怎么用?Java DefaultMessageListenerContainer.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jms.listener.DefaultMessageListenerContainer
的用法示例。
在下文中一共展示了DefaultMessageListenerContainer.initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: testSpringReceiverXa
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Test
public void testSpringReceiverXa() throws Exception {
ConnectionFactory cf = createCF(BROKER_URL);
DefaultJmsListenerContainerFactory jlcf = new DefaultJmsListenerContainerFactory();
jlcf.setTransactionManager(ptm);
jlcf.setSessionTransacted(true);
jlcf.setConnectionFactory(cf);
AtomicReference<Message> holder = new AtomicReference<>();
SimpleJmsListenerEndpoint jle = new SimpleJmsListenerEndpoint();
jle.setDestination(QUEUE);
jle.setMessageListener(message -> {
synchronized (holder) {
holder.set(message);
holder.notifyAll();
}
});
DefaultMessageListenerContainer mlc = jlcf.createListenerContainer(jle);
mlc.initialize();
mlc.start();
JmsTemplate jms = new JmsTemplate(cf);
jms.setDefaultDestinationName(QUEUE);
synchronized (holder) {
jms.convertAndSend("Hello");
holder.wait();
}
assertNotNull(holder.get());
}
示例3: 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();
}