jndi and jms

M

Mike Gaab

Hi,

I am having some difficulty getting a simple example of JMS running.
I would like to simply create a standalone app that sends and/or receives
messages from the server.

The main problem I am having is coming up with a string that points to
the server, specifically the context. Would some one explain the following
connect string:

ic.lookup("java:comp/env/jms/MyConnectionFactory");

I've gone through a number of the java tutorial step by step and they simply
do not run. Any other examples would be appreciated.

Thanks Mike
 
R

Roedy Green

I've gone through a number of the java tutorial step by step and they simply
do not run. Any other examples would be appreciated.
ic.lookup("java:comp/env/jms/MyConnectionFactory");

In Sun's tutorial they show code like this:

Context ctx = new InitialContext();

QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) ctx.lookup("QueueConnectionFactory");

TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");

Where did you read about the java: syntax?

Next, you realize you must download and install some sort of JMS
server, e.g. the one bundled with J2EE.

See http://mindprod.com/jgloss/jms.html
 
M

Mike Gaab

Roedy Green said:
In Sun's tutorial they show code like this:

Context ctx = new InitialContext();

QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) ctx.lookup("QueueConnectionFactory");

TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");

Where did you read about the java: syntax?

In the java tutorial for j2ee 1.4

Next, you realize you must download and install some sort of JMS
server, e.g. the one bundled with J2EE.

dah...

In order to write a standalone client, I need to locate where and which
messaging
service is being used. What I can not find is the following two parameters.

INITIAL_CONTEXT_FACTORY=
PROVIDER_URL=

These are needed to setup the intial context. The can be set
programmatically
or via a resource. Your example of creating an InitialContext with an empty
constructor will call the jndi.properties files. I can't find that either.

Mike
 
M

Mike Gaab

Mike Gaab said:
In the java tutorial for j2ee 1.4



dah...

In order to write a standalone client, I need to locate where and which
messaging service is being used.

a dah for me too. ;-)

I should have said which naming service is used. JNDI is just an api not
a service.
Mike
 
M

Mike Gaab

Mike Gaab said:
Hi,

I am having some difficulty getting a simple example of JMS running.
I would like to simply create a standalone app that sends and/or receives
messages from the server.

The main problem I am having is coming up with a string that points to
the server, specifically the context. Would some one explain the following
connect string:

ic.lookup("java:comp/env/jms/MyConnectionFactory");

I've gone through a number of the java tutorial step by step and they
simply
do not run. Any other examples would be appreciated.

I finally figured some of this out.

JNDI is part of the JDK. JDK1.5.0_03 comes with a number of naming service
providers.

This link helps explain a bunch.
http://java.sun.com/developer/technicalArticles/Programming/jndi/

Some services need to be manually started.

My question now is, if I create a ConnectionFactory for JMS using the admin
tool, how do I use it in a client that is standalone and also uses a
non-standard service? Or if I can't use it how do I create/bind the
ConnectionFactory programmatically? (I am not enough sure I am asking the
right questions.)


Mike
 
M

Mike Gaab

Mike Gaab said:
I finally figured some of this out.

JNDI is part of the JDK. JDK1.5.0_03 comes with a number of naming service
providers.

This link helps explain a bunch.
http://java.sun.com/developer/technicalArticles/Programming/jndi/

Some services need to be manually started.

My question now is, if I create a ConnectionFactory for JMS using the
admin tool, how do I use it in a client that is standalone and also uses a
non-standard service? Or if I can't use it how do I create/bind the
ConnectionFactory programmatically? (I am not enough sure I am asking the
right questions.)

If I am using "com.sun.jndi.cosnaming.CNCtxFactory" as the initialcontext,
how can I lookup a ConnectionFactory that was created using the JMS admin
tool?

MIke
 
M

Mike Gaab

Mike Gaab said:
If I am using "com.sun.jndi.cosnaming.CNCtxFactory" as the initialcontext,
how can I lookup a ConnectionFactory that was created using the JMS admin
tool?

ActiveMQ addressed this problem in their jndi.properties file.
They had entries for the JNDI names of connection factories, topics
and queues. I am not sure if this is standard but was something I
had been having trouble with since the application I am writing is
outside of the j2ee server.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,775
Messages
2,569,601
Members
45,182
Latest member
BettinaPol

Latest Threads

Top