ActiveMQ在Android中不起作用 [英] ActiveMQ is not working in Android

查看:175
本文介绍了ActiveMQ在Android中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在android App中开发ActiveMQ消费者,并且在项目中包含了 activemq-all-5.9.0.jar 并设置了配置生成路径,但是我的应用程序根本无法使用我。下面是我的代码。

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
麻烦处理 javax / management / j2ee / ListenerRegistration.class:

不适不构建核心库时建议或错误使用核心类(java。*或javax。*)

[2015-01-28 15:21:26-MyApp] Dx 1错误;正在中止

[2015-01-28 15:21:26-MyApp]转换为Dalvik格式失败,错误为1

我该如何解决此问题以及如何使我的应用正常工作。

How can i resolve this issue and how to make my App work.

请帮助我。

推荐答案

Android不支持J2EE,实际上不支持任何 javax。* 类,但是Oracle Java规范的子集。在此处查看更多详细信息: javax。*无法导入到我的Android应用程序中吗?

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

您需要找到一个适用于Android的ActiveMQ客户端,或者自己编写一个(虽然不建议使用)。您可以尝试以本文中记录的

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.

或者,如果可以的话,请使用轻量级的消息传递代理/客户端-周围有很多,而且客户端实现更简单(适用于Android)。

Alternatively, if an option, use a lightweight messaging broker / client - there are many around, with much easier client implementations (for Android here).

这篇关于ActiveMQ在Android中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