The Agent Request interaction pattern synchronously delivers a request
message from the adapter to WebSphere Application Server and requires a
response.
To create an Agent Request interaction pattern, you must create an
Enterprise Application Archive application that contains:
- A message driven bean (MDB) that receives messages and invokes the EJB
- An EJB that is triggered by the MDB and that implements the business logic
that you want to use for processing the event
- Helper classes that represent the .xsd files as java beans, and
format handler java beans that convert XML to java, as specified in the
.wsdl file.
The Enterprise Application Archive application must also contain
.wsdl and .xsd files from the Service Project. If you
chose Export to Service Project when you deployed your System Manager user
project, the Service Project already exists and is included in the Enterprise
Application Archive. If you instead exported your System Manager user
project as individual files to a directory or as a JAR file, you will need to
import the file or files into a new Service Project. To do so, follow
the same procedure as described for an Agent Delivery interaction pattern, in Import files for a new service project.
The procedure for creating an Agent Request interaction pattern is similar
to that for creating an Agent Delivery pattern, except that this pattern
requires that a response message be sent. Accordingly, the business
logic in the EJB skeleton for the Agent Request interaction pattern must
return a value.
Perform the following steps to create an Agent Request interaction
pattern.
The Agent Request interaction pattern requires an EJB to consume the
message incoming to WebSphere Application Server from the agent. You
must both create the EJB and add business logic to the EBJ method to process
the received event.
Start by creating a project to contain the EJB:
- In the J2EE view of the Business Integration perspective, choose
File>New>Project.
- In the New Project dialog, choose EJB in the left-hand panel, then select
EJB project in the right-hand panel, and then choose Next.
- In the Select an EJB Version dialog, choose Create 2.0 EJB Project,
and click Next.
- In the EJB Project Creation Dialog, provide a name for your EJB project
(see Figure 37), and the name of a new or existing Enterprise Application
Archive project folder to which it will be added. If you specify a name
for a new Enterprise Application Archive project, a folder with that project
name will be created.
Figure 37. Naming the EJB project

- Choose Finish. A project, containing an EJB module, is generated
under the name that you specified. The EJB project is created for you
and you can see it in the J2EE Hierarchy view under EJB Modules. In the
Services view, under Service Projects, select the .wsdl interface file
that you imported from your connector configuration (for example,
AgentReqConnector.wsdl). Right click, and choose New>Build
from Service. The New Service Skeleton dialog opens.
- Choose EJB Service Skeleton (see Figure 27) and click Next.
Figure 38. Choosing EJB Service Skeleton

- In the New Service Skeleton dialog, select Create a new port and
binding and select Generate helper classes. Choose
Next.
- The Service Skeleton dialog appears.
- Select the appropriate Port type name according to the interaction pattern
you are creating, and provide a meaningful package name in place of the
default. Click Next.
- In the next dialog, you can specify properties for generating the EJB
skeleton, or accept the defaults. Click Finish. The newly
created EJB project will be listed under Deployable Services in the Services
view.
- Edit the skeleton to add any necessary business logic.
A message driver bean is responsible for receiving events as messages from
the connector and invoking EJB processing of the events.
In this step, you will deploy the EJB service to the server using existing
inbound port and bindings - the original JMS bindings. This step
generates an MDB that invokes the appropriate method of the Session Bean
skeleton. The MDB is specific to the port type and the selection of the
operation is made based on the incoming message properties:
WSDLOperation (and possibly WSDLInput and WSDLOutput) properties. The
additional helper classes, format handlers, are also generated during the
deployment. These are used to convert from the wire format (the XML
message) to the Java Class, which in turn is passed as an argument to the
business method of the EJB.
You must configure the JNDI names uses by the EJB and MDB. The JNDI
setup is necessary since the lookup names of the queue connection factory and
queues defined in WSDL may not match the actual names defined on your
server. The WebSphere Application Server allows you to map the name you
are looking up (as specified in the .wsdl file) to the actual JNDI name
deployed on the server, thus allowing correct execution without the need for
modification of your wsdl files. You also need to specify what listener
port is used by the MDB.
- In the Package Explorer view, expand the folder for the Service Project
that you have created and select the EJBService .wsdl file that was
generated in the previous task. Right-click on the file, and in the
pop-up choose Enterprise Services>Generate Deploy Code.
- In the Generate Deploy Code dialog (see Figure 39), select Use an existing port. You can
either select the same EJB project you created in the previous step (for the
EJB skeleton) or specify the name of a new EJB project to create. A new
EJB project must be in the same Enterprise Application Archive project as your
existing EJB skeleton project. Choose Next.
Figure 39. Generate Deploy Code dialog

