Dashboard > PXE > Home2 > Message Exchange Interceptors > View

Page Operations


Navigation


PXE Log In   View a printable version of the current page.
Message Exchange Interceptors
Added by Alex Boisvert, last edited by Alex Boisvert on Aug 30, 2006

Introduction

ODE provides an extension mechanism that permits "interception" of message exchanges that enter or leave the ODE server. An incoming message exchange (my-role message exchange) can be intercepted at various points: when it first enters the system, when it is routed to a process, and when it is routed to a particular process instance. An outgoing message-exchange (partner-role message exchange) can be intercepted right before it exits the system. A message-exchange interceptor is invoked at these points in the life of a message exchange and can be used to alter the course of execution (e.g. by causing the message exchange to be failed).

This text is a quick summary of this mechanism.

Writing Message Exchange Interceptors

A message exchange interceptor is a Java class that implements the org.apache.ode.bpel.intercept.MessageExchangeInterceptor interface. This class must provide a no-arg constructor.

For example, an interceptor that limits the number of process instances that can be created for a process to 5, would look like this:

public class ThrottlingInterceptor implements MessageExchangeInterceptor {
    public void onNewInstanceInvoked(MyRoleMessageExchange mex, InterceptorContext ic)
        throws FailMessageExchangeException
    {
        if (ic.getProcessDAO().getNumInstances() >= 5)
            throw new FailMessageExchangeException("Too many instances.");
    }

    public void onBpelServerInvoked(MyRoleMessageExchange mex, InterceptorContext ic)
        throws FailMessageExchangeException, FaultMessageExchangeException {}

    public void onProcessInvoked(MyRoleMessageExchange mex, InterceptorContext ic)
        throws FailMessageExchangeException, FaultMessageExchangeException {}

    public void onPartnerInvoked(PartnerRoleMessageExchange mex, InterceptorContext ic)
        throws FailMessageExchangeException, FaultMessageExchangeException {}
}

A more elaborate version of this interceptor can be found in the ODE distribution, in the org.apache.ode.bpel.intercept.ThrottlingInteceptor class.

Deploying Message Exchange Interceptors

Message exchange interceptors are associated with a particular process via the process's deployment descriptor. For example, a message exchange interceptor named com.myco.MyInterceptor could be associated with the HelloWorld2 example process by modifying the deploy.xml file to:

<deploy xmlns="http://ode.fivesight.com/schemas/2006/06/27/dd"
        xmlns:pns="urn:/HelloWorld2.bpel"
        xmlns:sns="urn:/HelloWorld2.wsdl">

    <process name="pns:HelloWorld2">
        <active>true</active>
        <provide partnerLink="helloPartnerLink">
            <service name="sns:HelloService" port="HelloPort"/>
        </provide>
        <mex-interceptors>
            <mex-interceptor>
                <class-name>com.myco.MyInterceptor</class-name>
            </mex-interceptor>
        </mex-interceptors>
    </process>
</deploy>

Any number of interceptors may be associated with a process, by placing additional <mex-interceptor> under the <mex-interceptors> element.

A Note on Class-Paths

When using message-exchange interceptors one must ensure that the interceptor class and any classes on which it depends are found in the ODE server classpath. In the JBI environment this may require modification of the jbi.xml file in the ODE installer. In the AXIS2 environment, this may require the placement of a JAR file in ODE's WEB-INF/lib directory.



Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 1.4.1 Build:#212 Jun 02, 2005) - Bug/feature request - Contact Administrators