Tutorial4b (Old Sport Spotting)

Tutorial4b is a slightly altered version of Tutorial4, with a notify and a consume instead of the solicit/response, and an additional service implementing the consume.

The main difference in this tutorial is that besides the Bartender service we have an additional service, JayGatsby.

As in the case of Tutorial2, you use a notify and a consume operation to treat this service to a gin and tonic.

You again send the single flag field, ORDER, to SPARKL to start the transaction.

This time, however, ORDER is output via a notify operation.

The gin and tonic fields are consumed by the JayGatsby service through the Drink consume operation.

The mix

The mix comprises a notify operation, two request/reply operations and a consume operation.

The Sequencing Graph is derived from all the operations in the mix.

The mix has the following components:

Sequencer
Sequencer, a service provisioned using the Sequencer extension processes the transaction starting with the initial operation.
Bartender
A service provisioned using the Expressions extension. It supports the request/reply operations and is invoked on demand by the Sequencer.
JayGatsby
A service provisioned using the Expressions extension. It supports the consume operation and is invoked on demand by the Sequencer.
Order
An operation comprising a notify, implemented by the Sequencer.
AddGin/Ok
An operation comprising a request with one possible reply, implemented by the Bartender service.
AddTonic/Ok
An operation comprising a request with one possible reply, implemented by the Bartender service.
Drink
An operation comprising a consume, implemented by the JayGatsby service.
ORDER
A flag field sent to and from the operations. A flag field has no value and serves only sequencing purposes.
gin, tonic
Fields sent to and from the operations. They contain data in the form of a string.
Client, Server
Folders separating operations. Folders are optional and can be used to separate various components of a mix.

Figure: Tutorial4b - The mix


Explanation

The Sequencing Graph generated by the operations of Tutorial4b is almost the same as the one in Tutorial4.

The only difference is that the first vertex is generated by the notify operation and the rightmost vertex satisfies a consume goal event, not a response.

Table 1 summarises the key components of the mix.

Table 1. Tutorial4b - Component roles
Component Markup Description
Order
<notify 
  name="Order" 
  service="Sequencer" 
  fields="ORDER"/>
Once it receives the single flag field ORDER, Sequencer creates a new transaction and uses the notify as its starting point.

The Sequencer determines that the goal closest to the starting point is the Drink consume.

This consume requires the two fields gin and tonic, neither of which yet exist.

Bartender
<service 
  name="Bartender" 
  provision="expr"/>
The Bartender service is the same as in Tutorial4.
AddGin
<request 
  name="AddGin" 
  service="Bartender" 
  fields="ORDER">
  <prop 
    name="expr.bind.out" 
    Gin="gin"/>
  <prop 
    name="expr.src"><![CDATA[
Gin = "Gordon's",
"Ok".
  ]]></prop>
  <reply 
    name="Ok" 
    fields="gin"/>
</request>
Invoked as in the case of Tutorial4.

Implemented by the Bartender service who, despite your valiant efforts, still has some gin and tonic in the stockroom.

AddTonic
<request 
  name="AddTonic" 
  service="Bartender" 
  fields="ORDER">
  <prop 
    name="expr.bind.out" 
    Tonic="tonic"/>
  <prop 
    name="expr.src"><![CDATA[
Tonic = "Schweppes",
"Ok".
  ]]></prop>
  <reply 
    name="Ok" 
    fields="tonic"/>
</request>
See above.
JayGatsby
<service 
  name="JayGatsby" 
  provision="expr">
  <prop 
    name="expr.state" 
    OldSportsSaid="NewOldSportsSaid"/>
  <prop 
    name="expr.src"><![CDATA[
NewOldSportsSaid = 0.
  ]]></prop>
</service>
The JayGatsby service has a state variable, OldSportsSaid, which can be updated by the NewOldSportsSaid state variable.

When the service is started, this variable is updated to 0 due to the content of the expr.src property.

Operations on the JayGatsby service can update this state variable too.

Drink
<consume 
  name="Drink" 
  service="JayGatsby" 
  fields="gin tonic">
  <prop name="expr.src"><![CDATA[
NewOldSportsSaid = OldSportsSaid + 1.
  ]]></prop>
</consume>
Due to the two request/reply operations, the Sequencer is able to supply gin and tonic in a single message.

When it implements the Drink consume to receive the fields, JayGatsby says "Old Sport".

In other words, the OldSportsSaid variable of the service is incremented by 1.