Skip to end of metadata
Go to start of metadata

The guards mechanism in reactive messaging uses the general guard construct available in the Prova language (see Guards). We discuss here only the use of guards for individual, not Event Processing groups based, reactions.

When a Prova agent perceives an inbound message, a pattern match is attempted for all five position-based parts of the message, including the message payload. We are particularly interested in the case when the match is made with an inline reaction rcvMsg. Since rcvMsg can only accept one message, without the guards extension, matching the pattern would have immediately invalidated the reaction for any further matching, even if a condition that was following the reaction failed. Consider the following two examples:

post condition
pre condition (guard)

In the first case, even if the received message contained exactly the same IP2 as IP, the fact that this invalidates the condition would be detected too late, and finding another correctly qualifying inbound message would be impossible as the reaction would be satisfied and gone. In the second case, the guard is tested right after pattern matching but before the message is fully accepted, so that the net effect of the guard is really to serve as an extension of pattern matching for literals.

Another great use of guards is for extracting field values from the message payload, see Extracting payload fields using guards.

Labels: