- Setting up a standard apache Derby database to hold the scheduler tables.
- Creating a WAS scheduler that is callable via JNDI (and uses tables in the derby database).
- Producing an .ear file containing three components: a servlet and two, minimalist, stateless EJB's that demonstrate the important scheduler API's.
- Invoking the API and seeing the expected output.
- The optional EJB uses a public void handleEvent(TaskNotificationInfo arg) method that gets invoked by the scheduler so that events related to the management of the scheduled task can be intercepted (if you want) by your business logic - e.g. a TaskNotificationInfo.PURGED notification.
- The mandatory EJB implements a public void process(TaskStatus arg) method, that gets invoked by the scheduler and carries out your business logic.
Set up the Derby database
The SQL used for creating the derby tables, required by the scheduler, is shipped in the Scheduler folder - for me that was /home/jsears/IBM/WebSphere/7/AppServer1/Scheduler.Basically I took the createSchemaMod1Derby.ddl file from my WAS 7 instance, created the database and then pointed my WAS 6.0 scheduler at it. I used this combination because RAD 6.0 and WAS 6.0 are my primary environments.
The .ddl has to be modified with some variable substitution, for example: "CREATE TABLE @TABLE_QUALIFIER@@TABLE_PREFIX@TASK ("TASKID" BIGINT NOT NULL ," became "CREATE TABLE TBLTASK ("TASKID" BIGINT NOT NULL ,". I saved the result in a derby.sql file.
From the command line (after downloading and extracting derby) I exported the following variables:
- export DERBY_HOME=/home/jsears/local/tmp3/db-derby-10.5.3.0-bin
- export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:.
- java -jar $DERBY_HOME/lib/derbyrun.jar server start
- java -jar $DERBY_HOME/lib/derbyrun.jar ij
- connect 'jdbc:derby://localhost:1527//home/jsears/local/tmp3/MyDbTest;create=true';
- run '/home/jsears/local/tmp3/derby.sql';
- show tables;
- CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.user.user1', 'password1');
- CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.connection.requireAuthentication', 'true');
- disconnect;
- connect 'jdbc:derby://localhost:1527//home/jsears/local/tmp3/MyDbTest;user=user1;password=password1';
- exit;
Through the WebSphere Administrative console I created the database stuff first and then the scheduler stuff:
- Security > Global security > JAAS Configuration > J2C Authentication data > New ...
- Username and Password values as above, from derby setup, for jsears-desktopNode01/MyDerbyUID:

- Resources > JDBC providers @ Server level > New ...
- Name = Derby JSEARS 01
- Class path = /home/jsears/local/tmp3/db-derby-10.5.3.0-bin/lib/derbyclient.jar
- Implementation class name = org.apache.derby.jdbc.ClientConnectionPoolDataSource
- JDBC providers > Derby JSEARS 01 > Data sources > New ...
- Name = Derby Network Server DataSource
- JNDI name = jdbc/DerbyNSDS
- Component-managed authentication alias = jsears-desktopNode01/MyDerbyUID
- When created press the "Test connection" button!

- JDBC providers > Derby JSEARS 01 > Data sources > Derby Network Server DataSource > Custom properties
- databaseName = /home/jsears/local/tmp3/MyDbTest
- serverName = localhost
- portNumber = 1527

- Resources > Schedulers @ Server Level > New ...
Name = MyScheduler- JNDI name = sched/MyScheduler
- Data source JNDI name = jdbc/DerbyNSDS
- Data source alias = jsears-desktopNode01/MyDerbyUID
- Table prefix = tbl
- Work managers = Default Work Manager
- When completed press the "Verify tables" button!
Use the API'sThe servlet looks like this, in my mind the important bit is how the call backs are registered:
The first EJB is the optional one:
And here is the mandatory EJB:
What is most important is how the deployment descriptor looks (take into account that this was coded in a RAD 6 IDE). In particular how the
NOTE: use the following in RAD as the JDBC Driver class if you want to connect RAD to derby: org.apache.derby.jdbc.ClientDriverInvoke the API
Figure out what the appropriate BOOTSTRAP_ADDRESS + WC_defaulthost ports are of the servlet:
- Servers > Application Servers > server1 > Ports
- http://127.0.0.1:9081/SchedWebApp/Main/

0 comments:
Post a Comment