Consume

A consume is a goal of a transaction. It is satisfied once it receives the fields it expects.

Example XML code Notes

<consume 
  name="Iterate"
  service="Expr"
  fields="MAYBE div n">
  <prop 
    name="expr.bind.in" 
    Div="div" N="n"/>
  <prop 
    name="expr.bind.out" 
    NewDiv="div" N="n"/>
  <prop 
    name="expr.src" 
    content-type="text/x-erlang"><![CDATA[
    NewDiv = NextDiv(Div),
    "Ok".
  ]]></prop>
  <reply 
    name="Ok"
    fields="div n"/>
</consume>
A consume/reply can be used to allow for field mutability by creating a parallel thread of execution.

For example, every time Iterate is invoked, it creates a new thread of execution. The new thread makes it possible to add new values to the fields div and n, by effectively creating a new instance of these fields.

Note: The example is from a version of the Primes demo using the Expressions extension.

Attributes

A consume operation must have a name, a service that implements it, and some fields the operation asks for as input.

name

The name of the component. Other components use this name to reference the component.

service

The service that implements the operation. The implementing service is referenced by its name.

fields

A space-separated list of fields received or output by the operation subject. Depending on the type of operation, they can be input or output fields. The fields are referenced by their name.

Children

A consume optionally can take one or more replies as its children. Depending on the service specified for it, the consume can have one or more properties for additional functionality or field bindings too.

prop

A property defined for the component. For example, a Python or Erlang script. Most properties are specific to a SPARKL extension.

reply

A reply is a direct child of a consume operation. A reply must have a name and it has to reference one or more fields it uses to carry the newly-generated data.