Previous Topic: Session Bean JobsNext Topic: Database Jobs


Defining Session Bean Jobs

You can define a Session Bean (EJB_JOB) job to access a stateless or stateful session bean, invoke a method on the bean, and return the results.

Note: To run these jobs, your system requires CA WA Agent for UNIX, Linux, or Windows and CA WA Agent for Application Services.

Required Statements

To define a Session Bean job, you must specify the following statements:

In addition, to access stateful session beans, you require the following statements:

Optional Statements

You can specify the following optional statements for a Session Bean job:

Example: Invoke a Method on a Stateless Session Bean

Suppose that you want to invoke the reverse method on the CybEJBTestBean stateless session bean. The reverse method has one parameter, with type java.lang.String and value a23. The output from the reverse method is saved to the C:\Makapt15 file. The initial context factory supplied by the JNDI service provider is com.ibm.websphere.naming.WsnInitialContextFactory. The service provider's URL is iiop://172.24.0.0:2809, where 172.24.0.0 is the IP address of the WebSphere application server and 2809 is the ORB port. When the job runs, the output of the reverse method is stored in the output destination file.

AGENT APPAGENT
INITIAL_CONTEXT com.ibm.websphere.naming.WsnInitialContextFactory
LOCATION iiop://172.24.0.0:2809
BEAN CybEJBTestBean
METHOD reverse
DESTINATION C:\Makapt15
JNDIUSER cyberuser
PARAMETER TYPE(java.lang.String) VALUE(a23)

Example: Invoke a Method on a Stateful Session Bean

Suppose that you want to access a stateful session bean for an online shopping cart. The createaddbook method creates the Shoppingcart stateful bean for the duration of the job. The addbook method adds books to the shopping cart using the book's ISBN number. In this example, the Session Bean job adds two books to the shopping cart with ISBN numbers 1551929120 and 1582701709. When the job runs, two books are added to the shopping cart.

AGENT APPAGENT
INITIAL_CONTEXT com.ibm.websphere.naming.WsnInitialContextFactory
LOCATION iiop://172.24.0.0:2809
BEAN Shoppingcart
CREATEMETHOD createaddbook
METHOD addbook
CREATEPARAMETER TYPE(String) VALUE(ISBN)
PARAMETER TYPE(Integer) ARRAY(1551929120,1582701709)