ActiveMQ is not working in Android

。_饼干妹妹 提交于 2019-12-25 07:48:57

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/28189452/activemq-is-not-working-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!