Skip to content

Keyword

messageActor

Back to Index
      
messageActor( actorType: text actorId: uuid|text messages: [{ type: text alias: text | nothing body: value }] preview: boolean | nothing ): { actorId: uuid paths: [text] data: { `[type or alias]`: value } errors: [Error] preview: boolean } | Error

The messageActor function enables messaging Actors and receiving the response. Multiple messages can be sent in a single call, allowing preview of multiple messages in a single transaction. The messages are processed by the target actor in the order they are specified.

Availability

Discount Rule Reactor

Message Response

The return value contains information about the actor, whether the response was previewed or not, and the actual response values for each individual message (data)

The response data from the actor is a record where each field maps to the original message type (or alias if specified). Refer to the message reference for details of each message response type.

Error Handling

While message format and body is validated at compile-time, there are many reasons a message might fail. Therefor it’s recommended to handle Error responses separately.

Examples

From the Cookbook:

from orderState match
'pending' |> messageActor (
'order'
orderId
[{
type = 'applyCommands'
body = {
commands = [{
type = 'setOrderState'
orderState = 'cancelled'
}]
}
}]
)
'confirmed' |> 'Order is confirmed, no cancellation'
'cancelled' |> 'Order is already cancelled'
|> orderState
Back to Index