本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.start方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.start方法的具体用法?Java DefaultMessageListenerContainer.start怎么用?Java DefaultMessageListenerContainer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jms.listener.DefaultMessageListenerContainer
的用法示例。
在下文中一共展示了DefaultMessageListenerContainer.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: start
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
private void start(String beanName){
if(StringUtils.isEmpty(beanName)){
return;
}
DefaultMessageListenerContainer c = this.applicationContext.
getBean(beanName,DefaultMessageListenerContainer.class);
if(c != null)c.start();
}
示例3: afterPropertiesSet
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@PostConstruct
public void afterPropertiesSet() throws Exception {
if (!enabled) {
return;
}
this.buildComposite();
for (DefaultMessageListenerContainer defaultMessageListenerContainer : defaultMessageListenerContainers) {
defaultMessageListenerContainer.afterPropertiesSet();
defaultMessageListenerContainer.start();
}
}
示例4: 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());
}
示例5: 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();
}
示例6: 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);
}
示例7: subscribe
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public void subscribe(final Process process) {
LOGGER.trace("Subscribing to updates from Process " + process.getId());
if (!jmsContainers.containsKey(process.getId())) {
DefaultMessageListenerContainer container = subscribe(process, properties.getJms().getUpdate().getMaxConsumers());
container.start();
} else {
LOGGER.warn("Attempt at creating a JMS listener container for a Process that already has one.");
}
}
示例8: topicConduit
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Test(invocationCount = 5, successPercentage = 19)
public void topicConduit() throws Exception {
String topicName = "JmsByteArrayTransportTest-topicConduit-" + System.getProperty("user.name") + "-" + System.currentTimeMillis();
ConnectionFactory cf = ActiveMQTestUtils.createTestConnectionFactory();
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(cf);
jmsTemplate.setPubSubDomain(true);
JmsByteArrayMessageSender messageSender = new JmsByteArrayMessageSender(topicName, jmsTemplate);
CollectingByteArrayMessageReceiver collectingReceiver = new CollectingByteArrayMessageReceiver();
JmsByteArrayMessageDispatcher messageDispatcher = new JmsByteArrayMessageDispatcher(collectingReceiver);
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(cf);
container.setMessageListener(messageDispatcher);
container.setDestinationName(topicName);
container.setPubSubDomain(true);
container.afterPropertiesSet();
container.start();
Random random = new Random();
byte[] randomBytes = new byte[1024];
random.nextBytes(randomBytes);
while(!container.isRunning()) {
Thread.sleep(10l);
}
//TODO: this is a hack. The context doesn't seem to have always set up the consumer completely yet
Thread.sleep(500l);
messageSender.send(randomBytes);
long startTime = System.currentTimeMillis();
while(collectingReceiver.getMessages().isEmpty()) {
Thread.sleep(10l);
if ((System.currentTimeMillis() - startTime) > TIMEOUT) {
fail("Did not receive a message in " + (TIMEOUT / 1000) + " seconds.");
}
}
s_logger.debug ("topicConduit message received {}ms before timeout limit", TIMEOUT - (System.currentTimeMillis () - startTime));
assertEquals(1, collectingReceiver.getMessages().size());
byte[] receivedBytes = collectingReceiver.getMessages().get(0);
assertEquals(randomBytes.length, receivedBytes.length);
for(int i = 0; i < randomBytes.length; i++) {
assertEquals(randomBytes[i], receivedBytes[i]);
}
container.stop();
container.destroy();
}
示例9: requestConduit
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Test(invocationCount = 5, successPercentage = 19)
public void requestConduit() throws Exception {
String topicName = "JmsByteArrayTransportTest-requestConduit-" + System.getProperty("user.name") + "-" + System.currentTimeMillis();
ConnectionFactory cf = ActiveMQTestUtils.createTestConnectionFactory();
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(cf);
jmsTemplate.setPubSubDomain(true);
jmsTemplate.setReceiveTimeout(5000l);
final Random random = new Random();
final byte[] responseBytes = new byte[512];
random.nextBytes(responseBytes);
JmsByteArrayRequestSender requestSender = new JmsByteArrayRequestSender(topicName, jmsTemplate);
JmsByteArrayRequestDispatcher requestDispatcher = new JmsByteArrayRequestDispatcher(new ByteArrayRequestReceiver() {
@Override
public byte[] requestReceived(byte[] message) {
return responseBytes;
}
});
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(cf);
container.setMessageListener(requestDispatcher);
container.setDestinationName(topicName);
container.setPubSubDomain(true);
container.afterPropertiesSet();
container.start();
byte[] randomBytes = new byte[1024];
random.nextBytes(randomBytes);
while(!container.isRunning()) {
Thread.sleep(10l);
}
CollectingByteArrayMessageReceiver collectingReceiver = new CollectingByteArrayMessageReceiver();
requestSender.sendRequest(randomBytes, collectingReceiver);
long startTime = System.currentTimeMillis();
while(collectingReceiver.getMessages().isEmpty()) {
Thread.sleep(10l);
if ((System.currentTimeMillis() - startTime) > TIMEOUT) {
fail("Did not receive a response in " + (TIMEOUT / 1000) + " seconds.");
}
}
s_logger.debug ("requestConduit message received {}ms before timeout limit", TIMEOUT - (System.currentTimeMillis () - startTime));
assertEquals(1, collectingReceiver.getMessages().size());
byte[] receivedBytes = collectingReceiver.getMessages().get(0);
assertEquals(responseBytes.length, receivedBytes.length);
for(int i = 0; i < responseBytes.length; i++) {
assertEquals(responseBytes[i], receivedBytes[i]);
}
container.stop();
container.destroy();
}