rcvMult/5 (io,io,io,io,io)
This built-in is a variant of the inline reaction predicate rcvMsg that allows for receiving multiple inbound messages as opposed to a single message as in rcvMsg. As in the case of rcvMsg, the engine does not block the current thread and simply adds the continuation corresponding to the current context goals and variables so that the execution picks up exactly where it left off when the matching message is detected. In the case of rcvMult, the original reaction continues processing other messages after the first one is detected.
The predicate is commonly used as an initiator of a workflow or event pattern detection. The example below waits for a creation of a market and then proceeds to further processing in clauses for the predicate server_1.
By default, the rcvMult inline reaction exists until the Prova agent is terminated. However, there is a way to abandon and purge this reaction.
In the above example from hohpe_dynamic_discovery.prova, the client sends a request for proposals with a payload containing some test data (19). It then asserts the record best representing the best offer received and in the first branch clause receives offers and updates the best record. In the second clause, it spawns an asynchronous wait for one second, prints the best offer, and uses a special termination message with command type eof that is intercepted by the rcvMult reaction that is then terminated.
This example is somewhat contrived as there are better ways to achieve the same result using reaction groups. Here is a solution from hohpe_using_groups.prova. The sorted accumulator collects all offers sorted by the offer values. If the @size(1) annotation was not added to the exit reaction @or, the outputs would have continued every second. The @size(1) output just one collection with the results and the exit reaction extracts that first result and prints the highest offer.