Thursday Dec 18, 2008

Application Configuration for JBI Applications

Application Configuration for JBI components

This how-to shows how to use the configuration capabilities of the platform to modify connection parameters of JBI components without requiring applications to be redeployed. The technique is applicable to JavaCAPS, GlassfishESB, and OpenESB.

The scenario is based on Hemant's Application Configuration Lab How-To which implements a simple routing to read an input file and persist the data in a Database table using the Repository-based technology of JavaCAPS. This example implements the same scenario using the JBI technology.

The screencast consist of the following parts:

  1. Creating a simple routing using a File BC and a Database BC
  2. Configure the input filename using an Application Variable
  3. Configure the output database connection using an Application Configuration Object .

You can see some background information about Application Configuration capabilities in this narrated presentation.

Setup

The how-to assumes that you have already created two Databases - test and prod - and the associated Application Server JDBC resources. Part 5 of the GlassfishESB Introduction Tutorial shows how to create a database and setup the appropriate JDBC resources in Glassfish. This example uses JavaDB for the database, whereas how-to for the Repository technology used a MySQL database.

To create the database tables you can use a modified version of the same script. However to change from MySQL to JavaDB you will need to change the datatype LONG to BIGINT.

CREATE TABLE EMP(
EMPNO INT NOT NULL PRIMARY KEY,
ENAME VARCHAR(30),
JOB VARCHAR(30),
MGR INT,
HIREDATE DATE,
SAL BIGINT,
COMM BIGINT,
DEPTNO INT);

You can then create the required AppServer JDBC resources and connection pools from the cmd-line

Here's the commands to create the resources for the Prod database. 

> asadmin.bat create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.DataSource --property password=admin:user=admin:databaseName=prod:serverName=localhost:portNumber=1527:loginTimeout=0 ProdDBPool
> asadmin.bat ping-connection-pool ProdDBPool
> asadmin.bat create-jdbc-resource --connectionpoolid ProdDBPool jdbc/ProdDBPool

Configuration Mechanisms

The platform provides two mechanisms for modifying connection properties:

  1. Application Variables: define variables in a binding component service unit and provide values for those variables in the Binding itself.
  2. Application Configuration Objects: a predefined set of properties for a Binding. Define a instance of this object in the Binding itself and set the values for the predefined properties. Then configure a binding component service unit to make use of this particular named instance
    E.g., here's how Application Configuration Objects and Variables work for HTTP BC

In both alternatives, the composite applications you build can reuse named Application Variables and Application Configuration Objects.

Its not easy to see why there needs to be two mechanisms for doing this, but as a general rule of thumb, you can check if a Binding supports the property you need to configure in its Application Configuration Object. If not, then you can try an Application Variable instead.

Configuring the Scenario


The first configuration we need to make is to change the expected input filename. You can see from the File BC Application Configuration Object that its not possible to do this with an ACO. So this how-to will use an Application Variable instead.

The second configuration is to change the database connection from the Test DB to the Prod DB. This config is done by modifying the JNDI name of the AppServer JDBC Resource that our Database BC Service Unit uses.

In both cases, when the composite application is modified to make use of the Application Variable or Application Configuration Object then it needs to be redeployed. However, once it is setup correctly, then both the Application Variable or Application Configuration Object can be modified by independantly of the composite application. The composite app only needs to be restarted - not redeployed - for the new configuration information to take affect.

Screencast

Here's the screencast of the scenario

(The blog entry is also available as an article on the Grok JavaCAPS wiki)

About

jason

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today