Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

jndi and jms

Thread view: 
Mike Gaab - 23 Nov 2005 00:01 GMT
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
Roedy Green - 23 Nov 2005 01:01 GMT
>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
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Mike Gaab - 23 Nov 2005 18:21 GMT
>>I've gone through a number of the java tutorial step by step and they
>>simply
[quoted text clipped - 13 lines]
>
> 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
Mike Gaab - 23 Nov 2005 18:25 GMT
>>>I've gone through a number of the java tutorial step by step and they
>>>simply
[quoted text clipped - 23 lines]
> 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
Mike Gaab - 24 Nov 2005 16:26 GMT
> Hi,
>
[quoted text clipped - 11 lines]
> 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
Mike Gaab - 24 Nov 2005 16:51 GMT
>> Hi,
>>
[quoted text clipped - 28 lines]
> 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
Mike Gaab - 25 Nov 2005 08:29 GMT
>>> Hi,
>>>
[quoted text clipped - 34 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.