此内容没有您所选择的语言版本。

7.26. Exception Handling Examples


Time-out: If you are using the EsbActionHandler action and the node is awaiting a callback, you can limit the waiting period. To do so, add a timer to the node. (That is how Service1 is configured in the process definition snippet below.) The timer can be set for a certain period, in this case, ten seconds:
<node name="Service1">

  <action class=
    "org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
    <esbCategoryName>MockCategory</esbCategoryName>
      <esbServiceName>MockService</esbServiceName>
  </action>
  
  <timer name='timeout' duedate='10 seconds' 
    transition='time-out-transition'/>
  <transition name="ok" to="Service2"></transition>
  <transition name="time-out-transition" to="ExceptionHandling"/>

</node>
Copy to Clipboard Toggle word wrap
Service1 has two outgoing transitions. The first of these is ok whilst the second one is time-out-transition.
Normally the call-back will signal the default transition, which is ok , since it is defined as the first. However, if the processing of the service takes more then ten seconds, the timer will run instead. The timer's transition attribute is set to time-out-transition, meaning that this transition will be taken on timing-out.
The processing ends up in the ExceptionHandling node. From here, you can perform compensatory work.
Exception Transition: You can define an exceptionTransition to handle any exceptions that occurs in the midst of the service being processed. Doing so sets the faultTo endpoint reference on the message, meaning that the Enterprise Service Bus will make a call-back to this node. This signals the exceptionTransition.
Service2 has two outgoing transitions: the ok transition will be taken when things are happening normally, whilst the exception transition will be taken when the service has, as its name indicates, thrown an exception during processing:
<node name="Service2">
  <action class=
  "org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
     <esbCategoryName>MockCategory</esbCategoryName>
     <esbServiceName>MockService</esbServiceName>
     <exceptionTransition>exception</exceptionTransition>
   </action>
   <transition name="ok" to="Service3"></transition>
   <transition name="exception" to="ExceptionHandling"/>
</node>
Copy to Clipboard Toggle word wrap
In the preceding definition of Service2, the action's exceptionTransition is set to exception. In this scenario, the process itself also ends up in the ExceptionHandling node.
Exception Decision: Observe the configuration of Service3 and the exceptionDecision node that follows it. Service3 processes to a normal conclusion and the transition out of its node occurs as one would expect.
However, at some point during the service execution, an errorCode was set, and the exceptionDecision node checks if a variable of the same name has been called here:
<node name="Service3">
  <action class=
  "org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
     <esbCategoryName>MockCategory</esbCategoryName>
     <esbServiceName>MockService</esbServiceName>
     <esbToBpmVars>
        <mapping esb="SomeExceptionCode" bpm="errorCode"/>
     </esbToBpmVars>
  </action>
  <transition name="ok" to="exceptionDecision"></transition>
</node>
   
<decision name="exceptionDecision">
   <transition name="ok" to="end"></transition>
   <transition name="exceptionCondition" to="ExceptionHandling">
      <condition>#{ errorCode!=void }</condition>
   </transition>
</decision>
Copy to Clipboard Toggle word wrap
The esbToBpmVars mapping element extracts the errorCode called SomeExceptionCode from the message's body and sets in the JBPM context. (This is assuming that the SomeExceptionCode is set.)
In the next node, named exceptionDecision , the ok transition is taken if processing is normal, but if a variable called errorCode is found in the JBPM context, the exceptionCondition transition is taken instead.
To configure the system in this way, you need to use the JBPM's decision node feature. It allows you to nest multiple transitions within a condition:
<condition>#{ errorCode!=void }</condition>
Copy to Clipboard Toggle word wrap

Note

To learn more about conditional transitions, refer to the JBPM Reference Guide.

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat