participate


Java Message Service (JMS) - Connecting to Remote JMS Server using a Stand alone application.
<<   Back to Forum  |   Give us Feedback
This topic has 3 replies on 1 page.
raghu.k.nair
Posts:2
Registered: 2/27/05
Connecting to Remote JMS Server using a Stand alone application.   
Mar 28, 2005 9:26 PM

 
Hello ,
I am pretty new to JMS World. I have small question I think you people will be able to answer this.

I have a JMS Server ( OpenJMS / ActiveMQ ...). QueueConnectionFactory and Queue can be registered in some JNDI Server located somewhere .. ( Assumption)


From the Stand Alone application is it possible to load the Initial context properties and get QueueConnectionFactory and Queue from JNDI?
After this I hope i will be able to send messages to this queue.

Thanks n regds
Raghu
 
yiya
Posts:2
Registered: 8/18/05
Re: Connecting to Remote JMS Server using a Stand alone application.   
Aug 18, 2005 7:41 AM (reply 1 of 3)  (In reply to original post )

 
you have to create the context with the information of the server you are going to send messages to.

Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");//or another class you want to use that depens on the server
env.put(Context.PROVIDER_URL, "server_IP:port");//server ip and port
Context context = new InitialContext(env);

with this context you create the connection factory
QueueConnectionFactory qcf = (QueueConnectionFactory)context.lookup("JNDI/connectionFactory");

i hope this can help you.
 
strachaj
Posts:279
Registered: 7/16/97
Re: Connecting to Remote JMS Server using a Stand alone application.   
Aug 23, 2005 10:36 AM (reply 2 of 3)  (In reply to original post )

 
Absolutely! See

http://activemq.org/JNDI+Support

James
http://logicblaze.com/
 
monoranjang
Posts:33
Registered: 12/4/02
Re: Connecting to Remote JMS Server using a Stand alone application.   
Oct 26, 2005 3:45 AM (reply 3 of 3)  (In reply to #2 )

 
My current code is:
env.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

InitialContext initCtx = new InitialContext(env);

System.out.println("Getting connection factory....");
// Finding the WAS QueueConnectionFactory
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
System.out.println("qcf="+qcf);
// Finding the Queue Destination
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);


I am getting exception as:

Oct 26, 2005 4:10:11 PM com.ibm.ws.naming.java.javaURLContextFactory
SEVERE: javaAccessorNotSet
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:579)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:528)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:275)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at sender.Main.main(Main.java:29)
 
This topic has 3 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 27
  • Guests : 138

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums