Application Configuration for JBI Applications
By jason on Dec 18, 2008
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:
- Creating a simple routing using a File BC and a Database BC
- Configure the input filename using an Application Variable
- Configure the output database connection using an Application Configuration Object .
You can see some background information about Application Configuration capabilities in this narrated presentation.
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.
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.
The platform provides two mechanisms for modifying connection properties:
- Application Variables: define variables in a binding component service unit and provide values for those variables in the Binding itself.
- 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.
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.
Here's the screencast of the scenario.