I have developing ActiveMQ consumer in android App, and I have included activemq-all-5.9.0.jar in my project and set configure build path, but my app is not at all working for me. Below is my code.
ActiveMQConnectionFactory connectionFactory = null;
MessageConsumer consumer = null;
Session session = null;
Connection connection = null;
connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://xxx.xx.xx)?useExponentialBackOff=true&maxReconnectAttempts=-1");
connection = connectionFactory.createConnection("xxx", "xxx");
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic("jms.topic.test");
consumer = session.createConsumer(topic);
While running the App its showing following error message.
Dx trouble processing "javax/management/j2ee/ListenerRegistration.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
[2015-01-28 15:21:26 - MyApp] Dx 1 error; aborting
[2015-01-28 15:21:26 - MyApp] Conversion to Dalvik format failed with error 1
How can i resolve this issue and how to make my App work.
Please help me.
Android doesn't support J2EE, or in fact any of the
javax.*
classes, but a subset of the Oracle Java specifications. See more details here: javax.* cannot be imported in my Android app?.You'll need to find an ActiveMQ client for Android, or write one yourself (not advisable though). You could try the now-supported MQTT protocol designed for mobile as documented in this article.
Alternatively, if an option, use a lightweight messaging broker / client - there are many around, with much easier client implementations (for Android here).