Subroutines pattern

Subroutines can be used to construct a complex mix. A request or consume operation of a mix can be matched to another solicit or notify operation that starts a subroutine transaction.

In the example in Table 1, there are two mixes, both in the same configuration tree. A request/reply calls on a subroutine transaction.

Table 1. svc_subr - Subroutines
Example Description
<service name="Subr" 
  provision="subr"/>
<field name="a" type="string"/>
<field name="b" type="integer"/>
<mix name="Mix">
  <request name="myRequest" 
    fields="a" 
    service="Subr">
    <prop name="subr.spec" 
      function="MyFun" 
      Param1="a" 
      Param2="b"/>
    <reply name="Ok" 
      fields="b"/>
  </request>
</mix>
...
<field name="x" type="string"/>
<field name="y" type="integer"/>
<mix name="Mix">
  <solicit name="mySolicit" 
    service="Sequencer"
    clients="Subr" 
    fields="x">
    <prop name="subr.spec" 
      function="MyFun" 
      Param1="x" 
      Param2="y"/>
    <response name="Ok" 
      fields="y"/>
  </solicit>
</mix>
The request/reply can call on the subroutine solicit/response, that starts a subroutine transaction, because:
  1. The same svc_subr service supports the request/reply and is a client on the solicit/response
  2. The response and the reply are both named Ok
  3. The operations both have a subr.spec property that specifies:
    • The same function, MyFun
    • The same parameters, Param1 and Param2
  4. Each pair of fields mapped to the same parameter are of the same type:
    • Param1 is mapped to a and x, both of type string
    • Param2 is mapped to b and y, both of type integer