For some reason I am unable to create a durable consumer, to ingest messages from activemq. I have researched here and here, but using the latest versions (along with Java 1.7) hasn't solved the problem. I must be using a wrong version/implementation of something, but I haven't been able to root it out. Here is the code:
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import org.apache.activemq.ActiveMQConnectionFactory;
ConnectionFactory cf = new ActiveMQConnectionFactory("bob", "bobsPword", "tcp://localhost:61616");
Connection connection = cf.createConnection();
connection.start();
Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic("TEST.QUEUE.FOO");
MessageConsumer consumer = session.createDurableConsumer(topic, "clientId");
Message message = consumer.receiveNoWait();
if (message instanceof TextMessage) {
System.out.println("message: " + ((TextMessage) message).getText());
}else{
System.out.println("unexpected message...");
}
The error:
Exception in thread "main" java.lang.AbstractMethodError: org.apache.activemq.ActiveMQSession.createDurableConsumer(Ljavax/jms/Topic;Ljava/lang/String;)Ljavax/jms/MessageConsumer;
My dependencies:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.fusesource.stompjms</groupId>
<artifactId>stompjms-client</artifactId>
<version>1.19</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.10.0</version>
</dependency>
</dependencies>