Skip to main content

Sending Request Messages

Sending Request Messages

In your business service class, your implementation of OnProcessInput() should send a request message to some destination within the production. To do so, call one of the following instance methods of the business service class, as appropriate for your needs:

Each of these methods returns a status, an instance of %StatusOpens in a new tab.

These methods are also defined — with the identical method signatures — in Ens.BusinessProcessOpens in a new tab and Ens.BusinessOperationOpens in a new tab, although their internals are different in those classes. This means that you can invoke these instance methods from within your business process and business operation classes.

Using the SendRequestSync() Method

To send a synchronous request, use the SendRequestSync() method as follows:

  Set tSC = ..SendRequestSync(pTargetDispatchName, pRequest, .pResponse, pTimeout)

Where:

  • pTargetDispatchName — The configuration name of the business process or business operation to which the request is sent.

  • pRequest — A request message. See Defining Messages.

  • pResponse — (By reference) A response message. This object receives the data returned by the response.

  • pTimeout — (Optional) The number of seconds to wait for a response. The default is –1 (wait forever).

This method returns a status, an instance of %StatusOpens in a new tab.

If no response is expected, you can use SendRequestAsync() instead of SendRequestSync().

Using the SendRequestAsync() Method

To send an asynchronous request, use the SendRequestAsync() method as follows:

  Set tSC = ..SendRequestAsync(pTargetDispatchName, pRequest)

Where:

  • pTargetDispatchName — The configuration name of the business process or business operation to which the request is sent.

  • pRequest — A request message. See Defining Messages.

This method returns a status, an instance of %StatusOpens in a new tab.

Using the SendDeferredResponse() Method

All business hosts support the SendDeferredResponse() method. This method permits a business host to participate in the production deferred response mechanism. The business host identifies a previously deferred request, creates the actual response message, and sends this response to the business host that originated the request. See Using Deferred Sending in Programming in InterSystems IRIS.

This topic describes the role of a business service in this mechanism. Suppose an incoming event arrives in a production along with a deferred response token, and suppose the arrival point for this event is a business service. This business service then calls SendDeferredResponse() to create a response and direct it to the caller that originated the request. The SendDeferredResponse() call looks like this:

   Set sc = ..SendDeferredResponse(token, pResponseBody)

Where:

  • token — A string that identifies the deferred response so that the caller can match it to the original request. The business service obtains the token string through some mechanism unique to the production.

    For example, if the external destination is email, when sending a request for which it is willing to receive a deferred response, a business operation can include the token string in the subject line of the outgoing email. The entity receiving this email can extract this token from the request subject line and use it in the response subject line. This preserves the token so that the business service receiving the response email can use it in a subsequent call to SendDeferredResponse().

  • pResponseBody — A response message. This object receives the data returned by the response. See Defining Messages.

This method returns a status, an instance of %StatusOpens in a new tab.

FeedbackOpens in a new tab