Connecting JMS applications with WebSphere MQ using Tivoli Directory Server

This article shows you how to connect JMS applications to WebSphere MQ using IBM Tivoli Directory Server for authentication and lookup. It includes configuration steps for WebSphere MQ and Tivoli Directory Server.

Avinash Jhawar (avjhawar@in.ibm.com), Staff Software Engineer, IBM

Photo of Avinash JhawarAvinash Jhawar has nine years of experience in software testing and development. He currently works on WebSphere Message Broker and IBM Integration Bus. You can contact Avinash at avjhawar@in.ibm.com.



Pabitra Mukhopadhyay (pabmukho@in.ibm.com), Software Engineer, IBM

Photo of Pabitra MukhopadhyayPabitra Mukhopadhyay has seven years of experience with IBM mainframes (System z) application development, testing, and systems programming. He is currently working with the IBM India Software Labs System z Competency team as a z/OS and middleware systems programmer. He has co-authored developerWorks articles involving messaging products and z/OS. You can contact Pabitra at pabmukho@in.ibm.com.



Abhinav Priyadarshi (pabhinav@in.ibm.com), Technical Project Lead, WebSphere Message Broker Development team, IBM

Photo of Abhinav PriyadarshiAbhinav Priyadarshi is an Advisory IT Architect and Technical Lead for the IBM Integration Bus Development Team at the IBM India Software Lab in Bangalore. He has 12 years of experience with IBM. He develops new features and nodes for IBM Integration Bus, and provides consultancy on IBM Integration Bus Proofs of Concept, EAI design, and implementation for customers in India and the Asia-Pacific region. You can contact Abhinav at pabhinav@in.ibm.com.



Ravi SK Sinha (ravssinh@in.ibm.com), Software Engineer, IBM

Photo of Ravi SinhaRavi SK Sinha is a Software Engineer with four years of experience in IBM product development and support. He currently works on the WebSphere MQ JMS Level-3 Support team. You can contact Ravi at ravssinh@in.ibm.com.



11 September 2013

Introduction

IBM® WebSphere® MQ is a middleware product that enables independent and non-concurrent applications on a distributed system to communicate with each other using messages. WebSphere MQ emphasizes reliability, and provides assured one-time delivery of messages across a wide variety of IBM and non-IBM platforms.

IBM® Tivoli® Directory Server, hereafter called TDS, provides a reliable platform for enterprise security initiatives. It uses Lightweight Directory Access Protocol (LDAP) to provide a trusted identity data infrastructure for authentication as well as high availability.

A standalone Java™ Messaging Service (JMS) client can connect to a WebSphere MQ queue manager in various ways. The most common practice is for the client to use a Java Naming and Directory Interface (JNDI) binding file for lookup and authentication. However, in a high-volume transaction environment, the number of entries in the binding file is dependent on the number of WebSphere MQ objects, which can reduce the reliability, scalability, and performance of the entire setup. TDS enables you to overcome these shortcomings, and this article shows you how to set up TDS to connect a JMS application with WebSphere MQ for authentication and lookup.

Prerequisites

To benefit from this article, you should have some experience with JMS coding, and you should have installed:

  • WebSphere MQ V6.0 or later on any supported platform
  • TDS V6.3 or later on any supported platform

If you are installing WebSphere MQ and TDS on different systems, ensure that they are within same network and reachable from one another. In the example in this article, the installations are on different Microsoft® Windows® servers.

Configuring the WebSphere MQ queue manager

  1. Create and start a queue manager, for example QM1.
  2. Create a queue, for example Q1.
  3. Define and start a listener. Port 1414 is used in this example.
  4. Enter the following queue manager setup commands:
    crtmqm QM1
    strmqm QM1
    runmqsc QM1
    define qlocal (Q1)
    define listener (L1) trptype(TCP) port(1414)
    start listener (L1)

