Configuring a dynamic MQ endpoint using WebSphere ESB and WebSphere Service Registry and Repository

This article shows you how to configure a WebSphere MQ endpoint in WebSphere Service Registry and Repository that will be dynamically selected at runtime from within a WebSphere ESB mediation module.

Share:

Dave A. Krier (dakrier@us.ibm.com), WebSphere Solutions Architect, IBM

Photo of Dave KrierDave Krier is a WebSphere Solutions Architect specializing in WebSphere BPM and ESB technologies. He has over 10 years of experience working with a variety of IBM and non-IBM software products. Currently, he consults on a daily basis with IBM customers in the areas of business process development, implementation, and integration. You can contact Dave at dakrier@us.ibm.com.



22 February 2012

Also available in Chinese

Introduction

This article shows you how to configure an IBM® WebSphere® MQ endpoint in WebSphere Service Registry and Repository that will be dynamically selected at runtime from within a WebSphere ESB mediation module. The mediation module uses the native Endpoint Lookup primitive to query WebSphere Service Registry and Repository for an endpoint using elements from the service message object (SMO) that is flowing through the ESB. This approach promotes business flexibility by enabling the MQ endpoints to be managed in a central repository outside of the ESB. While governance of the endpoint is outside the scope of this article, it is a best practice to apply governance policies and classifications to the endpoints registered in the repository.

Environment for this article

  • WebSphere MQ V7.0.0.1
  • WebSphere Service Registry and Repository V7.0.0.3
  • WebSphere Integration Developer V7.0.1
  • WebSphere ESB

WebSphere MQ configuration

Create three new local queues.

  1. Open WebSphere MQ Explorer.
  2. Assuming a queue manager is already configured, create three new local queues named queue1, queue2, and queue3, and accept all default configurations:
    Figure 1
    Figure 1
    Figure 2
    Figure 2
    Figure 3
    Figure 3
  3. Repeat these steps for the next two queues. Note the queue manager name and port number used to connect to the queue manager:
    Figure 4
    Figure 4
    Figure 5
    Figure 5

Finding the queue manager port number

  1. Right-click on the queue manager name and select Properties. MB7QMGR is the name of my queue manager:
    Figure 6
    Figure 6
  2. Click on TCPIP to identify the port number for the queue manager. Take note of this number and click Cancel:
    Figure 6
    Figure 7

WebSphere MQ service definition

WebSphere MQ V7 provides a Service Definition Wizard in WebSphere MQ Explorer, which enables creation of WSDL for WebSphere MQ applications. This wizard helps you create MQ WSDL using MQ service bindings, and generates the WSDL document based on MQ service definitions and MQ IRI specifications. The following steps show how to create an MQ WSDL document for a WebSphere MQ application using the Service Definition Wizard. Before generating a WSDL document, you need to create a Service Definition Repository in which to store MQ service definitions.

  1. Right-click Service Definition Repositories and click Add Repository:
    Figure 8
    Figure 8
  2. Enter the name of the new Service Definition Repository and click Finish:
    Figure 9
    Figure 9
  3. Right-click the MyWMQServices repository and select Service Definition:
    Figure 10
    Figure 10
  4. Enter the name of the Service Definition as MQService_Port, select a Message Exchange Pattern of One-Way, and then select Next:
    Figure 11
    Figure 11

    A Message Exchange Pattern describes the message pattern required by the MQ application for which the WSDL document is being generated. MQ service definitions support both Request-Response and One-Way message exchange patterns, and the choice depends on the application.

  5. Set the binding type as MQ and select Next:
    Figure 12
    Figure 12

    MQ service bindings support both native MQ and SOAP/MQ binding types, depending on whether the application expects a WebSphere MQ message or a SOAP message.

  6. Provide an operation name of putMsg:
    Figure 13
    Figure 13
  7. Provide an Input Destination of msg/queue/queue1 as the name and (your queue manager name), and then click Finish:
    Figure 14
    Figure 14
  8. Click Finish to create the service definition.

This process creates a WSDL service definition, which you will load into WebSphere Service Registry and Repository to create the WSDL port and associated interface definition.

WebSphere Service Registry and Repository endpoint configuration

WebSphere Service Registry and Repository supports the WebSphere MQ Service Definition WSDL document through the WebSphere MQ integration feature, which is used to load WebSphere MQ WSDL documents into WebSphere Service Registry and Repository. Starting with V6.3, WebSphere Service Registry and Repository provides this feature in the default Governance Enablement Profile. You can enable this feature in any profile -- for details, see Enabling the WebSphere MQ integration feature into an existing profile in the WebSphere Service Registry and Repository information center.

When a WebSphere MQ WSDL document is loaded into WebSphere Service Registry and Repository, it automatically builds:

  • The WSDL logical port object on which the MQ queue and connection were specified in the MQ WSDL document, along with relationships between queue managers, queues, and connections
  • Representations of the queue managers
  • Representations of the queues and connections

First you must export the service definition from WebSphere MQ, then load the WSDL file into WebSphere Service Registry and Repository.

Exporting the WebSphere MQ service definition using WebSphere MQ Explorer

  1. From the Service Definition repository, right-click the WebSphere MQ Service Definition that needs to be exported and click Export:
    Figure 15
    Figure 15
  2. Select the newly created service definition, populate the destination for the file, and click OK:
    Figure 16
    Figure 16

    The WSDL file is exported to the destination you choose, so that it can be loaded into WebSphere Service Registry and Repository.

Loading the service definition into WebSphere Service Registry and Repository

  1. Open WebSphere Integration Developer and create a new workspace.
  2. Start the WebSphere ESB Server.
  3. Open the WebSphere Service Registry and Repository Admin Console at http://localhost:9080/ServiceRegistry (the server name and port may be different on your machine).
  4. After you log in to the Administrator Perspective, browse to the where you stored the service definition WSDL document that you exported from MQ Explorer, and click OK to load it:
    Figure 17
    Figure 17
    Figure 18
    Figure 18

With the WebSphere MQ integration feature enabled, when loading the WSDL document, WebSphere Service Registry and Repository automatically parses the WebSphere MQ WSDLs and builds the MQ entities from the service definition. You can view the MQ entities that are created using the Development and SOA Governance perspectives in the Governance Enablement Profile. After loading the MQ service definition WSDL document, you need to do a few additional configuration steps to prepare WebSphere Service Registry and Repository for use with the WebSphere ESB Endpoint Lookup primitive.

In WebSphere Integration Developer V7.0 and WebSphere ESB V7.0 or later, the Endpoint Lookup primitive only supports manual MQ endpoints with Associated Interface, as described in the WebSphere Integration Developer information center under Endpoint Lookup mediation primitive. This information center topic includes some important details, so please read through it and pay special attention to the areas highlighted below.

  • Figure 19
    Figure 19

Configuring manual MQ endpoint with Associated Interface

  1. Log into the WebSphere Service Registry and Repository Admin Console as an administrator.
  2. Select Administrator perspective.
  3. Select Manual MQ Endpoint with Associated Interface in the Business Objects section:
    Figure 20
    Figure 20
  4. Select New to add a new endpoint:
    Figure 21
    Figure 21
  5. Fill out the information as described below and select Add WSDL Port Type:
    Figure 22
    Figure 22
    1. Name: Give your endpoint a unique meaningful name.
    2. Name Space: Enter a unique meaningful namespace.
    3. Version: Since this is a new endpoint, start with V1.0.
    4. Endpoint: The WebSphere MQ URI, which must be correct. It is the returning value of the query, which will be passed to the MQ Import.

    The format of the WebSphere MQ URI is described below:

    Figure 23
    Figure 23
  6. Add WSDL Port Type. Put an asterisk in the search field to query WebSphere Service Registry and Repository for all valid WSDL port types. Select the port type that you imported from the MQ service definition WSDL. Select MQService_Port_PortType and click Add:
    Figure 24
    Figure 24
  7. Click Finish to complete the setup.
    Figure 25
    Figure 25
  8. Repeat these steps for the remaining two queue definitions giving each endpoint a unique name. Once completed, you should see three manual MQ endpoints:
    Figure 26
    Figure 26

Adding a custom property to each of the endpoints

  1. Select the first endpoint in the list, My_Manual_MQ_Endpoint1_WI, which is associated with queue1.
  2. At the upper right, select Edit Properties:
    Figure 27
    Figure 27
  3. Expand the Additional Properties section and select Add Property:
    Figure 28
    Figure 28
  4. Add a property named queue:
    Figure 29
    Figure 29
  5. Add a value of queue1 to property.

