问题描述
- ActiveMQ只执行一次就不在执行了
-
如题,怎么回事啊?我写的main方法测试的,第一遍能运行出来,第二次就不行了public class MessageSendAndReceive { public static void main(String[] args) throws JMSException { ConnectionFactory connectionFactory = new ActiveMQConnectionFactory( "vm://localhost"); Connection connection = connectionFactory.createConnection(); connection.start(); Queue queue = new ActiveMQQueue("testQueue"); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(queue); messageProducer.send(session.createTextMessage("Message")); MessageConsumer messageConsumer = session.createConsumer(queue); messageConsumer.setMessageListener(new MessageListener() { public void onMessage(Message msg) { TextMessage message = (TextMessage) msg; try { System.out.println(message.getText()); } catch (JMSException e) { e.printStackTrace(); } } });
这个只执行一次,第二次就没反应了,也不报错,要把MyEclipse关了在打开才能运行一次。。怎么回事啊
解决方案
没人啊。。。。求助啊。。。。
时间: 2024-10-01 15:39:34