![]() |
![]() |
|
|
Using JAM in a Clustered Environment
This scenario extends the EJB client model described in the BEA WebLogic Java Adapter for Mainframe Programming Guide to demonstrate a client requesting multiple employee actions against an EJB that is deployed in a cluster. The client holds a remote interface for each EJB on each WebLogic Server in the cluster on which it is deployed. A JAM gateway must be running on each WebLogic Server in the cluster. Each gateway is connected to a CRM running on the same machine or distributed to a different machine. The client is used to make multiple requests to the clustered EJB. The EJB writes a message to the WebLogic Server console, showing the distribution of the client requests.
Action List
To use JAM in a clustered environment, complete the following tasks.
|
Your action... |
Refer to... |
---|---|---|
1 |
Verify that prerequisite tasks have been completed. |
|
2 |
Prepare your system. |
|
3 |
Run the sample. |
Prerequisites
Verify that the following prerequisite tasks have been completed.
Preparing Your System
Complete the following steps to run the clustering scenario:
Running the Sample
To run the clustering sample provided with the JAM product, complete the following steps.
Listing 5-1 clusterSampleClientBean.java
// ===========================================================
// clusterSampleClientBean.java
// Example class that extends a generated JAM client EJB application.
//------------------------------------------------------------
package sample;
// Imports
import java.math.BigDecimal;
import java.io.IOException;
import com.bea.sna.jcrmgw.snaException;
// Local imports
import sample.EmployeeRecord;
import sample.EmployeeRecord.EmpRecord1V;
import sample.SampleClientBean;
//************************************************************
Extends the SampleClientBean EJB class, adding additional business logic.
*/
public class clusterSampleClientBean
extends SampleClientBean
{
// Public functions
*****************************************************************
* Read an employee record.
*/
public EmployeeRecord readEmployee(EmployeeRecord commarea)
throws IOException, snaException
{
EmployeeRecord erec = (EmployeeRecord) commarea;
try {
// Make the remote call.
erec = super.readEmployee(commarea);
// Log the results
printEmployee("readEmployee : ", erec);
} catch (Exception e) {
log("Read Exception " + e.toString() + " for "
+ erec.getEmpRecord().getEmpName().getEmpNameLast());
throw new IOException();
}
// Return the Employee Record
return erec;
}
/**********************************************************
* Create a new employee record.
*/
public EmployeeRecord newEmployee(EmployeeRecord commarea)
throws IOException, snaException
{
EmployeeRecord erec = (EmployeeRecord) commarea;
try {
// Make the remote call.
erec = super.newEmployee(commarea);
// Log the results
printEmployee("newEmployee : ", erec);
} catch (Exception e) {
log("Create Exception " + e.toString() + " for "
+ erec.getEmpRecord().getEmpName().getEmpNameLast());
throw new IOException();
}
// Return the Employee Record
return erec;
}
// Private Functions
/************************************************************
* Print the Employee Record
*/
private void printEmployee(String title, EmployeeRecord emp)
{
EmpRecord1V empinfo = emp.getEmpRecord();
log(title +
empinfo.getEmpName().getEmpNameFirst() + " " +
empinfo.getEmpName().getEmpNameMi() + " " +
empinfo.getEmpName().getEmpNameLast() + ", " +
empinfo.getEmpAddr().getEmpAddrStreet() + ", " +
empinfo.getEmpAddr().getEmpAddrSt() + " " +
empinfo.getEmpAddr().getEmpAddrZip());
}
private void log(String s) {
System.out.println(s);
}
}
<enterprise-beans>
<session>
<ejb-name>SampleClient</ejb-name>
<home>sample.SampleClientHome</home>
<remote>sample.SampleClient</remote>
<ejb-class>sample.clusterSampleClientBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<Application Deployed="true" Name="SampleClient" Path=.\config\mydomain\applications">
<EJBComponent Name="SampleClient" Targets="mach1,mach2,mach3" URL="SampleClient.jar""/>
</Application>
In the example in Listing 5-2, the ClientTest sample is used to make the cluster requests.
Listing 5-2 ClientTest Sample
java sample.ClientTest -u "t3://cluster:7001" -c 10 -i 100
The options are in this example are defined in the following way:
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|