layout | title | description | weight | published | navlevel |
---|---|---|---|---|---|
docs |
WebSphere MQ - Sample steps for creating queues and bindings file |
Sample scripts for creating MQ objects and bindings. |
80 |
true |
2 |
The Streams JMS toolkit provides operators for sending and receiving messages from WebSphere MQ. This article shows a simple sample for creating WebSphere MQ administered objects and generating bindings file.
Readers of this article is expected to have a basic understanding of WebSphere MQ.
- You must have already installed WebSphere MQ. A evaluation version of WebSphere MQ is available.
- Create an OS user on the machine where WebSphere MQ server is running and make sure the user name is same as the user that will run SPL application.
-
Create WebSphere MQ administered objects (assuming WebSphere MQ is installed at /opt/mqm/)
-
Log into the WebSphere MQ server as mqm user.
-
Set up WebSphere MQ environment
source /opt/mqm/bin/setmqenv -s
. -
Creating a new queue manager named "QM1"
crtmqm QM1
. -
Start QM1
strmqm QM1
. -
Run MQSC command on QM1
runmqsc QM1
. -
Create a local queue Q1
define qlocal(Q1)
. -
Create a listener
define listener(L1) trptype(tcp) port(1416)
. -
Start listener L1
start listener(L1)
. -
Create a channel named "JMS.STREAMS.SVRCONN"
def channel (JMS.STREAMS.SVRCONN) chltype(SVRCONN)
. -
Add a channel authentication record for the new OS user, assuming the username is "streamsadmin"
SET CHLAUTH('JMS.STREAMS.SVRCONN') TYPE(USERMAP) CLNTUSER('streamsadmin') USERSRC(CHANNEL) DESCR('streamsadmin record') ACTION(ADD)
. -
From a command prompt, provide the following authorities for user "streamsadmin".
setmqaut -m QM1 -t qmgr -p "streamsadmin" -all
setmqaut -m QM1 -t qmgr -p "streamsadmin" +setall +setid +altusr +connect +inq
setmqaut -m QM1 -n "Q1" -t q -p "streamsadmin" -remove
setmqaut -m QM1 -n "Q1" -t q -p "streamsadmin" +passall +passid +setall +setid +browse +get +inq +put +set
-
Perform a security refresh in MQSC command line
refresh security TYPE (AUTHSERV)
.
-
-
Generate bindings file using JMSAdmin script
-
Log into the WebSphere MQ server as mqm user.
-
Open
MQ_INSTALLATION_PATH/java/bin/JMSAdmin.config
file with text editor. -
Edit the following lines. Choose an accessible directory for the
PROVIDER_URL
parameter, where the.bindings
file will be generated.INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
PROVIDER_URL=file:///homes/user/bindings
An alternative to editing this file directly is to do the following:
- Copy MQ_INSTALLATION_PATH/java/bin/JMSAdmin.config to a different directory
- Make the file writable:
chmod u+w /path/to/JMSAdmin.config
- Run JMSAdmin with the -cfg flag:
MQ_INSTALLATION_PATH/java/bin/JMSAdmin -cfg /path/to/JMSAdmin.config
-
Set the
CLASSPATH
for running JMSAdmin toolexport CLASSPATH=$CLASSPATH:/opt/mqm/java/lib:/opt/mqm/java/lib/com.ibm.mq.jar:/opt/mqm/java/lib/com.ibm.mq.jms.Nojndi.jar:/opt/mqm/java/lib/com.ibm.mq.soap.jar:/opt/mqm/java/lib/com.ibm.mqetclient.jar:/opt/mqm/java/lib/com.ibm.mqjms.jar
-
Run JMSAdmin tool
MQ_INSTALLATION_PATH/java/bin/JMSAdmin
-
Run following commands in JMSAdmin tool for defining queue connection factory and queue. Replace
<host name>
with the actual host name.DEFINE QCF(confact) QMGR(QM1) tran(client) chan(JMS.STREAMS.SVRCONN) host(<host name>) port(1416)
DEFINE Q(dest) QUEUE(Q1) QMGR(QM1)
end
-
A file named
.bindings
has been generated under the directory specified for thePROVIDER_URL
parameter.
-