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

Send msg to JMS

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am new to JMS.

In our project we use Tomcat 4.1 as web server and Websphere Studio Application Developer 5.1 as IDE. Recently we got a component which runs on JBoss and it uses JMS. Because our app needs to access this component, we have to send a JMS message to its JMS queue.

In our development environment(Tomcat + WSAD), should I change Tomcat to some other J2EE application server such as JBoss which supports JMS?

I tried to use WAS test environment that supports JMS. Should I set up JMS in WAS?

In my servlet, I use "Context" to look up JMS queue connection factory name and queue name that the component provided. But I got an exception: "Name not found." Can I lookup a name which is in another J2EE container?

I really got confused! What is the correct way to do this?

Thanks in advance!

Chris

[ April 29, 2005: Message edited by: chris wang ]

[ April 29, 2005: Message edited by: chris wang ]

[ April 29, 2005: Message edited by: chris wang ]
[ April 29, 2005: Message edited by: chris wang ]
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can run JMS in a separate server. You should check out OpenJMS for an example of this. As for creating the InitialContext for a separate server, you'll need to pass a Map of properties so the context knows which host, port, etc to go to. You may want to check out the JNDI tutorial for more info on this.
 
Chris Wang
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for reply.

I got running a example in whcih I created a servlet in Tomcat and sent a JMS message to OpenJMS server. I put 4 OpenJMS jar files into $TOMCAT_HOME$/shared/lib and use following code to set up Context:

String icf = "org.exolab.jms.jndi.rmi.RmiJndiInitialContextFactory";
String url="rmi://localhost:1099/";
Hashtable env = new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY, icf );
env.put( Context.PROVIDER_URL, url );
Context ctx = new InitialContext(env);

It works fine.

But when I use the same way to connect JBossMQ I got an exception:
Name XAConnectionFactory is not bound in this Context.

My code looks like this:
String icf = "org.jnp.interfaces.NamingContextFactory";
String url="jnp://localhost:1099";
Hashtable env = new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY, icf );
env.put( Context.PROVIDER_URL, url );
Context ctx = new InitialContext(env);
QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup
("java:/XAConnectionFactory");
...

What's wrong with my code? or did i miss some jar files?
 
Do you pee on your compost? Does this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic