MQ Connectivity scenario 5: Fan in per device request-reply

In this scenario, an Eclipse Amlen topic subtree is mapped to a IBM® MQ topic subtree for requests. The messages that are put on topics in the Eclipse Amlen topic subtree are forwarded to the equivalent IBM MQ topic subtree for requests. A different IBM MQ topic subtree is mapped to a Eclipse Amlen topic subtree for responses. Messages that are put on topics in the IBM MQ topic subtree are forwarded to the equivalent Eclipse Amlen topic subtree for responses.

Background to this scenario

This MQ Connectivity scenario extends the basic Eclipse Amlen fan-in per device request-reply end-to-end scenario.

In this scenario, the intranet store system is replaced by IBM MQ. Request messages are sent from the internet applications in the same way as the basic scenario. Eclipse Amlen forwards the messages on to IBM MQ topics. IBM MQ sends response messages to Eclipse Amlen, which are forwarded to the appropriate internet applications.

You must complete the steps in Scenario: Fan-in per device request-reply to set up the basic scenario before you implement the MQ Connectivity extension.

Planning and implementing the solution

Plan your solution
In this scenario, consider the following key points:
  • What type of destination mapping rule do you need?

    Destination mapping rules identify the source and destination of a message. The source is either an Eclipse Amlen topic, topic subtree, or queue, or a IBM MQ topic, topic subtree, or queue. Similarly, the destination is either an Eclipse Amlen topic, topic subtree, or queue, or a IBM MQ topic, topic subtree, or queue. For more information about the different rule types, see Configuring destination mapping rules.

    In this scenario, request messages are sent from many internet applications to many topics in a subtree. This subtree must be preserved when messages are forwarded. Therefore, the following rule is required: Eclipse Amlen topic subtree to IBM MQ topic subtree.

    Response messages are sent from many IBM MQ topics in a subtree. This subtree must be preserved when the messages are forwarded to Eclipse Amlen. Therefore, the following rule is also required: IBM MQ topic subtree to Eclipse Amlen topic subtree.

  • Is the order of messages important?

    If the order that messages arrive in is important to your solution, you must set up your solution in a particular way. If you use multiple queue managers to send messages, messages can be sent out of order. If you use multiple queue managers to receive messages, messages can be received out of order.

    However, IBM MQ cannot handle the same volume of messages as Eclipse Amlen. Therefore, in solutions that involve a high volume of messages, you can use multiple queue managers to ensure that a backlog of messages does not build up on Eclipse Amlen. If the message backlog reaches the maximum message count that is set on the destination mapping rule, messages cannot be sent until the backlog reduces.

    When messages are moved from IBM MQ to Eclipse Amlen, Eclipse Amlen forwards persistent messages within transactions, and forwards nonpersistent messages immediately. Therefore, nonpersistent messages can be forwarded before earlier persistent messages are forwarded within a transaction. In this case, message order is not preserved.

    When MQTT messages are moved from Eclipse Amlen to IBM MQ, Eclipse Amlen forwards QoS 1 and QoS 2 messages within transactions, and forwards QoS 0 messages immediately. Therefore, QoS 0 messages can be forwarded before earlier QoS 1 and QoS 2 messages are forwarded within a transaction. In this case, message order is not preserved.

    When JMS messages are moved from Eclipse Amlen to IBM MQ, Eclipse Amlen forwards both JMS persistent and nonpersistent messages within transactions. If a nonpersistent message has the ConnectionFactory property DisableACK set, the message is forwarded immediately. Therefore, nonpersistent JMS messages with DisableACK set can be forwarded before earlier JMS messages are forwarded within a transaction. In this case, message order is not preserved.

    In this scenario, the order in which request messages are received is not important, as each message is published to a separate topic. Therefore, multiple queue managers can be used to handle the volume of messages.

