Writing a mediation handler

This topic outlines how to write a mediation handler, add mediation function to it, and prepare it for installation on an application server.

Before you begin

Before you start this task, you should have access to a Java™ programming environment, and the Eclipse development environment (part of the Application Server Toolkit supplied with WebSphere® Application Server.)

About this task

A mediation handler can be deployed. Each mediation handler executes some specific message processing at runtime, for example transforming a message format, or routing a message to a particular destination. A mediation handler is a Java program framework, to which you add the code that performs the mediation function. For more information about handlers, see Mediation handlers and mediation handler lists.

Your mediation handler class can be defined either in a Java project or an EJB project (which is needed for the deployment artefact.) Your programming and deployment artefacts can be separated in different projects. The steps below are for an EJB project, but the steps are very similar if you want to create a Java project, since you simply define a target server for either a Java project or an EJB project and the server runtime plug-in sets the class path correctly.

Procedure

  1. Create a new EJB project:
    1. Switch to the J2EE perspective to work with J2EE projects. Click Window > Open Perspective > Other >J2EE.
    2. From the File menu, select New > Project.
    3. Expand the J2EE folder, and select Enterprise Application Project. Click Next.
    4. Optional: If you have created a Java project instead of an EJB project, right click on the Java project folder icon for the context menu and select Properties. When the Properties panel appears, select the Server properties and target the project to WebSphere Application Server Version 6.0, as in the next step.
    5. Enter a name for the project and target the project to WebSphere Application Server Version 6.0. (If this is the first time you target this server you will need to click the New... button.) Click Next to take you to the EAR Module Projects window.
    6. Click New Module....
    7. Create a new module project by selecting the check box against EJB project, and entering the name of your mediation handler.
    8. Click Finish. You are returned to the EAR Module Projects window.
    9. Click Finish to create the new project.
  2. Create a mediation handler class by implementing the com.ibm.websphere.sib.mediation.handler.MediationHandler interface.
    1. From the File menu, select New > Java Class.
    2. Specify the source folder for your mediation EAR project.
    3. Specify a name for your mediation handler.
    4. Select Superclass java.lang.Object.
    5. Select Interface com.ibm.websphere.sib.mediation.handler.MediationHandler.
    6. Click in the check box to select Inherited abstract methods
    7. Click Finish to create the new mediation handler class.
  3. Add functional code that transforms or routes messages to your mediation handler using the Application Server Toolkit. For more information, see Adding mediation function to handler code. Beware that the default return value for the handle method created by the toolkit is false, which causes the message to be discarded. You need to change the return value to true to preserve the message.
  4. Generate an EAR file from your mediation handler class. Follow the instructions in the topic entitled "Deploying a mediation handler" in the Application Server Toolkit information center. Note that the Application Server Toolkit is also available in the Rational® Software Development Platform.

What to do next

Next, you are ready to install the EAR file containing your mediation handler into the application server.



In this information ...


Related tasks

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic    

Terms of Use | Feedback

Last updated: Aug 29, 2010 9:31:45 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=vela&product=was-nd-mp&topic=tjy1700
File name: tjy1700.html