Using dynamic WebSphere MQ endpoints

You can dynamically invoke services using WebSphere MQ import bindings. The import that you invoke is decided at run time and does not need to be wired directly to a component. During a dynamic invocation, you do not specify the endpoints that you use in the import bindings. If you use a mediation flow component, you can specify a target import and dynamic endpoint address using some mediation primitives. For example, the Message Element Setter mediation primitive to manipulate the Target section of the SMO.

Using a mediation flow component, you can specify a target import and dynamic endpoint address using mediation primitives such as the Message Element Setter mediation primitive.

Figure 1 shows a mediation module that includes an import, which is not wired to the mediation flow component. The import is configured to use Service Provider 1. Using the mediation flow component, the target import is specified in the SMO, and the unwired import is invoked. Other imports can be selected instead, if they are available. If you specify a target endpoint in the SMO, it overrides the imports reference to Service Provider 1, and replaces it with Service Provider 2. The service that is invoked at run time, is decided on a message by message basis.

Figure 1. Mediation module with an unwired import which is configured to use service provider 1Mediation module with an unwired import which is configured to use service provider 1
You can override the endpoint address or the target import using the Target and AlternateTarget sections of the SMO structure. The section of the SMO that you use to enable dynamic invocation is shown below:
  • /headers/SMOHeader/Target/address
  • /headers/SMOHeader/Target/@bindingType
  • /headers/SMOHeader/Target/@import
  • /headers/SMOHeader/AlternateTarget/address
  • /headers/SMOHeader/AlternateTarget/@bindingType
  • /headers/SMOHeader/AlternateTarget/@import

The address field includes the dynamic invocation target service URI for requests. When requests are routed, the @bindingType field provides further details about the URI. It indicates the type of binding that is used during a dynamic invocation. When requests are routed, the @import field provides the name of a target import that is used for dynamic invocation.

The WebSphere MQ endpoint that is used in the dynamic invocation, is structured according to the MQ URI standard. In summary, the standard requires that WebSphere MQ has the following form:
>>-wmq:--+------------+--+-------+--/msg/queue/--queueName-
         '-//hostname-'  '-:port-'  
-+-------+--+---------------------------+-><
  '-@qmgr-'  '-?connectQueueManager=qmgr-'   

In each URI, the queueName and optional destination queue manager, qmgr override the destination queue specified on the import binding. The hostname, port, and connectQueueManager, override the connection information on the import binding.

Examples of a valid WebSphere MQ URI are:

wmq:/msg/queue/queueName 
wmq:/msg/queue/queueName@qmgr
wmq://hostname/msg/queue/queueName
wmq://hostname/msg/queue/queueName@qmgr 
wmq://hostname:port/msg/queue/queueName
wmq://hostname:port/msg/queue/queueName@qmgr