|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Standard JMS acess to MQSeries |
« View previous topic :: View next topic » |
Author |
Message
|
kartagos |
Posted: Tue Sep 19, 2006 9:16 am Post subject: Standard JMS acess to MQSeries |
|
|
Newbie
Joined: 13 Apr 2006 Posts: 6
|
Hi all,
I have an application that access JMS provider (server) through standard JMS way. Here is a code snippet :
Code: |
ConnectionFactory CNF = null;
Destination DES = null;
Connection CNX = null;
Session SES = null;
QueueBrowser QBR = null;
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "class.of.my.provider" );
properties.put(Context.PROVIDER_URL, "a_url" );
//JNDI initialization OK
Context CTX = new InitialContext(properties);
//Object lookup...
CNF = (ConnectionFactory) CTX.lookup( "ConnectionFactory" );
DES = (Destination) CTX.lookup( queueName );
CTX.close();
//connection...
CNX = CNF.createConnection();
//session...
SES = CNX.createSession(false, Session.AUTO_ACKNOWLEDGE);
//browser...
QBR = SES.createBrowser((Queue)DES);
etc
|
This code is very simple to make it accessing OpenJMS or ActiveMQ implmenattion, as I only have to change the InitialContextFactory class name and the provider URL.
I also have an application accessing a queue on MQSeries (V6/Linux) , and I'm using this way (inline JMS ? ) to acess the Quueue :
Code: |
MQQueueConnectionFactory MQCF = null;
QueueConnection CNX = null;
QueueSession SES = null;
Queue Q = null;
QueueReceiver QR = null;
//Creating MQQueueConnectionFactory...
MQCF = new MQQueueConnectionFactory();
//settings...
MQCF.setHostName( "my_host" );
MQCF.setPort( 1414 );
MQCF.setQueueManager( "my_q_manager" );
MQCF.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
//creating Connection...
CNX = MQCF.createQueueConnection("my_user",null);
//creating session...
SES = CNX.createQueueSession( false , Session.AUTO_ACKNOWLEDGE );
//creating Q for input...
Q = SES.createQueue( conf.getString( MQ_CONF_QIN ) );
//creating QReceiver...
QR = SES.createReceiver( Q );
etc
|
I want to remove the explicit call of MQQueueConnectionFactory() and make the acess to MQseries just like the upper code. (using "com.ibm.mq.jms.MQQueueConnectionFactory" ? )
Finally, I will put these settings in a file jndi.proprties so that I can easily switch between MQseries and other JMS providers.
Thanx for your patience with this newbie question  |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 19, 2006 9:22 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can use the top set of code in any Java runtime environment.
You may have to add some additional information to set the InitialContext to something like the file context if you are not running in a J2EE server.
See the chapter in the Using Java manual on Using The JMS Administration Tool, particularly the section on Configuration. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 19, 2006 2:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
And please start with the file provider for the initial context. It is the easiest to implement and understand.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kartagos |
Posted: Wed Sep 20, 2006 12:23 am Post subject: |
|
|
Newbie
Joined: 13 Apr 2006 Posts: 6
|
Yes, That's what I'm planning to do : Using full JNDI based on file system context.
Thanx .. and I'll be back with some questions  |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|