Configuring TDS

  1. Create a suffix Distinguished Name (DN) of type organisation, for example o=test, as shown in Figures 1 and 2:
    Figure 1. Suffix in TDS Configuration Tool
    Suffix in TDS Configuration Tool

    Figure 2. Organisation object in TDS Administration GUI
    Organisation object in TDS Administration GUI
  2. Create two javaContainer objects, one for queue connection factory (qcf), and one for queue (destination). You can do this task in three different ways: TDS commands, the TDS administration GUI, or the WebSphere MQ JMSAdmin tool, as used in this example. In a text editor, open the JMSAdmin.config file from the /bin directory of the WebSphere MQ JMS installation directory. Remove the comment symbols from the following entries to define the LDAP context with appropriate values:
    INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
        The LDAP context factory.
    PROVIDER_URL=ldap://localhost/o=test
        The LDAP server and context.
    SECURITY_AUTHENTICATION=simple
        Simple authentication mode.
    PROVIDER_USERDN=cn=root
        User distinguished name.
    PROVIDER_PASSWORD=password
        Password for the user distinguished name.
    USE_INITIAL_DIR_CONTEXT=TRUE
        Initial directory context.
  3. Start the JMSAdmin tool by running the following command:
    JMSAdmin -t -v -cfg JMSAdmin.config
  4. Define the queue connection factory by running the following command, where qcf is an example queue connection factory name:
    define qcf(qcf) host(localhost) port(1414) transport(client) qmanager(QM1)
  5. Define a JMS queue that is based on a physical queue in the QM1 queue manager by running the following command, where Q1 is an example JMS queue name:
    define q(queue) queue(Q1) qmanager(QM1)
  6. Now you should see the two entries of type javaContainer created under the o=test object, as shown in Figure 3:
    Figure 3. javaContainer object in TDS Administration GUI
    javaContainer object in TDS Administration GUI

Code snippets of JMS application to look up JMS objects in TDS

In this line of code, the initial context factory is initialised with the LDAP service provider:

static String icf = "com.sun.jndi.ldap.LdapCtxFactory";

This line of code initialises the URL of the service provider's initial context. In this case, it points to the root context of the TDS server instance:

static String url = "ldap://<TDS_Server_IP_Address>:<TDS_Server_Instance_Port_Number>/o=test";

This line of code assigns the connection factory reference cf to an object after a lookup of connection information in TDS:

ConnectionFactory cf = (QueueConnectionFactory)ctx.lookup("cn=qcf");

This line of code assigns the destination queue reference destq to an object after a lookup of the destination queue in TDS:

Queue destq = (Queue)ctx.lookup("cn=queue");

Using the link below, you can download a sample JMS application that puts a message to a queue using TDS lookup.


Download

DescriptionNameSize
Sample JMS ApplicationSampleJMSApplication.zip1 KB

Resources

  • WebSphere MQ resources
  • IBM Tivoli Directory Server resources
  • WebSphere resources
    • developerWorks WebSphere
      Technical information and resources for developers who use WebSphere products. developerWorks WebSphere provides downloads, how-to information, support resources, and a free technical library of more than 2000 technical articles, tutorials, best practices, IBM Redbooks, and online product manuals.
    • developerWorks WebSphere application integration developer resources
      How-to articles, downloads, tutorials, education, product info, and other resources to help you build WebSphere application integration and business integration solutions.
    • Most popular WebSphere trial downloads
      No-charge trial downloads for key WebSphere products.
    • WebSphere forums
      Product-specific forums where you can get answers to your technical questions and share your expertise with other WebSphere users.
    • WebSphere demos
      Download and watch these self-running demos, and learn how WebSphere products can provide business advantage for your company.
    • WebSphere-related articles on developerWorks
      Over 3000 edited and categorized articles on WebSphere and related technologies by top practitioners and consultants inside and outside IBM. Search for what you need.
    • developerWorks WebSphere weekly newsletter
      The developerWorks newsletter gives you the latest articles and information only on those topics that interest you. In addition to WebSphere, you can select from Java, Linux, Open source, Rational, SOA, Web services, and other topics. Subscribe now and design your custom mailing.
    • WebSphere-related books from IBM Press
      Convenient online ordering through Barnes & Noble.
    • WebSphere-related events
      Conferences, trade shows, Webcasts, and other events around the world of interest to WebSphere developers.
  • developerWorks resources
    • Trial downloads for IBM software products
      No-charge trial downloads for selected IBM® DB2®, Lotus®, Rational®, Tivoli®, and WebSphere® products.
    • developerWorks business process management developer resources
      BPM how-to articles, downloads, tutorials, education, product info, and other resources to help you model, assemble, deploy, and manage business processes.
    • developerWorks blogs
      Join a conversation with developerWorks users and authors, and IBM editors and developers.
    • developerWorks tech briefings
      Free technical sessions by IBM experts to accelerate your learning curve and help you succeed in your most challenging software projects. Sessions range from one-hour virtual briefings to half-day and full-day live sessions in cities worldwide.
    • developerWorks podcasts
      Listen to interesting and offbeat interviews and discussions with software innovators.
    • developerWorks on Twitter
      Check out recent Twitter messages and URLs.
    • IBM Education Assistant
      A collection of multimedia educational modules that will help you better understand IBM software products and use them more effectively to meet your business requirements.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=944790
ArticleTitle=Connecting JMS applications with WebSphere MQ using Tivoli Directory Server
publish-date=09112013