EVENT_PUBLISH (Publish Event to Queues)

Publishes an event to one or more message queues. After EVENT_PUBLISH creates the event and delivers it to a message queue, the Event Broker then retrieves the event and distributes it to other applications. EVENT_PUBLISH supports event delivery to IBM WebSphere MQ and MSMQ destinations.

Syntax

CALL EVENT_PUBLISH(eventId, publishType, rc, properties,
<propValue1, …propValueN> , queue1 <, …queueN> );

Required Arguments

eventID
specifies the event that is to be published.
Type:Numeric, Input
publishType
specifies how to publish the event. To publish the event by using the queue transport, specify a publishType of TO_QUEUE.
Type:Character, Input
rc
receives a return code.
Type:Numeric, Output
properties
identifies a comma-separated list of optional property names. Specify any of the following property names, or specify double quotation marks to indicate that no properties are to be applied:
  • QUEUE_TIMEOUT
  • RESPONSE_QUEUE
  • SELECTOR
Type:Character, Input
queue1 <, …queueN>
character string that specifies the queue(s) that will be used to publish the event. When publishing to MSMQ queues, use the following syntax:
MSMQ://queueHostMachineName\queueName
When publishing to IBM WebSphere MQ queues, use the following syntax:
MQSERIES://queueManager:queueName
or
MQSERIES-C://queueManager:queueName
MQSERIES specifies the server interface that is used to connect to a queue manager that is local. MQSERIES-C specifies the client interface that is used, allowing the queue manager to be local or remote.
Type:Character, Input

Optional Argument

propValue1, …propValueN
specifies one value for each specified property name. The order of the property values must match the order of the property names in the properties parameter. A value must be specified for each property that is specified in the properties parameter. Valid property values are defined as follows:
QUEUE_TIMEOUT specifies the poll time-out value in seconds. If the event expects a result or acknowledgment response, then the response queue identifies the queue to receive the response. By default, the EVENT_PUBLISH CALL routine continues to poll until the response is received or until a 15-second time-out occurs. You can override the default time-out value by specifying an explicit queue time-out value. The value must be greater than zero.
RESPONSE_QUEUE used by the Event Broker, it specifies the name of a queue to receive the result or an acknowledgment. After the event is published, the queue is queried for the response, which is written to a target file that is specified by the RESULT_URL property value.
SELECTOR specified on the CALL routine, it identifies the name/value properties to define on the event messages that are published. These properties can be used by the Event Broker to determine what messages should be removed from the queue. The Event Broker can be configured so that it removes only messages from the queue that match particular name/value selectors. If the Event Broker configures selectors, then only messages that have properties that match the configured selector are delivered to the Event Broker. Other messages remain on the queue.
Type:Character or Numeric, Input

Details

If you specify multiple queues, and if you specify the RESPONSE property in the EVENT_BEGIN CALL routine, then the response is received and processed only for the queue that you specified first. The event is published to the first queue, and the response is written to the RESULT_URL location. For all remaining queues, the event is published, but the EVENT_PUBLISH CALL routine does not query the response queue for a result. To process results from multiple queues, issue EVENT_PUBLISH for each queue. Executing an EVENT_PUBLISH for each queue creates an explicit RESULT_URL for each response.

Examples

Example 1: Publishing an Event to a Queue

The following example publishes the event to one queue and does not apply any additional queue properties.
publishType = "TO_QUEUE";
firstQ = "MQSERIES://PCONE:MYQ";
CALL EVENT_PUBLISH(eventId,
   publishType, rc, '', firstQ);

Example 2: Using EVENT_PUBLISH with the RESPONSE_QUEUE Property

The following example publishes the event to one queue. Because a response is expected, the RESPONSE_QUEUE property and a time-out value of 30 seconds are specified. If the response is not received in 30 seconds, a time-out occurs.
publishType = "TO_QUEUE";
firstQ = "MQSERIES://PCONE:MYQ";
prop="RESPONSE_QUEUE, QUEUE_TIMEOUT";
respQ = "PCONE:MYQ";
timeout = "30";
CALL EVENT_PUBLISH(eventId, publishType, rc,
   prop, respQ, timeout, firstQ);

Example 3: Using EVENT_PUBLISH with the SELECTOR Property

The following example publishes the event to one queue. The SELECTOR property is used in this example to publish only event messages that are fourth quarter reports from the HR department. The value of the SELECTOR property should be one or more name/value pairs.
publishType = "TO_QUEUE";
firstQ = "MQSERIES://PCONE:MYQ";
prop="SELECTOR";
propValue="type=report quarter=four dept=hr";
qName="MQSERIES://QMGR:LocalQ";
CALL EVENT_PUBLISH(packageId, "TO_QUEUE",
   rc, prop, propValue, qName);