IncrementEJBPea.java

Abstract This example contains sample source code for a program that implements an activity, which invokes an EJB.
This example shows ...
  • How to invoke EJBs in WebSphere using the Program Execution Agent (PEA) and the Java High Performance Bridge.
You can use this example ...
  • For an activity implementation that invokes EJBs. 
Minimum MQWF version required
  • V3.3.0
Other required products
  • WebSphere Application Server V3.5.3 Advanced Edition.
Description

This sample contains a complete Workflow scenario, that is, an Entity Bean is created, incrementing its counter in a loop until it reaches the value of 3 and finally the EJB is removed.

All three activities are implemented using the same program, which acts as a dispatcher and executes the command that is retrieved from the input container. The value of the bean counter is then written to the output container. This value is used to validate the exit condition for the second activity.

The activity implementation uses the Java High Performance Bridge which caches the JVM and the static variables of the main class, which then significantly improves performance.

The EJB that is invoked here is the HitCount Bean which is installed by default with WebSphere. Because it is already deployed, you only have to start it.

The EJB invocation via the PEA allows you to retrieve the meta model of the Workflow containers, but does not support transactions. To use transactions, you can invoke EJBs using the UPES.

The configuration files referred to below are available only for Windows NT (or Windows 2000) and WebSphere, but the Java code is not dependent on the operating system or EJB container. It respects the EJB 1.1 standard.

Setup To prepare the sample, follow these steps:
  • Install and configure both IBM WebSphere MQ Workflow and WebSphere.
  • Start a command prompt and change to the directory where this HTML file is located.
  • Edit and customize the file setup_environment.cmd. You find more information within this file. Stay within this environment and perform the following steps:
  • Compile the sample using javac IncrementEJBPea.java.
  • Import the sample FDL using this command:
    fmcibie -uadmin -ppassword -i<MQWF_Root>\smp\fdl\apiexmpl.fdl -ot, where <MQWF_Root> is the directory into which you installed IBM WebSphere MQ Workflow.
Running the sample To run the sample, perform the following steps:
  • Make sure that both the IBM WebSphere MQ Workflow and WebSphere servers are started and that you performed all set-up steps as described.
  • Start the HitCount Bean within WebSphere. It is located in <nodename>/Default Server/Default container.
  • Start the IBM WebSphere MQ Workflow Client using the script start_runtime_client.cmd. Don't start it using the icon, because you need certain settings that are inherited from this command prompt environment.
  • Create a process instance from the template 'IncrementEJBPEA'.
  • Start this process instance and its related work items. The WorkItem 'IncrementAndGetValue' is defined to be invoked three times, because of its exit condition.
    Note: The output of the activity implementation containing the EJB invocation log will be written to the PEA window, which is usually minimized.
  • You can verify and track the value of the counter in the WebSphere database (usually 'WAS') in the 'INCBEANTBL' table.
View source code IncrementEJBPea.java
IncrementEJBPea.html (Javadoc)


[ Back to Java index ]