- In the Inbound Service Files dialog, select the JMSService .wsdl
file for your project, and the corresponding service name and port
name. Choose Finish.
- In the J2EE Hierarchy view, select your project under EJB Modules,
right-click, choose Open With the EJB Deployment Descriptor editor
and choose the Bean tab. Verify that the Destination type is
Queue. Specify the correct ListenerPort, so that its queue connection
factory and queue match those specified in the .wsdl file for this
interaction pattern.
- Choose the References tab. Select the resource queue name listed
under the MDB. The name from the .wsdl file then appears in the
Name box at right. Under WebSphere Bindings, in the
JNDI name field, enter the correct JNDI name for the deployment of
this queue, as defined in the WebSphere Application Server Administrative
Console (see Figure 40).
Figure 40. Entering the JNDI name for queue deployment

- Select the connector factory listed under the MDB. Under WebSphere
Bindings,in the JNDI name field, enter the correct JNDI name for
the deployment of this connection factory, as defined in the WebSphere
Application Server Administrative Console (see Figure 41).
Figure 41. Entering the JNDI name for connection factory

- Save the changes that you made in the EJB Deployment Descriptor
editor.
- Open the Server Configuration tab in the lower panel of the Business
Integration perspective and right-click on the Servers icon.
- Choose New, and choose Servers and Server Configuration. The
Create a New Server and Server Configuration dialog appears.
- In the Server name field, enter a name for the server instance you are
creating. Enter the same name in the Folderfield. In the Server
Type field, select EE Test Environment.
- Choose Finish, and respond Yes when prompted to create a new server
project with the name you specified.
- After the utility completes, in the Server Configuration panel
double-click the icon for the new server instance that you have
created. The WebSphere Server panel appears, with the name of the
server instance you have created. Choose the Configuration tab.
- The WebSphere Server Configuration panel appears. Put a check in
the Enable administration console check box.
- Choose the Variables tab. In the Defined variables drop down box,
locate the MQ_INSTALL_ROOT variable. Change the value of the variable
to the absolute root path of your MQ installation.
- Save your configuration. (Ctrl+S).
- Start the newly configured server instances, as follows: In the
lower portion of the Business Integration perspective, choose the Servers
tab. The Servers panel displays. In the Servers panel, select
the icon for the newly configured server instance, and click the run button to
start the server.
- Open the WebSphere Application Server Administrative Console. Under
General Properties under the Configuration tab, add the listener port name
that you specified in the Bean tab of EJB Deployment Descriptor (see Figure 42). Add the same connection factory JNDI value and
destination JNDI queue name value that you specified in the References tab of
EJB Deployment Descriptor. As appropriate for your needs, make any
necessary changes in the Maximum sessions, Maximum retries, and Maximum
messages fields.
Figure 42. Adding the Listener Port and JNDI names

- In the WebSphere Application Server Administrative Console, add the queue
as a resource (see Figure 43). Provide a display name for the queue, and use that
same value in the Base Queue Name field. In the JNDI Name field, enter
the name of the queue that you established in the destination JNDI queue name
value in the Bean tab of EJB Deployment Descriptor.
Figure 43. Adding the queue as a resource

Provide a value for Base Queue Manager Name (see Figure 44).
Figure 44. Providing a Base Queue Manager name

After you have completed these steps, you will have a completed Enterprise
Application Archive application for this interaction pattern. You can
then test this Enterprise Application Archive application in EE Test
Environment and deploy the Enterprise Application Archive application to
another WebSphere Application Server environment.
