IncrementEJBUpes.java

Abstract This example contains sample source code for a user-defined Program Execution Server (UPES) implementation with JMS, which invokes an EJB.
This example shows ...
  • How to invoke EJBs in WebSphere using a UPES.
You can use this example ...
  • As a UPES over JMS.
Minimum MQWF version required
  • V3.3.0
Other required products
  • WebSphere Application Server V3.5.3 Advanced Edition.
  • MQSeries V5.2 (V5.1 is not supported)
  • MQSeries support Pack MA88 (the new version for MQSeries V5.2)
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 activities are implemented using the same UPES, which acts as a dispatcher and executes the command that is retrieved from the input XML message. The value of the bean counter is then written to the output XML message. This value is used to validate the exit condition for the second activity. The last activity shuts down the UPES.

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.

This UPES sample focuses on the EJB invocation. If you need a sample with a more sophisticated XML parsing using a DOM tree, refer to the Distributed process sample using XML, which can be installed from the IBM WebSphere MQ Workflow product CD and check the <MQWF_Root>\SMP\DPXML\readme.html file, where <MQWF_Root> is the directory into which you installed IBM WebSphere MQ Workflow.

The EJB invocation via the UPES supports transactions, but offers no possibility to retrieve the meta model of the containers. The meta model can be retrieved when you invoke EJBs via the PEA.

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

Setup To prepare the sample, follow these steps:
  • Install and configure all of these: MQSeries, the JMS SupportPac, 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 IncrementEJBUpes.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.
    Note: If the name of your IBM WebSphere MQ Workflow queue manager is not 'FMCQM', the name of your System Group is not 'FMCGRP' or the name your System is not 'FMCSYS', you must replace these settings with your corresponding values in the FDL before importing it. You will find the settings in the 'SERVERs' section of the FDL, belonging to the server 'EJBINC'.
  • Create the UPES queue using the MQSeries Explorer:
    • Select the folder 'Queues' from the queue manager for IBM WebSphere MQ Workflow (default name is 'FMCQM').
    • Right-click this folder, then select 'New'->'Local Queue'.
    • Enter the queue name 'EJBINC' and accept the default values.
    • Click 'OK'. There is no need to share the queue in the cluster.
  • Start the WebSphere Application Server.
  • Register the UPES queue in JNDI using this command:
    register_upes.cmd.
    Note: If the name of your IBM WebSphere MQ Workflow queue manager is not 'FMCQM', you must replace the two occurrences of the string 'FMCQM' within this command file with the name of your queue manager.
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 the <nodename>/Default Server/Default container.
  • Start the UPES sample using start_upes.cmd
  • Start the IBM WebSphere MQ Workflow Client.
  • Create a process instance from the template 'IncrementEJBUPES'.
  • Start this process instance and the related work items. The WorkItem 'IncrementAndGetValue' is defined to be invoked three times, because of its exit condition. The last activity then shuts down the UPES.
    Note: The output of the UPES containing the XML messages and EJB invocation log will be written to the command prompt where you started the UPES.
  • You can verify and track the value of the counter in the WebSphere database (usually 'WAS') in the 'INCBEANTBL' table.
To clean up the JNDI service, you can unregister the UPES queue in JNDI using the unregister_upes.cmd.
View source code IncrementEJBPea.java
IncrementEJBUpes.html (Javadoc)


[ Back to Java index ]