• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

WebSphere MQ JMS Question

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am novice in using websphere MQ 6.0 in Z/OS.

We've the queues and queue managers configured in Z/OS.

I need to write a JMS code to put messages in the queues that were configured in Z/OS which CICS program(in Mainframe) will read it.

Is it possible to achieve this using JMS or do I need to depend on
WebSphere MQ base Java classes?

Please advice which one is a better approach.

Thanks in advance.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can certainly do this, the JMS libraries use the MQ libraries so in the end you depend on the base libraries. From a compile stand point if you are running inside an Application Server like websphere you should be able to look up the ConnectionFactory and Queue via JNDI and only compile against the JMS interfaces.

If you are writing an application outside of an application without a JNDI provider its debatable if using the JMS libraries would be better or not - as you will have to configure the ConnectionFactory via the JMS MQ library - tying you to it at compile (versus runtime via JNDI). I'd still use JMS though as the rest of the code can probably just use the JMS interfaces and only setting up the ConnectionFactory would be MQ specific (you might also have to set some MQ specific settings on the Queue depending on the kind of message you want to send).

If you want to send text back and forth use a TextMessage and set on the Queue - queue.setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ). If you configure this via JNDI you can avoid all MQ specific code in your classes.
[ September 02, 2008: Message edited by: Tim LeMaster ]
 
satheesh krishnaswamy
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your quick response.

Can you let me know what InitialContextFactory and ProviderURL that I should give if I use JMS code.

Please note I do not configure JNDI using JMSAdmin tool.

I use Websphere Application Server on z/OS.Please suggest the intitial context factory adn providerurl suitably.

Thanks,
 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here is an example of code using JMS API.It is easy. You can find a lot of code through internet that are more complet.

I coud test it successfully with a client Linux with JNDI. But I don't know how to test it with a client windows because Windows doesn't accept a .bindings file generated by JMSAdmin tools from Linux.
How to solve it ?




public static final String INITIAL_CONTEXT_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
public static final String PROVIDER_URL = "file:/var/mqm";
public static final String SECU = "none";

public static final String QUEUE_CONNECTION_FACTORY = "DEVQCF";
public static final String QUEUE = "MYQUEUE";



Hashtable env;
InitialContext context;
QueueConnectionFactory qcf = null;
QueueConnection connection;
Queue queue;

env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
//env.put(Context.SECURITY_AUTHENTICATION,SECU);



boolean useJNDI = false;
try {

if( useJNDI ) {
System.out.println("useJNDI");
context = new InitialContext(env);
qcf = (javax.jms.QueueConnectionFactory) context.lookup (QUEUE_CONNECTION_FACTORY);
}

//Groupe mqs
connection = qcf.createQueueConnection("usre","password");
System.out.println("connection reussie1");
connection.start();
System.out.println("connection reussie2");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue("FMD_RCV");

//Envoie de message
MessageProducer sender = session.createProducer(queue);

sender.close();
session.close();
connection.close();
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can be a very frustrating process. There are many settings, and many simple things that can be configured incorrectly.

Here are two CBT tutorials I put together to show people exactly how to set up queues, add messages to queues, and how to write an MDB, message driven bean, to read off of those queues. I hope this helps:

Tutorial on Configuring JMS Messaging in WebSphere Application Server Admin

Tutorial on Writing MDBs and Testing Message Queues and Topics

Good luck!

-Cameron McKenzie
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic