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|nothing paths: [text] data: { `[type or alias]`: value } errors: [Error] preview: boolean }

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

Multiple errors can occur during a single batch of messages, therefor inspect the error field in the response. Errors that are returned by the actor itself has a detail property fromMessage allowing you to infer which message caused the error.

Some errors, such as invalid actorId will result in the response actorId field being nothing.

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