Creating a Queue Connection Factory
and Queue for connectivity to MQ
Here are the resources used in the article:
[Link] [Link]
[Link]
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 [Link] 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
[Link]("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
[Link]("java:comp/env/jms/Queue").
Then in the [Link] you would add the following:
<resource-ref>
<description>
</description>
<res-ref-name>jms/QCF</res-ref-name>
<res-type>[Link]</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>[Link]</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 [Link] 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
[Link]
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/[Link].
The application will still use jms/QCF, but WebSphere will use the
target resource called jms/[Link]
The application will still use jms/Queue, but WebSphere will internally
redirect to the resource target called jms/[Link].
Script to create the Queue Manager and Queue
Create QM
crtmqm TSTQM1
Start QM
strmqm TSTQM1
Run script
runmqsc TSTQM1 < ./[Link]
script is called [Link]
********************************************************************/
* Create Listener */
********************************************************************/
DEFINE LISTENER (TSTQM1_1420) +
TRPTYPE (TCP) +
PORT (1420) +
CONTROL(QMGR) +
REPLACE
********************************************************************/
* Create Queues */
********************************************************************/
DEFINE QLOCAL('[Link]') REPLACE +
DESCR('My Test Queue') +
* Persistent messages OK
DEFPSIST(YES) +
* Shareable
SHARE DEFSOPT(SHARED) +
* Maximum queue depth
MAXDEPTH(100000)
********************************************************************/
* Server - Channel */
********************************************************************/
DEFINE CHANNEL('[Link]') +
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 [Link] and is case-sensitive