Service Event Condition Actions (SECAs) are a powerful tool used to build complex business processing solutions out of one or more OFBiz Service(s). With SECAs, you may associate one or more Services together to form a chain of processing logic based on defined triggering events and conditions.
There are no limits on the number of SECAs supported by OFBiz, or in the number of Services that may participate within a single SECA.
Writing SECAs is simple. To write a SECA, you will need one or more Services to participate as either the action
Service and/or the target
Service. Once you have your Services defined:
<?xml version="1.0" encoding="UTF-8" ?>
<service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://ofbiz.apache.org/dtds/service-eca.xsd">
Once the groundwork is laid, you can write SECAs by following these steps:
eca
element with a service
attribute similar to the following (Note: the following XML declarations are for illustration purposes only. Please substitute real values where appropriate):<eca service="eca_service_name" event="required_some_event_name" run-on-failure="optional_true_or_false" run-on-error="optional_true_or_false" type="optional_some_type" format="optional_some_format" >
condition
elements:<condition field-name="some_name" operator="operator_values" value="some_value" type="supported_types" />
set
elements as input parameters or to format an existing parameter:<set field-name="some_field" value="some_value" format="some_format" />
action
declarations. Each action
declaration calls a Service to perform some action as shown below. The Service called may have the same name as the ECA:<action service="some_service_to_call" mode="some_mode" run-as-user="optionally_set_to_a_user" />
eca service
element with an end tag.When a Service is called, the first thing the OFBiz Service Engine does, even before assigning a Service implementation engine, is to check for any defined ECAs. If one or more ECAs exists for a Service, each ECA is processed before the initial target Service is invoked.
Note: Some ECAs perform actions on the output of a Service. In such cases, while the ECA itself is processed before the call to the Service, actions defined within the ECA may be invoked after the target Service is run.
In this way, it is possible to combine together any number of Services using any combination of conditions and Events, and thus solve complex business problems using one or more discrete OFBiz Services.
3.21.248.162