【问题标题】:Publishing to a topic on ActiveMQ发布到 ActiveMQ 上的主题
【发布时间】:2012-11-06 05:41:26
【问题描述】:

我在使用 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;

【问题讨论】:

    标签: java jms activemq


    【解决方案1】:
    java.lang.NoSuchMethodError: org.apache.activemq.ActiveMQMessageProducerSupport.getDestination()Ljavax/jms/Destination;
    

    NoSuchMethodError 始终表明您的客户端类路径中有错误版本(较低版本(或)较高版本)的客户端 jar。

    【讨论】:

    • @JimGarrison:我认为如果 jar 根本不存在,我认为这将是 ClassNotFoundException,不是吗?如果可能,您能否提供任何参考来支持您的评论?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 2017-05-28
    • 2015-03-21
    • 2020-11-14
    • 2018-03-01
    • 1970-01-01
    相关资源
    最近更新 更多