Thursday, 12 March 2009

Create a JDBC connection in Websphere Message Broker

To get access to a transactional and pooled (?) data source from a Websphere message broker Java computer node, you will need to register a configurable service first.

Example of registrating a JDBC Oracle Server

set BROKERNAME=BRK_MYNAME
set PROVIDERNAME=OracleNAME

echo delete %PROVIDERNAME%
mqsideleteconfigurableservice %BROKERNAME% -c JDBCProviders -o %PROVIDERNAME%

echo create %PROVIDERNAME%
mqsicreateconfigurableservice %BROKERNAME% -c JDBCProviders -o %PROVIDERNAME% -n connectionUrlFormat,connectionUrlFormatAttr1,databaseName,databaseType,databaseVersion,jarsURL,portNumber,securityIdentity,serverName,type4DatasourceClassName,type4DriverClassName -v "jdbc:oracle:thin:[user]/[password]@//[serverName]:[portNumber]/[connectionUrlFormatAttr1]","XXXXX","XXXXX","Oracle","10.2","C:\oracle\Ora\jdbc\lib","1521","SXX","hostname.domain.se","oracle.jdbc.xa.client.OracleXADataSource","oracle.jdbc.OracleDriver"

echo stop broker
mqsistop %BROKERNAME%

echo setup user and password for %PROVIDERNAME%
mqsisetdbparms %BROKERNAME% -n jdbc::SXX -u user -p pass

echo start broker
mqsistart %BROKERNAME%

echo report properties
mqsireportproperties %BROKERNAME% -c JDBCProviders -o OracleNAME -r

After the configurable service has been created, you can retrive the Oracle connection with the getJDBCType4Connection as such:

String connectionName = "OracleNAME";
Connection conn = null;

conn = getJDBCType4Connection(connectionName,MbNode.JDBC_TransactionType.MB_TRANSACTION_AUTO);

Because the broker is managing the connections, your code may not:
  • perform any action that COMMITs or a ROLLBACKs the database transaction.
  • closes the connection to the database.
For more information and restrictions, refer to the WMB documentation,section Interacting with databases using the JavaCompute node

WESB Dynamic service gateway

The top new feature in Websphere ESB 6.2 that I have found is the support for Dynamic service gateways. This enables one to create a single instance that handles multiple protocols, multiple servuces and threat them the same, e.g. a simple way to create a single flow that handles multiple services and does the same VETRO pattern regardless of protocol.

The following image illustrates a flow that handles different protocols in the same way.



So far this has been hard to implement in IBMs Websphere Message Broker and Websphere ESB.

For example, in Messagebroker (6.1) the SOAP nodes binds to a single WSDL and in Websphere ESB the SCA components are also staticaly bound to a implementation. So far the easiest way of doing this has been to use a generic type with subtypes and example of this is the Salesforce.com Enterprise API where one operation supports multiple business objects.

See the IBM documentation for more information / examples.

Wednesday, 4 February 2009

IAM3: WebSphere Message Broker - Log4j Node

New support pack for using Log4j within the broker.