Write your applications
Continuing from the basic scenario, the internet applications are set up, and publish to the topic string Reservation/Request/clientID, where clientID specifies the client ID of the internet application. The internet applications are also set up to subscribe to the topic string Reservation/Response/clientID, where clientID specifies the client ID of the internet application.
For the IBM MQ applications, use the sample IBM MQ applications amqspub and amqssub.
Alternatively, you can write your own IBM MQ application. For more information about writing IBM MQ publish/subscribe applications, see Writing publish/subscribe applications in the IBM MQ documentation. For more information about writing IBM MQ queuing applications, see Writing a queuing application in the IBM MQ documentation.
Set up your infrastructure
  1. Set up IBM MQ:
    1. Create two queue manager to handle the messages. In this scenario, the queue managers are called ReserveQM1 and ReserveQM2. From the command line of the IBM MQ system, enter the following commands:

      crtmqm ReserveQM1

      strmqm ReserveQM1

      crtmqm ReserveQM2

      strmqm ReserveQM2

    2. Make a note of the IP address or host name of the IBM MQ system. These details are used when you create a queue manager connection.
    3. The following steps use MQSC commands, which must be run from an MQSC command prompt. From the command line, enter the following command to start MQSC for ReserveQM1:

      runmqsc ReserveQM1

    4. Create a server-connection channel for the queue manager. In this scenario, the server-connection channel is called MQ.MSG.SVRCONN. From the MQSC prompt, enter the following command:

      DEFINE CHANNEL(MQ.MSG.SVRCONN) CHLTYPE(SVRCONN) TRPTYPE(TCP)

    5. Start a listener for the queue manager. In this scenario, the listener is called ReserveQL, and listens on port 1414. From the MQSC prompt, enter the following commands:

      DEFINE LISTENER ('ReserveQL') TRPTYPE(TCP) CONTROL(QMGR) PORT(1414)

      START LISTENER ('ReserveQL')

    6. Authorize Eclipse Amlen to connect to the queue manager:
      1. Create a user ID on the IBM MQ system. In this scenario, the user ID is called MSGUSER.
      2. Create a channel authentication record that allows only the Eclipse Amlen IP address to use the server-connection channel that you created in step 1d. From the MQSC prompt, enter the following command:

        SET CHLAUTH(MQ.MSG.SVRCONN) TYPE(ADDRESSMAP) ADDRESS(IPAddress) MCAUSER('MSGUSER')

        Where:
        IPAddress
        Specifies the IP address of the Eclipse Amlen server.
      3. Grant general IBM MQ access to MSGUSER. From the MQSC prompt, enter the following commands:

        SET AUTHREC OBJTYPE(QMGR) PRINCIPAL('MSGUSER') AUTHADD(CONNECT, INQ, DSP)

      4. Grant authority for the user MSGUSER to issue requests to IBM MQ:

        SET AUTHREC PROFILE('SYSTEM.DEFAULT.MODEL.QUEUE') OBJTYPE(QUEUE) PRINCIPAL('MSGUSER') AUTHADD(DSP, GET)

        SET AUTHREC PROFILE('SYSTEM.ADMIN.COMMAND.QUEUE') OBJTYPE(QUEUE) PRINCIPAL('MSGUSER') AUTHADD(DSP, PUT)

      5. Grant authority for the user MSGUSER to create a queue for Eclipse Amlen synchronization records:

        SET AUTHREC PROFILE('SYSTEM.IMA.*') OBJTYPE(QUEUE) PRINCIPAL('MSGUSER') AUTHADD(CRT, PUT, GET, BROWSE)

        SET AUTHREC PROFILE('SYSTEM.DEFAULT.LOCAL.QUEUE') OBJTYPE(QUEUE) PRINCIPAL('MSGUSER') AUTHADD(DSP)

    7. Create the IBM MQ topic objects, and grant specific authorities to allow Eclipse Amlen to access the topics. In this scenario, the request topic object is called ReserveRequest and requires SUB, CTRL authority. The response topic object is called ReserveResponse and requires PUB, DSP authority. From the MQSC prompt, enter the following commands:

      DEFINE TOPIC('ReserveRequest') TOPICSTR('Reserve/Request')

      SET AUTHREC PROFILE('ReserveRequest') OBJTYPE(TOPIC) PRINCIPAL('MSGUSER') AUTHADD(SUB, CTRL)

      DEFINE TOPIC('ReserveResponse') TOPICSTR('Reserve/Response')

      SET AUTHREC PROFILE('ReserveResponse') OBJTYPE(TOPIC) PRINCIPAL('MSGUSER') AUTHADD(PUB, DSP)

    8. Repeat steps c to g for ReserveQM2. You must use a different port number in step e.
  2. Set up Eclipse Amlen:
    1. Create queue manager connections so that Eclipse Amlen can connect to the queue managers. In this scenario, Eclipse Amlen must connect to the ReserveQM1 and ReserveQM2 queue managers. From the Amlen WebUI:
      1. Go to the MQ Connectivity page by clicking Messaging > MQ Connectivity.
      2. Under the Queue Manager Connection Properties pane, click the Add icon.
      3. Enter the details for a queue manager connection, and click Save. In this scenario, the following values are used:
        • Name: ReserveQMC1
        • Queue Manager: ReserveQM1
        • Connection Name: The IP address or host name of the IBM MQ system on which the queue manager was configured.
        • Channel Name: MQ.MSG.SVRCONN
      4. Create a second queue manager connection in the same way. In this scenario, the following values are used:
        • Name: ReserveQMC2
        • Queue Manager: ReserveQM2
        • Connection Name: The IP address or host name of the IBM MQ system on which the queue manager was configured.
        • Channel Name: MQ.MSG.SVRCONN
    2. Create destination mapping rules to map from the message sources to the message destinations. In this scenario, the first destination mapping rule must map from the Eclipse Amlen topic subtree Reserve/Request to the IBM MQ topic subtree Reserve/Request. With this rule, a message that is published on the Eclipse Amlen topic Reserve/Request/123 is forwarded to the IBM MQ topic Reserve/Request/123. The second destination mapping rule must map from the IBM MQ topic subtree Reserve/Response to the Eclipse Amlen topic subtree Reserve/Response. From the Amlen WebUI:
      1. Go to the MQ Connectivity page by clicking Messaging > MQ Connectivity.
      2. Under the Destination Mapping Rules pane, click the Add icon.
      3. Enter the details for the first destination mapping rule, and click Save. In this scenario, the following values are used:
        • Name: RequestDMR
        • Rule Type: Amlen topic subtree to MQ topic subtree
        • Source: Reserve/Request
        • Destination: Reserve/Request
        • Maximum Messages: 10000
        • Associated queue manager connections: ReserveQMC1, ReserveQMC2
        • Enabled: True
      4. Create the second destination mapping rule in the same way. In this scenario, the following values are used:
        • Name: ResponseDMR
        • Rule Type: MQ topic subtree to Amlen topic subtree
        • Source: Reserve/Response
        • Destination: Reserve/Reseponse
        • Maximum Messages: 10000
        • Associated queue manager connections: ReserveQMC1, ReserveQMC2
        • Enabled: True
  3. Optionally, delete the connection and messaging policies Stock Reservation Internal ConPol, Stock Reservation Request Internal MsgPol, and Stock Reservation Response Internal MsgPol. TheMQ Connectivity process does not need a connection policy to connect to Eclipse Amlen. TheMQ Connectivity process uses the information that is contained in the destination mapping rules to restrict messaging activities, and therefore does not need messaging policies.
Test your solution
Use your applications to send test messages through the system and check that the solution works. Use the Troubleshooting section to help you resolve any problems that you encounter.
Monitor your solution
Use the monitoring tools from the basic scenario to monitor the solution.
Strengthen your security
Beyond the security enhancements that can be completed in the basic scenario, you can use SSL to secure the connection between Eclipse Amlen and IBM MQ. To use SSL to secure the connection, you must configure key repository databases and password stash files. For more information, see Configuring MQ Connectivity security by using CA certificates and Configuring MQ Connectivity security by using self-signed certificates.