Repeat these steps for the remaining two queues. You have now completed the setup of the MQ endpoints in WebSphere Service Registry and Repository.

Configuring WebSphere ESB runtime

Check the configuration of the WebSphere Admin Console to ensure that WebSphere Service Registry and Repository is configured to communicate correctly with WebSphere ESB properly. For details, see Endpoint Lookup mediation primitive in the WebSphere Integration Developer information center where it talks about how to configure the connection to WebSphere Service Registry and Repository, as highlighted below:

  • Figure 30
    Figure 30
  1. Log in to the WebSphere Application Server Admin Console with administrator privileges.
  2. Under Service Integration, navigate to the WebSphere Service Registry and Repository Definitions link:
    Figure 31
    Figure 31
  3. If properly configured, you should see a WebSphere Service Registry and Repository definition. Yours may be named differently, but that's okay. Select the link for it:
    Figure 32
    Figure 32
  4. Click on Connection Properties:
    Figure 33
    Figure 33
  5. Make sure the URL is correct (your server name and port may be different):
    Figure 34
    Figure 34

Creating a new mediation module

Create a new mediation module project and configure the mediation to query WebSphere Service Registry and Repository for an MQ endpoint. The query will include content from the SMO to ensure that you select the correct MQ destination queue.

  1. Create a new mediation module project.
  2. Create a new interface with a one-way operation, as shown below:
    Figure 35
    Figure 35
  3. Add a new Import to the assembly diagram and associate it with the newly created interface.
  4. Configure the Import with MQ bindings and provide it with the connection details shown below. You must supply valid connection information on the Properties pane, but it will be overridden by the information that is returned back from WebSphere Service Registry and Repository:
    Figure 36
    Figure 36
  5. Associate the interface with the mediation:
    Figure 37
    Figure 37
  6. Wire the mediation flow to the MQ Import:
    Figure 38
    Figure 38
  7. Double-click the mediation flow SCA component to generate an implementation.
  8. Click on the operation name to open up the message flow diagram:
    Figure 39
    Figure 39
  9. Add an Endpoint Lookup primitive to the message flow diagram and configure it as shown below:
    1. On the Details Tab, provide the Port Type Name and Registry Name, which is the name of the WebSphere Service Registry and Repository definitions in the WebSphere Application Server Admin Console.
    2. Set the Match Policy to return the first match.
    3. Set the Binding Type to return All Binding Types:
      Figure 40
      Figure 40
  10. Click on the Advanced section and add a new User Property. Set the Type to XPATH, so that you can pull the value from the SMO. For the Value, use the relative path to the field in the SMO. As you edit this value, an XPATH Wizard will build the XPATH expression for you:
    Figure 41
    Figure 41
  11. Add two Trace nodes to the message flow to show what WebSphere Service Registry and Repository has returned. No need to modify any of the properties. Wire them up as shown below:
    Figure 42
    Figure 42
  12. Add a Service Invoke primitive and configure it as shown below. Make sure to select the checkbox to enable a dynamic endpoint. If WebSphere Service Registry and Repository returns an endpoint and places it in the header address, the values defined in the associated MQ Import will be overridden:
    Figure 43
    Figure 43

Testing

  1. Right click on the message flow SCA component and click Test Component:
    Figure 44
    Figure 44
  2. Add the value queue3 or any of the valid queue names. The queue name will be used in the WebSphere Service Registry and Repository query from the Endpoint Lookup. You can change the queue name and it will affect the WebSphere Service Registry and Repository query, returning a different endpoint:
    Figure 45
    Figure 45
  3. If successful, you should see the wmq URL address in the target/address field. You can now check the queue to see the message in the queue.
  4. The default message expiration is usually set to a low value, so the message will likely expire after a few minutes. Check the queue depth right after the test to ensure that the message has arrived on the correct queue:
Figure 46
Figure 46

For more information, see Dynamic invocation with wired MQ import, using SMO in the WebSphere ESB information center:

See also Endpoint Lookup mediation primitive in the WebSphere Integration Developer information center:

Resources

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 Business process management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Business process management, WebSphere
ArticleID=794421
ArticleTitle=Configuring a dynamic MQ endpoint using WebSphere ESB and WebSphere Service Registry and Repository
publish-date=02222012