• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Using JMS on a client only, outside of a container

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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?

Any suggestions?



OS: Ubuntu 11.04
JAVA: 1.7
JEE: 5
IDE: Netbeans 7.2
JEE-container: Glassfish 3+

For completeness, here is the server-side code


 
Sheriff
Posts: 28360
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way I do it is to get a QueueConnectionFactory from the server via JNDI. From there I can create a QueueConnection. And then I get a Queue from the server, also via JNDI.

I'm connecting to a standalone JMS server, not a Java EE container, but the principle should be the same, you should be able to connect to your server via JNDI. But I can't tell you exactly how.
 
Gerben Feenstra
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this example:


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?
 
Gerben Feenstra
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is solved, created new thread for the latest problem: https://coderanch.com/t/594744/EJB-JEE/java/Cannot-remotely-find-JNDI-resources#2711264
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic