I have a standalone desktop application 'A' which needs to send messages to remote application 'B' running inside a JEE container. Application B has a JMS-queue to recieve messages. Application A should have minimal changes, and for Application B I have no access to functionality or source code whatsoever.
So the plan is to make a jar-library which can be used by creating a single call with some parameters to it from within Application A. The library should put messages on the queue in Application B.
I followed the Java EE 5 tutorial from oracle, in particular the part about JMS that has a 'server' (earthmdb demo) and a client (jupiterclient demo) running separately (http://docs.oracle.com/javaee/5/tutorial/doc/bnchx.html). I use the 'server' to mimic Application B so I can test my code. It is a simple class implementing the MessageListener interface and an onMessage() method. This is working just fine; I see messages get send from the client-application and they're being received in the onMessage() method correctly.
However, they both run inside the same Glassfish container. So I tried to seperate the client to a standalone application to eventually be able to put it in a jar that is to be used by application A.
I used Apache ActiveMQ as a JEE implementation, so I don't need to run inside a JEE/glassfish-container. The messages are send to "TapServiceQueue" running in the glassfish-container on the same machine (for now) on port 17294. My code runs, messages get send, but they are not received on the server-side somehow :/
Here's is the code of my client class:
I created my app as a Maven-app inside netbeans, so dependencies are taken care of automatically.
In my client I do a createQueue:
This seems rather strange to me, since the queue already exists. I've been searching for ages for a solution now, but there does not seem to be a way to get an existing queue reference :s How to do this? Can you guys see something wrong in my code? Or is my approach not the correct one somehow?
Then I should be able to get the connectionFactory from the context with this:
and the queue:
But I don't know what values to use in the properties to connect to my glassfish container. What type of InitialContextFactory should I use? What protocol should I use? vm:// or tcp://, or something else?
I tried using com.sun.enterprise.naming.SerialInitContextFactory and the url: iiop://127.0.0.1:17294 But then I get an Exception:
This is driving me crazy. How hard can it be to remotely connect to a queue and put a message on it?