Service groups

Service "groups" are a technique for grouping together Services where there is a need to run all the Services together.

Getting ready

Create or find an existing Service group definition XML document. This XML document will have an XML version declaration as follows:

<?xml version="1.0" encoding="UTF-8" ?>

And a Service group XML schema declaration as shown:

<service-group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://ofbiz.apache.org/dtds/service-group.xsd">

If creating a new Service group definition XML document, ensure that this document is configured in the containing Component's ofbiz-component.xml file. For example, if creating a Service group definition XML document in the servicedef directory, add a line similar to the following to the ofbiz-component.xml file:

<service-resource type="group" loader="main"
location="servicedef/groups.xml"/>

How to do it...

To group Services together, follow these steps:

  1. Add one or more group elements as shown here. Each group element defines a Service group:
    <group name="updateCreditCardAndAddress" send-mode="all"> </group>
    
  2. Within each group element, add one or more invoke declaration(s). Each invoke declaration points to a Service:
    <invoke name="createPostalAddress" mode="sync"
    result-to-context="true"/>
    <invoke name="createCreditCard" mode="sync"/>
    <invoke name="createPartyContactMech" mode="sync"/>
    
  3. Close each element with an end tag.
  4. Save the file.
  5. Restart OFBiz to make Service group definitions effective.

How it works...

Service groups are a set of Services that should all run as a result of the initial Service call. Unlike SECAs, where conditions and triggers determine which Services will be run during any particular invocation, Service groups are used to indicate that all Services within the group should be run. Note, it is possible to have Service groups with participating Services that have SECAs defined.

The following table provides some of the more often used Service group configuration elements. Attribute values include:

group tag

  

Attribute name

Required?

Description

name

Yes

The name of the Service this action will invoke.

send-mode

No

The mode in which the Service(s) should be invoked.

Valid values: "none", "all", "first-available", "random", "round-robin".

The default is "all".

To configure one or more Services within a group element declaration, add invoke elements configured as follows:

invoke tag

  

Attribute name

Required?

Description

name

No

The name of the Service this action will invoke.

mode

Yes

The mode in which this Service should be invoked. Can be sync or async. Note that async actions will not update the context even when set to true.

result-to-context

No

Should the results of the action Service update the main Service's context. Valid values: "true", "false".

Default is "false".

See also

Please refer to the Service group XML XSD schema file located at:

~framework/service/dtd/service-group.xsd

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.141.75