Vittorio Ziparo wrote:
I am currently evaluating hornetQ for use in a research project. The project requires clients to run on Android smarphones, but up to now I failed to get HornetQ running to it. Apparently, one of the problems is that Android does not support javax.naming. Does anyone know if there is a clean way to run a HornetQ client on Android, or if there is at least some workaround?
Since javax.naming is not available on Android that means that you can not use JNDI to lookup the JMS resources from your phone.
Instead you can try to allocate them directly from Android code: http://hornetq.sourceforge.net/docs/hornetq-2.1.1.Final/user-manual/en/html/using-jms.html#d0e1186
I'm very interested to know what are the issues/challenges to run HornetQ clients on Android, please keep us posted.
Thank you for the fast reply. I'll let you know if this works.
As Jeff alluded to, HornetQ on the client doesn't use anything from javax.naming - this must be your own code trying to do a JNDI lookup, not HornetQ causing this problem.
I tried to modify the code as suggeted. I apologize in advance if this is some stupid error on my side, but I am very new to HornetQ and JBoss technology in general. The code, which is attached to this message, works fine as plain java code but gives the following problem when used in a Android app: "The type javax.naming.Referenceable cannot be resolved. It is indirectly referenced from required .class files".
I am using HornetQ 2.1.0 and I added the following jars to my project from the lib directory of HornetQ:
Thank you for the support,
ComTestServer.java.zip 1.0 KB
Is there a stacktrace or does it specify which class files it is referenced from. I do know that ConectionFactory.java implements javax.naming.Referenceable maybe that is the issue, if that is the case then most vendors would have the same issue. You could try using the HornetQ core API as this would not use ant referenceable classes afaik (take a look at one of the core examples)
I tried with the core example but the compiler complains saing: "The type javax.transaction.xa.XAResource cannot be resolved. It is indirectly referenced from required .class files".The problem is relative to ClientSession.
just doing a quick google search it looks like the android JVM does not implement the full JDK. I guess it is unlikely you will get any complex peice of java software to work on it.
HornetQ uses XA for all its transaction stuff...
It seems Android does not support enough "entreprisey" API to run HornetQ client...
An alternative could be to use STOMP to communicate between Android phone and HornetQ.
To send and receive STOMP messages, all you need is to be able to open a Socket and read/write on it (see HornetQ's StompExample).
You can maybe also use a Java library like Gozirra which provides a higher-level API (http://trac.germane-software.com//Gozirra).
On HornetQ server, make sure to use a STOMP acceptor: http://hornetq.sourceforge.net/docs/hornetq-2.1.1.Final/user-manual/en/html/interoperability.html#stomp
Once STOMP messages are delivered to HornetQ, they will be handled like JMS messages: you can have other parts of your infrastucture listening to JMS and receive the messages sent by the Android phone.
hope that helps,
You could just grab that class from the J2SE and put in on your client classpath. It's just an interface after all