File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes Invoking MQ server from standalone java Appl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Invoking MQ server from standalone java Appl" Watch "Invoking MQ server from standalone java Appl" New topic
Author

Invoking MQ server from standalone java Appl

ramjcp kris
Greenhorn

Joined: Sep 05, 2005
Posts: 27
HI

i have created QueueManager say QM and queues say Q1 in MQServer.

Now i want to publish a mesage into the queue Q1 created earlier Through stand alone java client.

can any one tell me how to acheive this.
i am giving here the code i have written .



can any one tell me how do i need to give the properties at time of context cretion for lookup.

i was new to JMS and IBM MQ server ,if my apporach is wrong , pls suggest me.

hope i would get some answer
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Here's some code I use for plopping a message off to WebSphere's embedded messaging:




The free CBT tutorial on JMS that shows you how to set up JMS, and lease/read messages from a JMS queue/topic is here:

Free WebSphere Tutorial for Working with JMS - Embedded Messaging

Enjoy!

-Cameron McKenzie
ramjcp kris
Greenhorn

Joined: Sep 05, 2005
Posts: 27
hi Cameron

thanks for your reply.

i need it to be done through stand alone client.
i mean its pure java class which contains main method from there i want to post message to queue running in MQServer.

how to create a connection factory from context just like the way you have given reply
Steve Wink
Ranch Hand

Joined: May 13, 2002
Posts: 223
Originally posted by ramjcp kris:
hi Cameron

thanks for your reply.

i need it to be done through stand alone client.
i mean its pure java class which contains main method from there i want to post message to queue running in MQServer.

how to create a connection factory from context just like the way you have given reply


This code is looking up the JMS object in a JNDI context. What you need to a JNDI provider ( you could even use the Sun reference ones I guess, and check out the JNDI tutorial while you're at it ) and then bind your queueing objects into the JNDI context, and access the JNDI context.
The JMS provider you have will probably have a tool for binding its objects into JNDI, for example WebSphere MQ has JMSAdmin, or you could do it via an app server. You'll have to provide the correct properties for your app to access the JNDI context, typically in a JNDI.properties file in your classpath. The relevent properties are typically the initial context factory class name, the protocol, host and the port. The MQ tool will have to use the same JNDI context.

If your set up is WebSphere MQ inside WebSphere ( I'm guessing its this because of the forum youre in ) then you could run your application with the launchclient batch file. This provides the correct environment for you so you wouldn't need to specify the JNDI initial context factory etc.
[ March 27, 2007: Message edited by: Steve Wink ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invoking MQ server from standalone java Appl