Using IBM WebSphere MQ Adapters in Productions
Using the IBM WebSphere MQ Inbound Adapter
|
|
-
The queue manager to use.
-
The channel specification to use. This specification includes the name of the channel to use, the transport used by the channel, the server name (or IP address) that is running the IBM WebSphere MQ server, and the port.
-
The message queue to check.
-
A polling interval, which controls how frequently the adapter checks for new input.
-
When the adapter is initialized, it connects to the given queue manager and queue, using the given channel.
-
The adapter regularly executes its
OnTask() method, which retrieves a message from the queue (if a message is available). The polling interval is determined by the
CallInterval setting.
-
When the adapter retrieves a message, it does the following:
-
-
-
The internal
ProcessInput() method of the business service class executes. This method performs basic production tasks such as maintaining internal information as needed by all business services. You do not customize or override this method, which your business service class inherits.
-
The response message follows the same path, in reverse.
The following list describes the basic requirements of the business service class:
The following example shows the general structure that you need:
Class EMQS.Service Extends Ens.BusinessService
{
Parameter ADAPTER = "EnsLib.MQSeries.InboundAdapter";
Method OnProcessInput(pInput As EnsLib.MQSeries.Message,
pOutput As %RegisteredObject) As %Status
{
set tsc=$$$OK
//your code here
Quit tsc
}
}
Note:
Studio provides a wizard that you can use to create a business service stub similar to the preceding. To access this wizard, click
File > New and then click the
Production tab. Then click
Business Service and click
OK. Note that the wizard provides a generic input argument. If you use the wizard, InterSystems recommends that you edit the method signature to use the specific input argument needed with this adapter; the input argument type should be
EnsLib.MQSeries.Message.
Within your custom business service class, your
OnProcessInput() method should have the following signature:
Method OnProcessInput(pInput As EnsLib.MQSeries.Message,
pOutput As %RegisteredObject) As %Status
-
-
Create an instance of the request message, which will be the message that your business service sends.
-
For the request message, set its properties as appropriate, using values in the MQ message.
-
Each of these methods returns a status (specifically, an instance of
%Status).
-
Make sure that you set the output argument (
pOutput). Typically you set this equal to the response message that you have received. This step is required.
-
Return an appropriate status. This step is required.
-
Body The body of the message.
-
-
BodySize An integer that indicates the length of the message.
The following business service retrieves messages and forwards them to a business host named
EMQS.MessageProcessor.
Class EMQS.Service Extends Ens.BusinessService
{
Parameter ADAPTER = "EnsLib.MQSeries.InboundAdapter";
Method OnProcessInput(pInput As EnsLib.MQSeries.Message,
pOutput As EMQS.InboundMsg) As %Status
{
//create production message to carry the retrieved MQ message
Set inbound=##class(EMQS.InboundMsg).%New()
Set inbound.Body=pInput.Body
Set inbound.MessageId=pInput.MessageId
//forward this to the message processor
Set tsc=..SendRequestSync("EMQS.MessageProcessor",inbound,.response)
Set pOutout=response
Quit tsc
}
}
Class EMQS.InboundMsg Extends Ens.Request
{
Property Body As %String (MAXLEN="");
Property MessageId As %String(MAXLEN = 128);
}
To add your business service to a production, use the Management Portal to do the following:
-
Add an instance of your business service class to the production.
-
Enable the business service.
-
Configure the adapter to access an IBM WebSphere MQ queue and retrieve messages. Specifically:
-
Content Date/Time: 2019-02-17 22:48:09