0% found this document useful (0 votes)
4 views

JMSTester

This document outlines the steps to create a Queue Connection Factory (QCF) and a queue for connecting to MQ, including necessary scripts and configurations in web.xml. It details the JNDI lookups for obtaining the QCF and queue objects, as well as the importance of defining resource references for successful deployment in WebSphere. Additionally, it provides instructions for creating a Queue Manager and Queue, along with troubleshooting authentication errors and setting up JNDI resources.

Uploaded by

kolli1432003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

JMSTester

This document outlines the steps to create a Queue Connection Factory (QCF) and a queue for connecting to MQ, including necessary scripts and configurations in web.xml. It details the JNDI lookups for obtaining the QCF and queue objects, as well as the importance of defining resource references for successful deployment in WebSphere. Additionally, it provides instructions for creating a Queue Manager and Queue, along with troubleshooting authentication errors and setting up JNDI resources.

Uploaded by

kolli1432003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Creating a Queue Connection Factory

and Queue for connectivity to MQ


Here are the resources used in the article:

runmqsetup.sh setupMQ.mqsc

JMSTesterEAR.ear

An application wishes to be able to post and receive message to MQ


the application will pull messages put messages on MQ and will pull
then off.

You need to define a resource reference (using the resource-ref tag)


in web.xml and then figure out how to map that resource to a real
resource in the web server. If you're using WebSphere app server
then the deployment step will take care of that for you (you'll be
prompted to map the web-app resource to a server resource.

In your code your JNDI call to get an Connection Factory object the
JNDI lookup is going to be
context.lookup("java:comp/env/jms/QCF").

In your code your JNDI call to get a queue object from the QCF
object the JNDI lookup is going to
context.lookup("java:comp/env/jms/Queue").

Then in the web.xml you would add the following:

<resource-ref>
<description>
</description>
<res-ref-name>jms/QCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<message-destination-ref>
<description>
</description>
<message-destination-ref-name>jms/Queue</message-destination-ref-name>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-usage>ConsumesProduces</message-destination-usage>
<message-destination-link>jms/Queue</message-destination-link>
</message-destination-ref>

<message-destination>
<description>
</description>
<message-destination-name>jms/Queue</message-destination-name>
</message-destination>

When the application is deployed you can re-map these resources as


they are defined as indirect JNDI resources. Re mapping is
presented as an option in the application install wizard as
WebSphere detects from the web.xml that indirect JNDI override is
possible

If you DO NOT add the <resource-ref>, <message-destination-ref>, <message-


destination> then you would have to create resources in WebSphere for
the QCF and Queue that match exactly the names as defined in the
code and this means that if you needed to install the application in an
environment and the JNDI names you had used were already being
used then your application would not work!

Here is the application working


http://<hostname>:<port>/JMSTester/

Port is usually 9080 is only one server exist, otherwise you need to
look at the server ports.
You can see above the application is using jms/QCF for the queue
connection factory and jms/Queue for the actual MQ queue. But our
WebSphere as we will see below is not using these names.

Lets have a look at an installed application and show how we can


update the resources anytime an override.
I want the application to use my resource called jms/QCF.LQTest.
The application will still use jms/QCF, but WebSphere will use the
target resource called jms/QCF.LQTest
The application will still use jms/Queue, but WebSphere will internally
redirect to the resource target called jms/LQ.Test.

Script to create the Queue Manager and Queue


Create QM
crtmqm TSTQM1

Start QM
strmqm TSTQM1

Run script

runmqsc TSTQM1 < ./setupMQ.mqsc


script is called setupMQ.mqsc
********************************************************************/
* Create Listener */
********************************************************************/
DEFINE LISTENER (TSTQM1_1420) +
TRPTYPE (TCP) +
PORT (1420) +
CONTROL(QMGR) +
REPLACE
********************************************************************/
* Create Queues */
********************************************************************/

DEFINE QLOCAL('LQ.TEST') REPLACE +


DESCR('My Test Queue') +
* Persistent messages OK
DEFPSIST(YES) +
* Shareable
SHARE DEFSOPT(SHARED) +
* Maximum queue depth
MAXDEPTH(100000)

********************************************************************/
* Server - Channel */
********************************************************************/
DEFINE CHANNEL('SYSTEM.ADMIN.SVRCONN') +
CHLTYPE(SVRCONN) +
TRPTYPE(TCP) +
DESCR('Server connection for WebSphere') +
REPLACE

Creating a Queue Connection Factory


A QCF is used to know how to communicate with MQ as created by
the mqsc script

Lest create the QCF and QUEUE. This SIB is not required for this!
Now lets fix the auth error
Save and go back to QCF and set the authentication alias

Save
Creating a Queue (Destination)
Creating a JNDI resource for a MQ Queue

For you first scope use Cell, then once working you can create a node and or
cluster scope
The actual queue name in MQ is LQ.TEST and is case-sensitive

You might also like