You can write a mediation handler, add mediation function
to it, and prepare it for installation on an application server.
Before you begin
You should have access to a Java™ programming
environment, and an assembly tool such as
IBM® Rational® Application Developer.
About this task
A mediation handler can be deployed. Each mediation handler
executes some specific message processing at run time, 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.
You can define a mediation handler class either in a Java project or an EJB project
(which is needed for the deployment artifact). Your programming and deployment artifacts can be
separated in different projects. The following steps are for an EJB project, but the steps are very
similar if you want to create a Java project, because you 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
- Create a new EJB project:
- Switch to the Java EE perspective to work with Java
EE projects. Click Window > Open Perspective > Other >
Java EE.
- From the File menu, select New > Project.
- Expand the Java EE folder, and select Enterprise Application
Project. Click Next.
- 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 an appropriate server for your system, as in the
next step.
- Enter a name for the project and target the project
to an appropriate server for your system. (If this is the first time
you target this server, click New....) Click Next to
take you to the EAR Module Projects window.
- Click New Module....
- Create a new module project by selecting the check box
against EJB project, and entering the name of your mediation handler.
- Click Finish. You
are returned to the EAR Module Projects window.
- Click Finish to create the new
project.
- Create a mediation handler class by implementing the com.ibm.websphere.sib.mediation.handler.MediationHandler
interface.
- From the File menu, select New > Java Class.
- Specify the source folder for your mediation EAR project.
- Specify a name for your mediation handler.
- Select Superclass java.lang.Object.
- Select Interface com.ibm.websphere.sib.mediation.handler.MediationHandler.
- Select the Inherited abstract methods check
box.
- Click Finish to create the new
mediation handler class.
- Add functional code that transforms or routes messages
to your mediation handler by using the IBM Rational Application Developer. 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 must change the return
value to true to preserve the message.
- Generate an EAR file from your mediation handler class.
Follow the instructions in the IBM Rational Application Developer documentation.
What to do next
Next, you are ready to install the EAR file containing your
mediation handler into the application server.