wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes very basic question about JMS hosts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "very basic question about JMS hosts" Watch "very basic question about JMS hosts" New topic
Author

very basic question about JMS hosts

jeff willis
Greenhorn

Joined: Jul 29, 2004
Posts: 25
Hi,

I've set up my own machine as a JMS host (using Suns Application Server J2EE RI). In it I specify my machine as "the default" host, set up a connection factory, and Queues (for a point-to-point message).

I have written a few simple messaging apps to send and to listen to messages on my machine.

This all works fine.

Now I want to communicate to a remote host.

How is this host set up? How does my system know the queue name of the remote host? I don't see a connection between the remote host queue name and the remote host IP address.

For example, say HOST_B is listening on queue JMS/HOST_B.
And on HOST_A, my point-to-point sender application wants to send to HOST_B, how does it connect?
Brian Tinnel
Ranch Hand

Joined: Aug 25, 2003
Posts: 69
The short answer is: The same as your client application.

You need to get a proper InitialContext, look up the queue, look up the queue connection factory, create a connection, create a session, create a sender, create a message, use the sender to send the message and then close it all down.

When creating the InitialContext you need to specify the proper InitialContext.PROVIDER_URL and InitialContext.INITIAL_CONTEXT_FACTORY for HOST_B and then you are set. If you are sending between different brands of app servers, then you might have issues to resolve, but it should work fine between similar hosts.
jeff willis
Greenhorn

Joined: Jul 29, 2004
Posts: 25
So, would PROVIDER_URL be the IP address of HOST_B?

(yeah, let's assume that HOST_A and HOST_B are running the same application server)

When I examine the PROVIDER_URL from my Context on my machine, it doesn't contain the IP address of my machine.



The output of that is:

Brian Tinnel
Ranch Hand

Joined: Aug 25, 2003
Posts: 69
InitialContext.PROVIDER_URL is just a public static final String, it is always "java.naming.provider.url". It is most often used in remote clients when creating an InitialContext to access a J2EE app server.

The format of a PROVIDER_URL is specific to an app_server. For JBoss it is usually something like "jnp://myhost:1099".

You use it like this:



If you don't use Properties with the InitialContext, then it will look for a jndi.properties on your classpath to load the properties. My guess is that is what you have been doing on your remote application. The jndi.properties will look something like:



When running code within an app server, the InitialContext will automatically be created to refer to the app server you are running on. To talk to another app server, you will need to create a Properties object and use it to create an InitialContext.
jeff willis
Greenhorn

Joined: Jul 29, 2004
Posts: 25
ok, I think I can see the light at the end of the tunnel...

I'll set up a PROVIDER_URL with this format:

PROTOCOL//host ort

With the PROTOCOL being the protocol used by the server to exchange data.

The whole problem with this is finding that protocol. If it's a WebLogic server the protocol is "t3", if it's a SonicMQ the protocol is "ldap", if it's the Sun app server (J2EE RI) the protocol is (I think) "iiop".

I wish there were a very easy place to find this information.

Know of any?
jeff willis
Greenhorn

Joined: Jul 29, 2004
Posts: 25
I'm not sure how I got that smiley in my previous post.

the format is PROTOCOL//host : port

(no spaces...I'm trying to keep the smileys out)
Brian Tinnel
Ranch Hand

Joined: Aug 25, 2003
Posts: 69
Each app server is different. You will just need to look through the documentation of the app server you are trying to communicate with. Or, do a search. If you run into problems, do a search. Most likely, someone else will have run into the same problem.
 
jQuery in Action, 2nd edition
 
subject: very basic question about JMS hosts
 
Similar Threads
Send msg to JMS
Problem looking up remote JMS queue from standalone app
WSAD5.1.3 remote MQv5.3 connection and listen using MDB
MDB listening to external MQ in Glassfish
Embedded JMS server.Messaging.