• Post Reply Bookmark Topic Watch Topic
  • New Topic

Send msg to JMS

 
Chris Wang
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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 ]
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!