发布到ActiveMQ上的主题

时间:2012-11-05 21:32:43

标签: java jms activemq

我在使用java发布到ActiveMQ上的JMS主题时遇到问题。我的代码非常基本,但是我收到了一个错误。当我尝试发送消息时,似乎会出现问题:

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);

ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.start();

ActiveMQSession session = (ActiveMQSession) connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
Topic topic = ((TopicSession) session).createTopic(subject);
ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(topic);


ActiveMQTextMessage txtmessage = (ActiveMQTextMessage) session.createTextMessage();
txtmessage.setText(readFileAsString("foo.txt",null));


producer.send(txtmessage);

Producer.send没有发送短信,我收到以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.activemq.ActiveMQMessageProducerSupport.getDestination()Ljavax/jms/Destination;

1 个答案:

答案 0 :(得分:0)

java.lang.NoSuchMethodError: org.apache.activemq.ActiveMQMessageProducerSupport.getDestination()Ljavax/jms/Destination;

NoSuchMethodError始终表示您的客户端类路径中的客户端jar版本较差(较低版本(或更高版本))。