Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 3.96 KB

mq-create-objects-bindings-sample.md

File metadata and controls

75 lines (53 loc) · 3.96 KB
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

Introduction

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.

Skill Level

Readers of this article is expected to have a basic understanding of WebSphere MQ.

Requirements

  • 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.

Steps

  • Create WebSphere MQ administered objects (assuming WebSphere MQ is installed at /opt/mqm/)

    1. Log into the WebSphere MQ server as mqm user.

    2. Set up WebSphere MQ environment source /opt/mqm/bin/setmqenv -s.

    3. Creating a new queue manager named "QM1" crtmqm QM1.

    4. Start QM1 strmqm QM1.

    5. Run MQSC command on QM1 runmqsc QM1.

    6. Create a local queue Q1 define qlocal(Q1).

    7. Create a listener define listener(L1) trptype(tcp) port(1416).

    8. Start listener L1 start listener(L1).

    9. Create a channel named "JMS.STREAMS.SVRCONN" def channel (JMS.STREAMS.SVRCONN) chltype(SVRCONN).

    10. 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).

    11. 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

    12. Perform a security refresh in MQSC command line refresh security TYPE (AUTHSERV).

  • Generate bindings file using JMSAdmin script

    1. Log into the WebSphere MQ server as mqm user.

    2. Open MQ_INSTALLATION_PATH/java/bin/JMSAdmin.config file with text editor.

    3. 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
    4. Set the CLASSPATH for running JMSAdmin tool

      export 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

    5. Run JMSAdmin tool MQ_INSTALLATION_PATH/java/bin/JMSAdmin

    6. 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

    7. A file named .bindings has been generated under the directory specified for the PROVIDER_URL parameter.

Additional Resources

WebSphere MQ Knowledge Center