我正在尝试使用ActiveMQ 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 5.xi的更多信息后发现,该版本仅支持JMS 1.x,并且不支持此方法,因此我将需要更改为支持JMS 2.0的Apache Artemis。但是,我对此有一些疑问它:
javax.jms-api
版本是什么?