• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

very basic question about JMS hosts

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic