Scenario: Developing destination user exits

To develop destination user exits, you must develop OSGi services that include the provided user exit APIs.

Before you begin

You must be an experienced programmer in Java™, Open Services Gateway Initiative (OSGi) services, and OSGi bundles. The public user exit Java APIs must be exported as an OSGi service in your OSGi bundle.
Remember: There can be more than one OSGi service in your OSGi bundle.

About this task

To develop destination user exit OSGi services:

Procedure

  1. Locate the Members\resources\userexits installation directory.
  2. Set up your development environment.
    1. Download the user exit API JAR file from the Members\resources\userexits installation directory.
    2. Verify that your integrated development environment (IDE) is configured for OSGi development.
    3. Optional: Download the latest Eclipse IDE and either Equinox SDK or Apache Aries: Maven Plug-in.
    4. Optional: Download the latest WebSphere® Application Server V7 Feature pack for OSGi Applications and JPA 2.0.
    5. Modify your /META-INF/MANIFEST.MF file to match your implementation.
    6. Optional: For Maven plug-in implementations, modify your /META-INF/pom.xml and META-INF/pom.properties files to match your implementation.
    7. Optional: For Blueprint Container implementations, modify your /OSGI-INF/blueprint.xml file to match your implementation.
  3. Implement the appropriate user exit API.
    PreDeliveryUserExitHandler
    The PreDeliveryUserExitHandler is used in the destination process flow before a message enters the destination process flow.
    PostDeliveryUserExitHandler
    The PostDeliveryUserExitHandler is used in the destination process flow after a message exits the destination process flow.
    BusinessDocument
    The BusinessDocument is used to handle the message, payload, attachments, transport headers, and message properties in the process flow.
  4. Debug your OSGi components in your local IDE.
    Restriction: User exits cannot be tested in your local development environment. You must deploy the user exit OSGi services on the system for testing.
  5. Assemble your destination user exit OSGi services and prepare your userexit_bundle-SymbolicName.jar OSGi bundle for deployment on the system.
  6. To deploy your authentication user exit bundle, locate the bin directory.
    Important: You must repeat this procedure for each node that requires this user exit.
  7. To load your user exit OSGi bundle into the data grid, type execute user_exit load <path to userexit_bundle.jar>
  8. To deploy your user exit OSGi bundle on your current node, type execute user_exit config <userexit_bundle-SymbolicName>|all
    Important: If you update an existing user exit on the system, you must restart the member.
  9. Optional: Restart the member:
    1. To stop the member, type execute member stop operational
    2. To start the member, type execute member start operational or execute member start_service operational
  10. Optional: To verify your user exit deployment, type execute user_exit list

Example

API code snippet for pre-delivery and post-delivery destination user exit points.


/**
 * This user exit handler is invoked prior delivery to a destination.
 *  
 */
public interface PreDeliveryUserExitHandler extends UserExitHandler {

    /*
     * (non-Javadoc)
     * 
     * @see com.ibm.b2b.userexits.spi.UserExitHandler#invoke(com.ibm.b2b.userexits.spi.BusinessDocument)
     */
    @Override
    public BusinessDocument invoke( BusinessDocument bdo ) throws PreDeliveryExitException;

}
/**
 * This user exit handler is invoked post delivery to a destination.
 * 
 */
public interface PostDeliveryUserExitHandler extends UserExitHandler {

    /*
     * (non-Javadoc)
     * 
     * @see com.ibm.b2b.userexits.spi.UserExitHandler#invoke(com.ibm.b2b.userexits.spi.BusinessDocument)
     */
    @Override
    public BusinessDocument invoke( BusinessDocument bdo ) throws PostDeliveryExitException;

}

What to do next

You can now manage and configure your user exits in the process flows for AS4 HTTP destinations, AS4 HTTPS destinations, and AS4 messaging destinations.

Tip: To edit deployed user exit OSGi bundles, type execute user_exit export <userexit_bundle-SymbolicName> <directory location for exported files>. You can then edit the OSGi bundle locally and modify, debug, and test before you deploy the modified OSGi bundle again.