BPEL4WS和ESB不仅不是相互竞争的,反而是互补的。BPEL定义业务流程,而ESB提供BPEL执行过程中所有需要的服务。下面看一个PXE的BPEL过程无缝迁入到ServiceMix里面的例子
这是在PXE中独立执行时候的配置,我们看到ProcessSVC的Provider里面使用了Protocoladapter.soap这个协议提供。其实bpel更不需要关注提供协议的类型,这些服务全部交给ESB做就行了
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<system-descriptor name="AsyncProcess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.fivesight.com/pxe/system-descriptor/ http://www.fivesight.com/pxe/system-descriptor/"
wsdlUri="file:main.wsdl"
xmlns="http://www.fivesight.com/pxe/system-descriptor/"
xmlns:proc="uri:com.bptest.process"
xmlns:resp="uri:com.bptest.responder">
<channels>
<channel name="inboundChannel" />
<channel name="callbackChannel" />
<channel name="outboundChannel" />
</channels>
<services>
<service name="ProcessSVC" provider="uri:protocoladapter.soap">
<imports>
<port name="ProcessPORT" type="proc:ProcessPT" channel-ref="inboundChannel"/>
<port name="CallbackPORT" type="resp:CallbackPT" channel-ref="callbackChannel"/>
</imports>
</service>
<service name="ResponderSVC" provider="uri:protocoladapter.soap">
<exports>
<port name="ResponderPORT" type="resp:ResponderPT" channel-ref="outboundChannel"/>
</exports>
</service>
<service name="ProcessSync.BpelService" provider="uri:bpelProvider">
<imports>
<port name="AsyncResponder.Responder" type="resp:ResponderPT" channel-ref="outboundChannel"/>
</imports>
<exports>
<port name="Client.Process" type="proc:ProcessPT" channel-ref="inboundChannel"/>
<port name="AsyncResponder.Caller" type="resp:CallbackPT" channel-ref="callbackChannel"/>
</exports>
</service>
</services>
</system-descriptor>
下面是ServiceMix中的配置。很明显,刚才的provider里面换成了uri:jbi。通过pxe的JBI兼容组件,当业务流程中调用这些组件的时候,自动通过ESB来调用这些服务。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<system-descriptor name="AsyncProcess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.fivesight.com/pxe/system-descriptor/ http://www.fivesight.com/pxe/system-descriptor/"
wsdlUri="file:./AsyncProcess.wsdl"
xmlns="http://www.fivesight.com/pxe/system-descriptor/"
xmlns:proc="uri:com.bptest.process"
xmlns:resp="uri:com.bptest.responder">
<channels>
<channel name="inboundChannel" />
<channel name="callbackChannel" />
<channel name="outboundChannel" />
</channels>
<services>
<service name="ProcessSVC" provider="uri:jbi" >
<properties>
<property name="namespace"
value="uri:fivesight.com/examples/AsyncProcessJBI" />
</properties>
<imports>
<!-- The following port will be registered as a JBI service endpoint
{uri:fivesight.com/examples/AsyncProcessJBI:ProcessSVC, ProcessPORT}
-->
<port name="ProcessPORT" type="proc:ProcessPT" channel-ref="inboundChannel"/>
<!-- The following port will be registered as a JBI service endpoint
{uri:fivesight.com/examples/AsyncProcessJBI:ProcessSVC, CallbackPORT}
-->
<port name="CallbackPORT" type="resp:CallbackPT" channel-ref="callbackChannel"/>
</imports>
</service>
<service name="ResponderSVC" provider="uri:jbi" >
<properties>
<property name="namespace"
value="uri:fivesight.com/examples/AsyncProcessJBI" />
</properties>
<exports>
<!-- The following port will invoke JBI service endpoint
{uri:fivesight.com/examples/AsyncProcessJBI:ResponderSVC, ResponderPORT}
-->
<port name="ResponderPORT" type="resp:ResponderPT" channel-ref="outboundChannel"/>
</exports>
</service>
<service name="ProcessSync.BpelService" provider="uri:bpel">
<properties>
<property name="compiledProcess" value="AsyncProcess.cbp"/>
</properties>
<imports>
<port name="AsyncResponder.Responder" type="resp:ResponderPT" channel-ref="outboundChannel"/>
</imports>
<exports>
<port name="Client.Process" type="proc:ProcessPT" channel-ref="inboundChannel"/>
<port name="AsyncResponder.Caller" type="resp:CallbackPT" channel-ref="callbackChannel"/>
</exports>
</service>
</services>
</system-descriptor>