我正在尝试使用 ActiveMQ“Classic”5.x 创建一个持久的消费者,所以我有以下内容:
private static void consumeFromTopic() throws JMSException, NamingException {
javax.naming.Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic("topic-queue");
MessageConsumer consumer = session.createDurableConsumer(topic, "lanhellas-durable-consumer");
consumer.setMessageListener(new MyListener());
connection.start();
}
当我尝试启动我的消费者时,我得到以下信息:
Exception in thread "main" java.lang.AbstractMethodError: org.apache.activemq.ActiveMQSession.createDurableConsumer(Ljavax/jms/Topic;Ljava/lang/String;)Ljavax/jms/MessageConsumer;
这是我的
pom.xml
:
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.7.0</version>
</dependency>
因此,阅读有关 ActiveMQ“Classic”5.x 的更多信息,我发现仅支持 JMS 1.x,并且此版本不支持此方法,因此我需要更改为支持 JMS 2.0 的 Apache Artemis,但我有一些对此有疑问:
javax.jms-api
版本是什么?