JMS without J2EE?
Forgive me if this is a simple question, but I am attempting to write a simple application to publish/subscribe to an IMQ topic but the only examples I can find seem to require that the code be deployed within the application server.
1 - can I configure a Topic with the application server and use it from outside of the server?
2 - if so, does anyone have any sample code creating an InitialContext? I'm stumped.
Thanx!
[453 byte] By [
jtalarico] at [2007-11-25 17:16:08]

# 1
1 - can I configure a Topic with the application server and use it from outside of the server?
Yes. MQ can also be used as a stand alone product (without the application server).
2 - if so, does anyone have any sample code creating an InitialContext?
There are some examples in the "Sun ONE Message Queue 3.5 Java Client Developer's Guide", Chapter 3 Using Administered Objects:
http://docs.sun.com/source/817-3728/adminobj.html#wp25413
chiaming
http://wwws.sun.com/software/products/message_queue/
# 2
You can not access resources maintained by the App Server
out side of an App Server. But the App Server can access
external resources. So if you have both internal (e.g. ejb's)
and external (standalone JMS apps) that need to share a
JMS admin object such as a Topic you need to store them
in an external repository (LDAP) and configure your App Server
to use the external admin objects.
See the following knowledge base article that goes into some
details about how to do this:
http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsunone%2F8281&zone_110=828 1%2A%20
Chris
http://wwws.sun.com/software/products/message_queue/
kasso at 2007-7-3 11:27:19 >

# 3
It seems that there can be no implicit connection to the JNDI server for binding to Topic/Queue Connections outside of the App Server. This makes sense. However, I was successful in connecting and using a Topic as chiaming.yang suggested. I simply avoided the JNDI lookup and made a connection using the host name and port properties of the TopicConnectionFactory...
TopicConnectionFactory conFactory = new TopicConnectionFactory();
conFactory.setProperty("imqBrokerHostName", "localhost");
conFactory.setProperty("imqBrokerHostPort", "7676");
- JT
# 4
It appears that you are using the j2eesdk or appserver8 platform edition which is a J2EE product.
If you wish to use a standalone JMS provider and create standalone J2SE applications that use JMS, please download the Sun Java System Message Queue product (free for the Platform Edition) from the following url
http://wwws.sun.com/software/products/message_queue/
and go through the examples that are included.
As Chris pointed out the NamingContext of the j2eesdk or appserver8 can only be used by application server components running inside the server. This is because the J2EE platform is not required to make it's resources available to standalone J2SE applications.
However, standalone J2SE applications can be run in the app server's application client container and get access to the resources defined in the app server's NamingContext.
The caveat to this is that these resources are not visible across servers. In order to have an application use resources that are shared, they have to be created in some external NamingContext - like an LDAP dircetory, and then be accessed via proxy resources that are declared in the app server's NamingContext.
George
