Showing posts with label TIBCO EMS. Show all posts
Showing posts with label TIBCO EMS. Show all posts

Tuesday, April 26, 2011

TIBCO EMS Fault Tolerant Pair - Server Authorization=True

TIBCO EMS User's Guide Chapter 19 Fault Tolerance - Authorization and Fault-Tolerant Servers describes how to setup server authorization in a FT pair. This article tries to compliment the TIBCO official documentation with easy to understand examples and illustrations.

There are at least 3 possible configurations of authorization-enabled FT pairs.

1) Primary and secondary servers share a common users.conf file.
2) Primary and secondary servers each uses separate users.conf file.
3) Primary and secondary servers retrieve user/group from a common LDAP.

Before we look into each option, ensure the server names and server passwords are identical on both servers. Server password is stored in the tibemsd.conf file. Examine the section in tibemsd.conf.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                =

You must setup the server password on both servers. You can do this on individual server, without needing to run them as pair.

First, start up the first instance (using tibemsd1.conf)

Connect to this instance using tibemsadmin in $EMS_HOME/bin

tibadmin@tibems01:~/tibco/ems/5.1/bin$ ./tibemsadmin

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

Type 'help' for commands help, 'exit' to exit:
> 


Connect to tibems01 (login name = admin, password = blank)

> connect tibems01
Login name (admin): 
Password: 
Connected to: tcp://tibems01:7222
tcp://tibems01:7222> 

Set the server password using the following command.

tcp://tibems01:7222> set server password=serverpass
Server parameters have been changed
tcp://tibems01:7222> 

Before you proceed to carry out the same step to tibems02, lets inspect the tibemsd1.conf file. You should see that the mangled password is now there.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                = $man$o9y3vdC5oxiNRQT6Sb4F+FqKLqM

Now set the server password in tibemsd2.conf, with the exact same password used in tibemsd1.conf.

tibadmin@tibems01:~/tibco/ems/5.1/bin$ ./tibemsadmin 

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

Type 'help' for commands help, 'exit' to exit:
> connect tibems02
Login name (admin): 
Password: 
Connected to: tcp://tibems02:7222
tcp://tibems02:7222> set server password=serverpass
Server parameters have been changed
tcp://tibems02:7222> 

Inspect tibemsd2.conf file.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                = $man$vwtgocxurfOKsIcAiMOwD84fCDc


Note that the mangled password does not need to be identical in both tibemsd1.conf and tibemsd2.conf.

The FT pair are still not operational until we create a user 'EMS-SERVER' in each server. This is where it gets confusing. Not only you set up the server password (stored in the tibemsd.conf files), you also need to create a user called 'EMS-SERVER' with the exactly same password (serverpass). This task is subject to which option we choose and is described in sections below.

Option1: Primary and secondary servers share a common users.conf file (in other words, both tibemsd1.conf and tibemsd2.conf point to a single users.conf file)

Servers using a common users.conf file

Start either one of the instances (I chose tibems01)

Start tibco admin tool and connect.

> connect tibems01
Login name (admin): 
Password: 
Connected to: tcp://tibems01:7222
tcp://tibems01:7222> create user EMS-SERVER password=serverpass
User 'EMS-SERVER' has been created
tcp://tibems01:7222> 

Now inspect the users.conf file.

admin::"Administrator"
EMS-SERVER:$2$og/IEiSh$gp3b15kK67UPbMR3t7NX4h2X:""

The user admin is created by default by the server, without a password.

The EMS-SERVER is the one that we have just created. Note the mangled password.

Option 2: Primary and secondary servers each uses separate users.conf files (say, tibemsd1.conf uses users1.conf and tibemsd2.conf uses users2.conf)

Servers have own users.conf file

Perform what were done in step 1 for both tibems01 and tibems02. You should see the mangled password for EMS-SERVER in both usersN.conf files.

3) Primary and secondary servers retrieve user/group from a common LDAP.

Not covered in this article. We will discuss this when I have my LDAP server deployed.

Happy authorizing...☺

Cheers,

Saturday, April 23, 2011

TIBCO EMS 5.1.5 ESTATUS = 230 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException

Alright, the FT setup in the previous article worked, but didn't quite right. After the first successful startup and worked as pair, it never did again the second time.

Kept giving out this error.

2011-04-19 13:47:22.004 Recovering state, please wait.
2011-04-19 13:48:23.313 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.DataStore._checkValidConnParams(DataStore.java:280)
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.DataStore.open(DataStore.java:302)
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.CallableDataStore.open(CallableDataStore.java:121)
2011-04-19 13:48:23.313         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-04-19 13:48:23.314         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-04-19 13:48:23.314         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-04-19 13:48:23.314         at java.lang.reflect.Method.invoke(Method.java:597)
2011-04-19 13:48:23.314         at com.tibco.tibems.tibemsd.internal.Context.invokeMethodInLine(Context.java:308)
2011-04-19 13:48:23.316 SEVERE ERROR: Unable to open store [$sys.failsafe]: [ ESTATUS = 230, ERRSTR = com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out ]
2011-04-19 13:48:23.317 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out
2011-04-19 13:48:23.317         at com.tibco.tibems.tibemsd.internal.db.DataStore._checkValidConnParams(DataStore.java:280)
2011-04-19 13:48:23.317         at com.tibco.tibems.tibemsd.internal.db.DataStore.open(DataStore.java:302)
2011-04-19 13:48:23.324         at com.tibco.tibems.tibemsd.internal.db.CallableDataStore.open(CallableDataStore.java:121)
2011-04-19 13:48:23.324         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-04-19 13:48:23.324         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-04-19 13:48:23.324         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-04-19 13:48:23.325         at java.lang.reflect.Method.invoke(Method.java:597)
2011-04-19 13:48:23.325         at com.tibco.tibems.tibemsd.internal.Context.invokeMethodInLine(Context.java:308)
2011-04-19 13:48:23.325 SEVERE ERROR: Unable to open store [$sys.meta]: [ ESTATUS = 230, ERRSTR = com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out ]
2011-04-19 13:48:23.327 ERROR: Initialization failed: storage for '$sys.meta' not found.
2011-04-19 13:48:23.327 FATAL: Exception in startup, exiting.

After an hour of investigation, it finally narrowed down to oracle jdbc driver problem.

In TIBCO EMS User's Guide, Chapter 10, the documentation did give some clue about RAC.

"The TIBCO Enterprise Message Service server must connect to the Oracle RAC 10g database using the Oracle JDBC OCI driver and TAF configuration."

Why not give it a try? So I went ahead to try to use OCI rather than the thin driver. And it works!

In summary, 3 things needs to be done.

1) Install the Oracle Instant Client 11.2. (instantclient-basic-linux32-11.2.0.2.0.zip)
2) Install libaio package
3) Update the store-db.conf

1) Install the Oracle Instant Client 11.2.
Download the zip file from Oracle website. Unzip all the contents into the $EMS_HOME/lib folder.

2) Install libaio package

root@tibems01:~# apt-get install libaio1

3) Update the stores-db.conf file.

[$sys.failsafe]
type=dbstore
dbstore_driver_url=jdbc:oracle:oci:emsfs/emsfs@oradb11g01:1521:orcl
dbstore_driver_username=emsfs
dbstore_driver_password=emsfs

[$sys.meta]
type=dbstore
dbstore_driver_url=jdbc:oracle:oci:emsmeta/emsmeta@oradb11g01:1521:orcl
dbstore_driver_username=emsmeta
dbstore_driver_password=emsmeta

[$sys.nonfailsafe]
  type=file
  file=/home/tibadmin/ems_ft_cfg/datastore/async-msgs.db
  mode=async
  file_crc=disabled

Start the server pair, with log_trace = DEFAULT, +DBSTORE

Primary (active) server (tibems01)

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 15:35:28.828 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 15:35:28.829 Process Id: 11175
2011-04-19 15:35:28.829 Hostname: tibems01
2011-04-19 15:35:28.829 Hostname IP address: 172.16.10.10
2011-04-19 15:35:28.829 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 15:35:28.829 Detected IP interface: 172.16.10.10 (eth0)
2011-04-19 15:35:28.829 Detected IP interface: 192.168.50.10 (eth1)
2011-04-19 15:35:28.829 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db1.conf'.
2011-04-19 15:35:28.835 Logging into file '/home/tibadmin/ems01.log'
2011-04-19 15:35:28.836 Trying JVM location: /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:35:28.851 Loaded jvm from /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:35:28.851 Added java virtal machine option -Xmx256m
2011-04-19 15:35:28.851 Added java virtal machine option -Djava.class.path=/home/tibadmin/tibco/ems/5.1/bin/tibemsd.jar
2011-04-19 15:35:28.851 Added java virtal machine option -Xrs
2011-04-19 15:35:28.851 Added java virtal machine option -Dems.com.tibco.tibems.tibemsd.internal.version=5.1.5
2011-04-19 15:35:29.024 Java virtual machine started.
2011-04-19 15:35:29.089 Java Version 1.6.0_24
2011-04-19 15:35:29.095 Java server tasks started.
2011-04-19 15:35:29.108 Server name: 'EMS-SERVER'.
2011-04-19 15:35:29.108 Storage Location: '.'.
2011-04-19 15:35:29.108 Routing is disabled.
2011-04-19 15:35:29.108 Authorization is disabled.
2011-04-19 15:35:30.999 Active server 'tcp://tibems02:7222' not found.
2011-04-19 15:35:30.999 Continuing as active server.
2011-04-19 15:35:30.000 Accepting connections on tcp://tibems01:7222.
2011-04-19 15:35:30.000 Recovering state, please wait.
2011-04-19 15:41:45.330 Store '$sys.failsafe' locked by 'EMS-SERVER'
2011-04-19 15:41:45.347 Store '$sys.meta' locked by 'EMS-SERVER'
2011-04-19 15:41:45.347 Store '$sys.meta': Recovering Zone records...
2011-04-19 15:41:45.398 Store '$sys.meta': Recovered <1> Zone records
2011-04-19 15:41:45.398 Store '$sys.meta': Recovering Connection records...
2011-04-19 15:41:45.414 Store '$sys.meta': Recovered <0> Connection records
2011-04-19 15:41:45.415 Recovering transaction records
2011-04-19 15:41:45.415 Store '$sys.meta': Recovering Transaction records...
2011-04-19 15:41:45.427 Store '$sys.meta': Recovered <0> Transaction records
2011-04-19 15:41:45.427 Store '$sys.failsafe': Recovering Transaction records...
2011-04-19 15:41:45.458 Store '$sys.failsafe': Recovered <0> Transaction records
2011-04-19 15:41:45.458 Recovered all transaction records
2011-04-19 15:41:45.458 Store '$sys.meta': Recovering Session records...
2011-04-19 15:41:45.470 Store '$sys.meta': Recovered <0> Session records
2011-04-19 15:41:45.470 Store '$sys.meta': Recovering Consumer records...
2011-04-19 15:41:45.485 Store '$sys.meta': Recovered <0> Consumer records
2011-04-19 15:41:45.486 Store '$sys.meta': Recovering Producer records...
2011-04-19 15:41:45.499 Store '$sys.meta': Recovered <0> Producer records
2011-04-19 15:41:45.499 Store '$sys.meta': Recovering Purge records...
2011-04-19 15:41:45.511 Store '$sys.meta': Recovered <0> Purge records
2011-04-19 15:42:40.661 Recovering valid msg records...
2011-04-19 15:42:40.661 Store '$sys.meta': Recovering Valid records...
2011-04-19 15:43:13.912 Store '$sys.meta': Recovered <0> Valid records
2011-04-19 15:43:13.912 Store '$sys.failsafe': Recovering Valid records...
2011-04-19 15:43:13.982 Store '$sys.failsafe': Recovered <1> Valid records
2011-04-19 15:43:13.982 Recovered all valid msg records
2011-04-19 15:43:13.983 Store '$sys.meta': Recovering Message records...
2011-04-19 15:43:13.985 Store '$sys.failsafe': Recovering Message records...
2011-04-19 15:43:14.252 Store '$sys.failsafe': Recovered <0> Message records
2011-04-19 15:43:14.260 Store '$sys.meta': Recovered <0> Message records
2011-04-19 15:43:14.280 Recovering Ack records
2011-04-19 15:43:14.280 Store '$sys.failsafe': Recovering Ack records...
2011-04-19 15:43:14.302 Store '$sys.failsafe': Recovered <0> Ack records
2011-04-19 15:43:14.302 Recovered all Ack records
2011-04-19 15:43:14.302 Server is active.

Secondary (standby) server (tibems02)

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 15:42:56.457 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 15:42:56.457 Process Id: 2466
2011-04-19 15:42:56.457 Hostname: tibems02
2011-04-19 15:42:56.457 Hostname IP address: 172.16.10.11
2011-04-19 15:42:56.457 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 15:42:56.458 Detected IP interface: 172.16.10.11 (eth0)
2011-04-19 15:42:56.458 Detected IP interface: 192.168.50.11 (eth1)
2011-04-19 15:42:56.458 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db2.conf'.
2011-04-19 15:42:56.462 Trying JVM location: /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:42:56.480 Loaded jvm from /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:42:56.480 Added java virtal machine option -Xmx256m
2011-04-19 15:42:56.480 Added java virtal machine option -Djava.class.path=/home/tibadmin/tibco/ems/5.1/bin/tibemsd.jar
2011-04-19 15:42:56.480 Added java virtal machine option -Xrs
2011-04-19 15:42:56.480 Added java virtal machine option -Dems.com.tibco.tibems.tibemsd.internal.version=5.1.5
2011-04-19 15:42:56.647 Java virtual machine started.
2011-04-19 15:42:56.702 Java Version 1.6.0_24
2011-04-19 15:42:56.708 Java server tasks started.
2011-04-19 15:42:56.710 Server name: 'EMS-SERVER'.
2011-04-19 15:42:56.710 Storage Location: '.'.
2011-04-19 15:42:56.710 Routing is disabled.
2011-04-19 15:42:56.711 Authorization is disabled.
2011-04-19 15:43:14.416 Accepting connections on tcp://tibems02:7222.
2011-04-19 15:43:14.416 Server is in standby mode for 'tcp://tibems01:7222'.

Cheers...getting ready for my Easter holiday trip.

Friday, April 22, 2011

TIBCO EMS FT pair on Oracle Database 11gR2 shared storage

Related article: Read this also

In the previous article I wrote about setting up a TIBCO EMS fault tolerant pair that uses NFSv4 shared folder to store shared states. This article describes the step to set up a database-based shared state datastore.

The end-state is depicted in the following deployment diagram.


This is a 2-in-1 article. One part is to set up the required conf files and set up the Oracle Database 11gR2 for as datastore. The other part is to configure 2 separate tibemsd for the FT pairs.

1) Install hibernate package on the host machine
2) Configure tibemsd-db.conf
3) Configure stores-db.conf
4) Create EMS schema using export tool
5) Test it!

1) Install hibernate package

I will use hibernate 3.2.5 from the package hibernate_3.2.5_linux24gl23_x86.zip

1.1 Unzip the package into you temp folder.
1.2 run TIBCOUniversalInstaller-lnx-x86.bin as tibadmin, created earlier in this article.
1.3 Follow the steps in the screens below.

2) Configure tibemsd-db.conf

tibemsd-db.conf is a sample file located in $EMS_HOME/tibco/ems/5.1/sample/config folder. Copy this file from $EMS_HOME/tibco/ems/5.1/sample/config into your shared state directory.

Edit the tibemsd-db.conf and modify the following lines.

users                   = /home/tibadmin/ems_ft_cfg/users.conf
groups                  = /home/tibadmin/ems_ft_cfg/groups.conf
topics                  = /home/tibadmin/ems_ft_cfg/topics.conf
queues                  = /home/tibadmin/ems_ft_cfg/queues.conf
acl_list                = /home/tibadmin/ems_ft_cfg/acl.conf
factories               = /home/tibadmin/ems_ft_cfg/factories.conf
routes                  = /home/tibadmin/ems_ft_cfg/routes.conf
bridges                 = /home/tibadmin/ems_ft_cfg/bridges.conf
transports              = /home/tibadmin/ems_ft_cfg/transports.conf
tibrvcm                 = /home/tibadmin/ems_ft_cfg/tibrvcm.conf
durables                = /home/tibadmin/ems_ft_cfg/durables.conf
channels                = /home/tibadmin/ems_ft_cfg/channels.conf
stores                  = /home/tibadmin/ems_ft_cfg/stores-db.conf

dbstore_classpath       = /home/tibadmin/tibco/components/eclipse/plugins/com.tibco.tpcl.org.hibernate_3.2.5.001/hibernate3.jar:/home/tibadmin/tibco/components/eclipse/plugins/com.tibco.tpcl.org.com.mchange.c3p0_0.9.1.001/c3p0-0.9.1.jar:/home/tibadmin/tibco/ems/5.1/bin/antlr-2.7.6.jar:/home/tibadmin/tibco/ems/5.1/bin/asm-attrs.jar:/home/tibadmin/tibco/ems/5.1/bin/asm.jar:/home/tibadmin/tibco/ems/5.1/bin/cglib-2.1.3.jar:/home/tibadmin/tibco/ems/5.1/bin/commons-collections-2.1.1.jar:/home/tibadmin/tibco/ems/5.1/bin/commons-logging-1.0.4.jar:/home/tibadmin/tibco/ems/5.1/bin/dom4j-1.6.1.jar:/home/tibadmin/tibco/ems/5.1/bin/ehcache-1.2.3.jar:/home/tibadmin/tibco/ems/5.1/bin/jta.jar:/home/tibadmin/tibco/ems/5.1/lib/ojdbc5.jar

dbstore_driver_name     = oracle.jdbc.driver.OracleDriver
dbstore_driver_dialect  = org.hibernate.dialect.Oracle10gDialect
jre_library             = /opt/java/jre/lib/i386/server/libjvm.so
jre_option   = -Xmx256m

3) Configure stores-db.conf

stores-db.conf is a sample stores.conf file located in $EMS_HOME/tibco/ems/5.1/sample/config folder. Copy this file from $EMS_HOME/tibco/ems/5.1/sample/config into your shared state directory.

[$sys.failsafe]
type=dbstore
dbstore_driver_url=jdbc:oracle:thin:emsfs/emsfs@//oradb11g01:1521/orcl
dbstore_driver_username=emsfs
dbstore_driver_password=emsfs

[$sys.meta]
type=dbstore
dbstore_driver_url=jdbc:oracle:thin:emsmeta/emsmeta@//oradb11g01:1521/orcl
dbstore_driver_username=emsmeta
dbstore_driver_password=emsmeta

#store the non failsafe message in NFS drive.
[$sys.nonfailsafe]
  type=file
  file=/home/tibadmin/ems_ft_cfg/datastore/async-msgs.db
  mode=async
  file_crc=disabled


4) Create EMS schema using export tool

TIBCO EMS comes with a tool to create the required database schema for shared states and message storage.

Before you use the tool, ensure the TIBCO EMS host has the required database connectivity. Though you only need the Oracle JDBC java library (ojdbc5.jar) to be in the classpath, I suggest that you install the entire package of Oracle Instant Client for Linux (instantclient-basic-linux32-11.2.0.2.0.zip).

Next, create an oracle db user for each EMS data store of type dbstore.

for meta dbstore
GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO emsmeta IDENTIFIED BY emsmeta;

ALTER USER emsmeta DEFAULT TABLESPACE USERS;

ALTER USER emsmeta TEMPORARY TABLESPACE TEMP;

for failsafe dbstore

GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO emsfs IDENTIFIED BY emsfs ;

ALTER USER emsfs DEFAULT TABLESPACE USERS;

ALTER USER emsfs TEMPORARY TABLESPACE TEMP;

Note: The userid and password must be same is the one specified in the store-db.conf file in step 3.

After you have created the EMS oracle user, execute the tibemsd_util.jar as follow. The util is located under $EMS_HOME/bin where EMS_HOME is /home/tibadmin/tibco/ems/5.1 in my case.

java -jar tibemsd_util.jar -tibemsdconf /home/tibadmin/ems_ft_cfg/tibemsd-db1.conf -createall -export

You should see the following output on the stdout.

drop table ACK_RECS cascade constraints
drop table CONNECTION_RECS cascade constraints
drop table CONSUMER_RECS cascade constraints
drop table CONSUMER_RECS_IMPSELMAP cascade constraints
drop table EMS_HBLOCK_TABLE cascade constraints
drop table EMS_MESSAGES cascade constraints
drop table EMS_SYS_RECORDS_TABLE cascade constraints
drop table PRODUCER_RECS cascade constraints
drop table PURGE_RECS cascade constraints
drop table SESSION_RECS cascade constraints
drop table TXN_RECS cascade constraints
drop table VALID_MSGS_RECORD cascade constraints
drop table VALID_MSGS_RECORD_HELDMSGS cascade constraints
drop table VALID_MSGS_RECORD_HOLDMSGS cascade constraints
drop table VALID_MSGS_RECORD_NOHOLDMSGS cascade constraints
drop table ZONE_RECS cascade constraints
drop sequence hibernate_sequence
create table ACK_RECS (ACK_RECORD_ID number(19,0) not null, CONSUMER_ID number(19,0), SEQNO number(19,0), DISCARD_ACK_FLAG number(1,0), TXN_ID number(19,0), SESS_ID number(19,0), CONN_ID number(19,0), primary key (ACK_RECORD_ID))
create table CONNECTION_RECS (STORE_ID number(19,0) not null, CONNECTION_ID number(19,0), CONNECTION_TYPE number(10,0), CLIENT_ID varchar2(256 char), CONNECTION_USER varchar2(256 char), NEW_TEMP_DESTS_FLAG number(1,0), primary key (STORE_ID))
create table CONSUMER_RECS (STORE_ID number(19,0) not null, CONSUMER_ID number(19,0), SESSION_ID number(19,0), CONNECTION_ID number(19,0), DURABLE_NAME varchar2(255 char), SUBSCRIPTION_NAME varchar2(255 char), CLIENT_ID varchar2(255 char), ZONE_ID number(10,0), SELECTOR_STRING varchar2(4000 char), SELECTOR_BYTES long raw, NO_LOCAL number(1,0), CONNECTION_CONSUMER number(1,0), DESTINATION varchar2(255 char), DEST_TYPE number(3,0), CONSUMER_MSG_SEQNO number(19,0), MULTICAST_FLAG number(1,0), primary key (STORE_ID))
create table CONSUMER_RECS_IMPSELMAP (StoreId number(19,0) not null, HASHMAP_VALUE varchar2(255 char), HASHMAP_KEY varchar2(255 char) not null, primary key (StoreId, HASHMAP_KEY))
create table EMS_HBLOCK_TABLE (id number(19,0) not null, last_update timestamp not null, server_id varchar2(255 char) not null, JDBCURL varchar2(4000 char) not null, primary key (id))
create table EMS_MESSAGES (STORE_ID number(19,0) not null, MESSAGE_SEQNO number(19,0), TYPE number(3,0), PRIORITY number(3,0), DELIVERYMODE number(3,0), REDELIVERED number(3,0), DESTINATION varchar2(255 char), DESTINATION_TYPE number(3,0), EXPIRATION number(19,0), TIMESTAMP number(19,0), REPLYTO varchar2(255 char), REPLYTO_TYPE number(3,0), USERTYPE varchar2(255 char), MSGID varchar2(255 char), CORRELATIONID varchar2(255 char), COMPRESSED number(1,0), CLIENTFLAGS number(19,0), ENCODING varchar2(255 char), ENCODED_PROPERTIES raw(1024), ENCODED_SUPPRESS_CONSIDS raw(1024), TXNID number(19,0), ZONEID number(19,0), ROUTESRC varchar2(255 char), ROUTESEQNO number(19,0), ROUTECONSID number(19,0), PRODUCERID number(19,0), DELETED number(1,0) not null, MESSAGE_SIZE number(19,0), SMALL_MESSAGE_BODY raw(1024), LARGE_MESSAGE_BODY blob, primary key (STORE_ID))
create table EMS_SYS_RECORDS_TABLE (SYSTEM_REC_ID number(19,0) not null, VERSION varchar2(255 char), EMS_START_TIME varchar2(255 char), EMS_UPDATE_TIME varchar2(255 char), primary key (SYSTEM_REC_ID))
create table PRODUCER_RECS (STORE_ID number(19,0) not null, PRODUCER_ID number(19,0), SESSION_ID number(19,0), CONNECTION_ID number(19,0), DESTINATION varchar2(255 char), DEST_TYPE number(3,0), primary key (STORE_ID))
create table PURGE_RECS (PURGE_RECORD_ID number(19,0) not null, DEST_NAME varchar2(255 char), DEST_TYPE number(3,0), SEQ_NO number(19,0), primary key (PURGE_RECORD_ID))
create table SESSION_RECS (STORE_ID number(19,0) not null, SESSION_ID number(19,0), CONNECTION_ID number(19,0), ACKNOWLEDGE_MODE number(10,0), TRANSACTED number(1,0), IS_XA number(1,0), MSGID_PREFIX varchar2(255 char), primary key (STORE_ID))
create table TXN_RECS (TXNREC_STORE_ID number(19,0) not null, SESS_ID number(19,0), TXN_ID number(19,0), RECORD_ID number(19,0), TXN_STATE number(10,0), XID raw(1024), primary key (TXNREC_STORE_ID))
create table VALID_MSGS_RECORD (VALID_MSG_RECORD_ID number(19,0) not null, ACTIVE_HI_SEQ number(19,0), SMALL_MESSAGE_BODY raw(1024), LARGE_MESSAGE_BODY blob, primary key (VALID_MSG_RECORD_ID))
create table VALID_MSGS_RECORD_HELDMSGS (id number(19,0) not null, HELD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table VALID_MSGS_RECORD_HOLDMSGS (id number(19,0) not null, HOLD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table VALID_MSGS_RECORD_NOHOLDMSGS (id number(19,0) not null, NO_HOLD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table ZONE_RECS (STORE_ID number(19,0) not null, ZONE_ID number(10,0), ZONE_NAME varchar2(255 char), ZONE_TYPE number(5,0), primary key (STORE_ID))
alter table CONSUMER_RECS_IMPSELMAP add constraint FKD1B84D7B3B9C4484 foreign key (StoreId) references CONSUMER_RECS
create index DEL_IDX on EMS_MESSAGES (DELETED)
alter table VALID_MSGS_RECORD_HELDMSGS add constraint FK5908794BC44ABBE5 foreign key (id) references VALID_MSGS_RECORD
alter table VALID_MSGS_RECORD_HOLDMSGS add constraint FK6A06C9D5C44ABBE5 foreign key (id) references VALID_MSGS_RECORD
alter table VALID_MSGS_RECORD_NOHOLDMSGS add constraint FK610EB196C44ABBE5 foreign key (id) references VALID_MSGS_RECORD
create sequence hibernate_sequence

Note: For some reasons the required tables are not created in database, probably due to missing/incorrect configuration of hibernate ddl properties.

Anyway, I have converted the output above into a sql script and simply run them with sqlplus.

[oradb11g01 $] sqlplus emsmeta/emsmeta @meta.sql
[oradb11g01 $] sqlplus emsfs/emsfs @fs.sql

This following paragraphs describe the step to setting up a FT pair.

Make 2 copies of the tibemsd-db.conf files made in step 1. Call them tibemsd-db1.conf and tibemsd-db2.conf respectively.

In both files, make sure the stores parameter points to the same conf file.

stores                  = /home/tibadmin/ems_ft_cfg/stores-db.conf

In each files, do the following:

tibemsd-db1.conf

listen = tcp://tibems01:7222
ft_active = tcp://tibems02:7222

tibemsd-db2.conf

listen = tcp://tibems02:7222
ft_active = tcp://tibems01:7222

The config file referencing can be visualised in the following picture.


Start EMS on both servers using tibemsd-db1.conf and tibemsd-db2.conf, in any sequence. The EMS FT pair on Oracle Database 11g R2 are now operational.

tibadmin@tibems02:~/ems_ft_cfg$ startEMS-db.sh 

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 06:02:33.785 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 06:02:33.785 Process Id: 1629
2011-04-19 06:02:33.786 Hostname: tibems02
2011-04-19 06:02:33.786 Hostname IP address: 172.16.10.11
2011-04-19 06:02:33.786 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 06:02:33.786 Detected IP interface: 172.16.10.11 (eth0)
2011-04-19 06:02:33.786 Detected IP interface: 192.168.50.11 (eth1)
2011-04-19 06:02:33.786 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db2.conf'.
2011-04-19 06:02:34.891 Java Version 1.6.0_24
2011-04-19 06:02:34.904 Server name: 'EMS-SERVER'.
2011-04-19 06:02:34.904 Storage Location: '.'.
2011-04-19 06:02:34.904 Routing is disabled.
2011-04-19 06:02:34.904 Authorization is disabled.
2011-04-19 06:02:37.451 Active server 'tcp://tibems01:7222' not found.
2011-04-19 06:02:37.451 Continuing as active server.
2011-04-19 06:02:37.456 Accepting connections on tcp://tibems02:7222.
2011-04-19 06:02:37.456 Recovering state, please wait.
2011-04-19 06:04:13.561 Store '$sys.failsafe' locked by 'EMS-SERVER'
2011-04-19 06:04:13.561 Creating system record for store '$sys.failsafe' ...
2011-04-19 06:04:13.660 Store '$sys.meta' locked by 'EMS-SERVER'
2011-04-19 06:04:13.660 Creating system record for store '$sys.meta' ...
2011-04-19 06:04:14.342 Server is active.
2011-04-19 06:06:00.481 Backup server 'EMS-SERVER@tibems01' has connected.

tibadmin@tibems01:~/ems_ft_cfg$ startEMS-db.sh 

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 06:05:58.102 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 06:05:58.103 Process Id: 10071
2011-04-19 06:05:58.103 Hostname: tibems01
2011-04-19 06:05:58.103 Hostname IP address: 172.16.10.10
2011-04-19 06:05:58.103 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 06:05:58.103 Detected IP interface: 172.16.10.10 (eth0)
2011-04-19 06:05:58.103 Detected IP interface: 192.168.50.10 (eth1)
2011-04-19 06:05:58.103 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db1.conf'.
2011-04-19 06:05:58.410 Java Version 1.6.0_24
2011-04-19 06:05:58.419 Server name: 'EMS-SERVER'.
2011-04-19 06:05:58.419 Storage Location: '.'.
2011-04-19 06:05:58.419 Routing is disabled.
2011-04-19 06:05:58.420 Authorization is disabled.
2011-04-19 06:06:00.401 Accepting connections on tcp://tibems01:7222.
2011-04-19 06:06:00.401 Server is in standby mode for 'tcp://tibems02:7222'.

Lastly, I have a Gigabit connection between the EMS host and the DB host, so I will just let the shared state traffic to pass through my MSG_VLAN. For detail of the Laboratory network topology, refer to this article.

Cheers,

Wednesday, April 20, 2011

TIBCO EMS 5.1.5 Ubuntu Fault Tolerant Pair On NFS

If you'd like to jump the gun and try out the FT pair on Oracle Database, then this article is for you.

In the previous article, I briefly wrote about setting a file-based shared state TIBCO EMS FT pair on Windows platform. This article shows you how to install TIBCO EMS on linux hosts for fault tolerance configuration. The installations will use NFSv4 mounted folder for the shared states.

TIBCO EMS 5.1 is supported on the following Unix/Linux distributions under Intel Architecture.
  • Novell SUSE Linux Enterprise 10
  • Red Hat Enterprise Linux 4
  • Oracle Enterprise Linux 4
  • Mac OS X 10.4+
  • Solaris 10
Though not officially supported on Ubuntu, the installation of TIBCO EMS 5.1.5 on Ubuntu Linux is very straight forward.

This article shows you the installation made under a non-root user. If you need to use multicast you will need to start the daemon as root. I personally do not like to use setuid on the files.

There are 2 possible options when setting up FT pair using NFS storage.

1) Shared binary folder, such as /mountpoint/tibco
2) Independent binary folders on each EMS hosts, such as /home/tibadmin/tibco

In both options, the intances will use a shared NFS mountpoint for the shared states.

I have picked option 2 for my environment because I want to be able to run a single instance of TIBCO EMS if my Openfiler service is unavailable.

The installation package of TIBCO EMS 5.1.5 is TIB_ems_5.1.5_linux26gl23_x86.tar.gz

To install TIBCO EMS 5.1.5, follow the following steps:

1) Create a user account that you will use to install and run your EMS

#mkdir -p /home/tibadmin
#groupadd -g 1002 tibadmin
#useradd -u 1002 -g tibadmin tibadmin -s /bin/bash -d /home/tibadmin
#chown -R tibadmin:tibadmin /home/tibadmin

Note the uid and gid down, we will need to create a user with identical uid and gid on the Openfiler server in the absence of NIS or LDAP. This is a very important step for the NFSv4 idmap to work properly.

Login as tibadmin

#su - tibadmin
$

2) Copy the installation package into a temp folder. Make sure it is owned by tibadmin:tibadmin

$sudo chown tibadmin:tibadmin TIB_ems_5.1.5_linux26gl23_x86.tar.gz

3)Unzip the installation package

$gzip -d TIB_ems_5.1.5_linux26gl23_x86.tar.gz

4) Untar the tarball

$tar -xvf TIB_ems_5.1.5_linux26gl23_x86.tar

5) Execute the extracted installation binary

$./TIBCOUniversalInstaller-lnx-x86.bin

Follow the steps in the screens below.









6) Install the libstdc++5 package. This is required because Ubuntu 10.10 comes with libstdc++6 and not libstdc++5. Download the package (google it!) and install as follow.

dpkg -i libstdc++5_3.3.6-20_i386.deb

Repeat step 1 to 5 on another server instance, in my case it is tibems02.

Up to now, we have 2 instances of TIBCO EMS local installations. The next step is to set up the shared storage for the FT pair.

To set up a shared storage for the configuration files and message persistence, I use openFiler NAS and mount the exported directory using NFSv4 client.

1) ssh into the openfiler sever from any host with connectivity to the NFS server.

tibadmin@tibems01:~$ssh root@openfiler
root@openfiler's password: 
Last login: Wed Apr 20 12:40:18 2011 from 192.168.13.101
[root@openfiler ~]# 

2) Create tibadmin user on the openfiler server

[root@openfiler ~]# groupadd -g 1002 tibadmin
[root@openfiler ~]# useradd -u 1002 -g tibadmin -s /sbin/nologin tibadmin
[root@openfiler ~]# id tibadmin
uid=1002(tibadmin) gid=1002(tibadmin) groups=1002(tibadmin)
[root@openfiler ~]# 

3) Setup the shared filesystem exports from openfiler (or on your favourite Linux/UNIX distributions).

4) Edit the /etc/exports file on NFS server. Add fsid=0, you should see something similar to this.

openfiler1:/yoursharedfolderforemsconfig 192.168.50.10 (rw,fsid=0,no_subtree_check,no_root_squash,sync) 192.168.50.11 (rw,fsid=0,no_subtree_check,no_root_squash,sync)

Note 1: 192.168.50.10 and 192.168.50.11 are IP address NAS NIC's of my EMS hosts. Refer to this VMWare ESXi infrastructure for the full picture.

Note 2: The fsid=0 option will will be removed if you change the NFS share configurations from the webgui of openfiler. Just back up a copy of /etc/exports file, in case it is overwritten you always have a copy of it.

Note 3: While it is not the best practice to setup a NFSv4 export without a well thought through pseudo-filesystem, this configuration meets my initial requirement.

If you have time, you should look at setting up the psuedo-fs in this way.

                   /tibco (fsid=0,ro)
                            |
             -------------------------------
            |            |                  |
        ems_ft_cfg   ems_logging    ems_ft_datastore

On the clients (tibems01 and tibems02), the shared folder is mounted with the following mount options, specified in the /etc/fstab file. Note the nfs4 in particular.

$mkdir -p /home/tibadmin/ems_ft_cfg
$mount -t nfs4 -o rw openfiler1:/ home/tibadmin/ems_ft_cfg

I am not sure if NFS exported by OpenFiler meets the fault tolerance storage criteria. At least according to the TIBCO EMS User Guide, Chapter 5, the fnctl() POSIX file locking semantic on NFSv4 should work. For compliance to other criteria, a separate test is required.

struct flock fl;
 int err;
 fl.l_type = F_WRLCK;
 fl.l_whence = 0;
 fl.l_start = 0;
 fl.l_len = 0;
 err = fcntl(file, F_SETLK, &fl);

To setup for FT, the next step is to prepare the conf files on both servers (tibems01 and tibems02) and point them to the NFSv4 exported folder mouted under home/tibadmin/ems_ft_cfg.

1) Copy all the files from the sample/config directory (/home/tibadmin/tibco/ems/5.1/samples/config) into /home/tibadmin/ems_ft_cfg

tibadmin@tibems01:/$ cp /home/tibadmin/tibco/ems/5.1/samples/config/* /home/tibadmin/ems_ft_cfg/

2) Create a sub-folder under /home/tibadmin/ems_ft_cfg, name it "datastore" (it becomes "/home/tibadmin/ems_ft_config/datastore")

tibadmin@tibems01:/$ mkdir /home/tibadmin/ems_ft_cfg/datastore

3) Edit /home/tibadmin/ems_ft_cfg/tibemsd.conf, populate the following configuration parameters.

users                   = /home/tibadmin/ems_ft_cfg/users.conf
 groups                  = /home/tibadmin/ems_ft_cfg/groups.conf
 topics                  = /home/tibadmin/ems_ft_cfg/topics.conf
 queues                  = /home/tibadmin/ems_ft_cfg/queues.conf
 acl_list                = /home/tibadmin/ems_ft_cfg/acl.conf
 factories               = /home/tibadmin/ems_ft_cfg/factories.conf
 routes                  = /home/tibadmin/ems_ft_cfg/routes.conf
 bridges                 = /home/tibadmin/ems_ft_cfg/bridges.conf
 transports              = /home/tibadmin/ems_ft_cfg/transports.conf
 tibrvcm                 = /home/tibadmin/ems_ft_cfg/tibrvcm.conf
 durables                = /home/tibadmin/ems_ft_cfg/durables.conf
 channels                = /home/tibadmin/ems_ft_cfg/channels.conf
 stores                  = /home/tibadmin/ems_ft_cfg/stores.conf
   
 store                   = /home/tibadmin/ems_ft_cfg/datastore

 max_msg_memory          = 256MB

 #uncomment accordingly
  ft_active               = tcp://tibems01:7222
 #ft_active               = tcp://tibems02:7222

 ft_heartbeat            = 3
 ft_activation           = 10
 ft_reconnect_timeout    = 60

4) Make 2 copies of the tibemsd.conf files. One as tibemsd1.conf, the other as tibemsd2.conf. In tibemsd2.conf, comment out the appropriate ft_active parameter.

#ft_active               = tcp://tibems01:7222
 ft_active               = tcp://tibems02:7222

Summary:
For Primary instance

listen = tcp://tibems01:7222
ft_active = tcp://tibems02:7222

For secondary instance

listen = tcp://tibems02:7222
ft_active = tcp://tibems01:7222

To start the primary and secondary servers.

Login to tibems01 as tibadmin
tibadmin@tibems01:cd ~/tibco/ems/5.1/bin
tibadmin@tibems01:~/tibco/ems/5.1/bin$./tibemsd -config /home/tibadmin/ems_ft_cfg/tibemsd1.conf

You should see this.

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-16 03:27:01.550 Process started from './tibemsd'.
2011-04-16 03:27:01.550 Process Id: 1469
2011-04-16 03:27:01.550 Hostname: tibems01
2011-04-16 03:27:01.551 Hostname IP address: 172.16.10.10
2011-04-16 03:27:01.551 Detected IP interface: 127.0.0.1 (lo)
2011-04-16 03:27:01.551 Detected IP interface: 172.16.10.10 (eth0)
2011-04-16 03:27:01.551 Detected IP interface: 192.168.50.10 (eth1)
2011-04-16 03:27:01.551 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd1.conf'.
2011-04-16 03:27:01.582 Server name: 'EMS-SERVER'.
2011-04-16 03:27:01.582 Storage Location: '/home/tibadmin/ems_ft_cfg/datastore'.
2011-04-16 03:27:01.582 Routing is disabled.
2011-04-16 03:27:01.582 Authorization is disabled.
2011-04-16 03:27:01.681 Active server 'tcp://tibems02:7222' not found.
2011-04-16 03:27:01.681 Continuing as active server.
2011-04-16 03:27:01.686 Accepting connections on tcp://tibems01:7222.
2011-04-16 03:27:01.687 Recovering state, please wait.
2011-04-16 03:27:02.017 Server is active.


Login to tibems02 as tibadmin

tibadmin@tibems02:cd ~/tibco/ems/5.1/bin
tibadmin@tibems02:~/tibco/ems/5.1/bin$./tibemsd -config /home/tibadmin/ems_ft_cfg/tibemsd2.conf

You should see this.
TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-16 03:31:45.008 Process started from './tibemsd'.
2011-04-16 03:31:45.009 Process Id: 15288
2011-04-16 03:31:45.009 Hostname: tibems02
2011-04-16 03:31:45.009 Hostname IP address: 172.16.10.11
2011-04-16 03:31:45.009 Detected IP interface: 127.0.0.1 (lo)
2011-04-16 03:31:45.009 Detected IP interface: 172.16.10.11 (eth0)
2011-04-16 03:31:45.009 Detected IP interface: 192.168.50.11 (eth1)
2011-04-16 03:31:45.009 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd2.conf'.
2011-04-16 03:31:45.020 Server name: 'EMS-SERVER'.
2011-04-16 03:31:45.020 Storage Location: '/home/tibadmin/ems_ft_cfg/datastore'.
2011-04-16 03:31:45.020 Routing is disabled.
2011-04-16 03:31:45.020 Authorization is disabled.
2011-04-16 03:31:45.076 Accepting connections on tcp://tibems02:7222.
2011-04-16 03:31:45.076 Server is in standby mode for 'tcp://tibems01:7222'.

Note: One the primary server, it has detected that the secondary server is up and connected.

2011-04-16 03:31:45.075 Backup server 'EMS-SERVER@tibems02' has connected.

Now try to shutdown the primary server, the secondary server will become active.

2011-04-16 03:41:47.082 Connection to primary server 'tcp://tibems01:7222' has been lost.
2011-04-16 03:41:47.083 Server activating on failure of 'tcp://tibems01:7222'.
2011-04-16 03:41:47.083 Server rereading configuration.
2011-04-16 03:41:47.126 Recovering state, please wait.
2011-04-16 03:41:47.135 Server is now active.

Cheers,

Thursday, March 3, 2011

Basic TIBCO EMS file-based-storage, shared state Fault Tolerance Configuration

The official TIBCO EMS documentation has detailed the steps required to setup a functional Fault Tolerance server pair. I made a summary of the steps below for those who are in hurry.

WARNING: This is not a production configuration as it lacks of security enforcement such as ssl communication between servers. The the file system where the shared storage resides (which is NTFS) may not meet the criteria (Write Order, Synchronous Write Persistence, Distributed File Locking, Unique Write Ownership - refer to the official documentations) for Fault Tolerance. The shared storage folder in local drive is for quicky PoC only. The tibemsd.conf files may contain default parameter values that do not meet your operation scenarios.

New! - FT Pair on NFS
New! - FT Pair on Oracle

In scope:
- FT pair with shared state, file-based
- Inspect the propagation of a new topic into backup server when Fail-over takes place
- FT pair with sever authorization = enabled

Not in scope:
- SSL requirements
- Client configurations for FT connections
- Shared application binary folders for both participating servers
- Testing of client fail-over (it would probably not work because storage criteria are not met)

Tools:
Notepad++
DOS command line prompt

Bill of materials:
Installation of TIBCO EMS 5.1.x (1x)
tibemsd.conf (2x, 1 for primary sever, 1 for backup server)
Windows XP host (1x, we will use different listening ports for both severs so they can co-exist in the same host)

Schematic of Fault Tolerance EMS Server Pair Configuration, shared state (from the official doco).



Preparing the tibemsd.conf for the first server
1) Create a local folder in you local drive, name it "ems_ft_config"
2) Create a sub-folder under that folder, name it "datastore" (it becomes "ems_ft_config\datastore")
3) Copy tibemsd.conf from the sample folder of your TIBCO EMS installation. In my host, it is "C:\tibco\ems\5.1\samples\config"
4) Paste tibemsd.conf into "ems_ft_config", rename it to tibemsd1.conf
5) Edit tibemsd1.conf with your favorite text editor. Update the following parameters

users                   = x:\ems_ft_config\users.conf
 groups                  = x:\ems_ft_config\groups.conf
 topics                  = x:\ems_ft_config\topics.conf
 queues                  = x:\ems_ft_config\queues.conf
 acl_list                = x:\ems_ft_config\acl.conf
 factories               = x:\ems_ft_config\factories.conf
 routes                  = x:\ems_ft_config\routes.conf
 bridges                 = x:\ems_ft_config\bridges.conf
 transports              = x:\ems_ft_config\transports.conf
 tibrvcm                 = x:\ems_ft_config\tibrvcm.conf
 durables                = x:\ems_ft_config\durables.conf
 channels                = x:\ems_ft_config\channels.conf
 stores                  = x:\ems_ft_config\stores.conf
 
  
 store                   = x:\ems_ft_config\datastore

 
 ft_active               = tcp://your-ip-address:7224
 ft_heartbeat            = 3
 ft_activation           = 10
 ft_reconnect_timeout    = 60

6) Save the file.
7) Make another copy of tibemsd1.conf, name it tibesmd2.conf. Update the following parameters (note: replace 'x' with  your drive letter)

ft_active               = tcp://your-ip-address:7222

8) Save the file.
9) Open a command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
10) Execute the following command

tibemsd -config x:\ems_ft_config\tibemsd1.conf

You should see the server startup traces in the stdout.



Let's examine the output.

(1) The server is started with tibemsd1.conf file
(2) It is trying to contact the server specified in the ft_active parameter, but could find the server (could be it was down, we haven't started it, or there was a connection problem to the target server.
(3) It decided to startup as active server (as opposed to 'backup server), and start listening on port 7222 as specified in the 'listen' parameter.
(4) Because it knows that itself is part of a FT pair, it performs the state recovery step.

Up to this stage, all is running as expected.

11) Open another command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
12) Execute the following command

tibemsd -config x:\ems_ft_config\tibemsd2.conf

You should see the server startup traces in the stdout.


Let's examine the output.

(1) The server is started with tibemsd2.conf file
(2) It starts listening on port 7224 as specified in the 'listen' parameter of tibemsd2.conf file
(3) This time, it has started itself in standy mode because it has detected an active EMS server specified in the ft_active parameter.

On the primary server, the trace shows that the secondary server has been accepted as the standby server.


Using tibemsadmin, connect to each server and issue a command 'show server'. It provides the summary of the server, as you can see from the following images. The first server is the 'active' sever, and the second server is the 'standby server'.

Primary Server

Secondary Server

Examine one of the fail-over behaviour.

We will examine the behaviour of the backup server after it re-reads the configuration. First we add a new topic into the active server by using tibemsadmin tool.

1) Open another command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
2) Execute the following command to connect to the primary sever (make sure that you have this server as the active sever)

tibemsadmin -server tcp://192.168.13.200:7222 -user admin

3) Press enter when asked for password, because we don't have one
4) Create a new topic called topiccreatedin7222 by issueing the following command at the admin prompt[tcp://192.168.13.200:7222> ]

tcp://192.168.13.200:7222> create topic topiccreatedin7222



5) Shut down the active server by issuing a 'shutdown' command at the admin prompt and answer 'yes' to the confirmation question.

tcp://192.168.13.200:7222> shutdown

You will see that the active server is shutdown, and the standy server resume it's operation as the primary server.



6) Connect to the now active primary server

tibemsadmin -server tcp://192.168.13.200:7224 -user admin

7) Issue the command 'show topics' at the admin prompt

tcp://192.168.13.200:7224> show topics

You now see that the topic created in the previously active server is now served in this new instance of active server.



Enabling server authorization for TIBCO EMS Fault Tolerance pair -> Available here.

Wednesday, October 13, 2010

Consuming TIBCO EMS Topic Message from Oracle SOA 11g Application

The previous article describes how FileGateway publishes its data transformation completion event. We will see in this article how another application consumes this event.

In this example, we will create a simple Oracle SOA 11g Application that contains a JMS listener and a file writer.

The use case
Trigger:
JMS Message arrives in FGW.FILEREADY topic.

Flow:
1. JMS adapter receives message.
2. Mediator component maps the input (JMS body) to the input of a File Adapter.
3. File adapter writes the JMS message body into a local file.
4. End of use case.

The Steps
1. Create an empty Oracle SOA 11g Application. Name it as DataLoader. Create a new project called WaitFile within DataLoader. Ensure the fileInfo.xsd created in the previous article is included in this project.

Figure 1: Empty Oracle SOA Application in JDeveloper, with fileInfo.xsd

2. Configure the JMS Adapter
Double click on the composite.xml to open the composite editor. From the "Component Palette" on the right, drag the "JMS Adapter" into the "Exposed Services" pane of the composite editor.

Configure the following:
  • In Step 2 - Service name: WaitFile
  • In Step 3 - Select Third Party JMS Provider
  • In Step 4 - JMS Connection JNDI Name: eis/tibjmsDirect/Topic
  • In Step 5 - Select Define from operation and schema (specified later)
  • In Step 6 - Operation Type: Consume Message, Operation Name: Consume_Message
  • In Step 7 - Destination Name: FGW.FILEREADY. This is the topic name defined in the TIBCO EMS.
  • In Step 8 - Browse for fileInfo in the xsd file.WaitFile
    • Figure 2: Browse Message Schema
    • In Step 9 - Click Finish

    3. Configure the File Adapter
    From the "Component Palette" on the right, drag the "File Adapter" into the "External Refereces" pane of the composite editor.

    Configure the following:
    • In Step 2 - Service name: WriteFileInfo
    • In Step 3 - Select Define from operation and schema (specified later)
    • In Step 4 - Operation Type: Write File, Operation Name: Write
    • In Step 5 - Directory for Outgoing File (physical path): C:\. File Naming Convention (po_%SEQQ%.txt): fileInfo_%SEQ%.txt
    • In Step 6 - Browse for fileInfo in the xsd file.WaitFile
    • In Step 7 - Click Finish

    4. Configure the Mediator
    From the "Component Palette" on the right, drag the "Mediator" into the "Components" pane of the composite editor.

    Configure the following:
    • Name: Mediator1
    • Template: Define Interface Later
    • Click the OK button

    5. Wiring the service, component and reference in the composite.



    Figure 3: Wired service, component and reference

    6. Configure the Mediator
    Double-click the "Medialtor1" component to bring up the mapper. Create a new mapper file, accept the default file name.


    Figure 4: Create new transformation map


    Drag to map the entire source node (imp1:fileInfo) to target node (imp1:fileInfo)

    Figure 5: Mapped source and target

    7. Configure the JMS Module in Oracle SOA Admin Server console
    Make sure your SOA Admin server is started for your domain. Point your browser to http://localhost:7001/console assuming your server runs locally.

    Under the "Domain Structure" menu, click on the "Deployments" menu. Locate the "JmsAdapter" in the Deployments table. Click on the "JmsAdapter", the setting page of "JmsAdapter" is displayed.

    Figure 6: Domain Structure -> Deployments

    Instead of creating a new JMS connection pool, we will just modify the existing pool, for the sake of simplicity. You can always create your own connection pool dedicated to consuming messages from the FileGateway.

    Click on the Configuration tab, then the Outbound Connection Pools sub-tab. Then click on the "eis/tibjmsDirect/Topic"


    Figure 7: Outbound Connection Pool table

    In the "Properties" tab of "eis/tibjmsDirect/Topic", enter the required parameter values for FactoryProperties, Password and Username, then click "Save"

    Figure 8: Connection pool property configuration

    You need to re-deploy the JmsAdapter for the change to be effective. The changes you have made will be stored in a deployment plan.

    Back to the "Deployments" menu. Check the checkbox to the left of "JmsAdapter" and click the "Update" button at the top of the "Deployments" table. Re-deploy the application, create a new plan if necessary.

    Figure 9: Update JmsAdapter deployment

    Figure 10: Deployment plan

    Figure 11: Deployment plan

    8. Deploy the WaitFile SOA 11g application into the soa_server1. (assuming you have created a soa managed server)

    Figure 12: WaitFile composite deployed

    9. Start TIBCO EMS server (make sure you have carried out the steps described in this article). Run FileGateway in TIBCO Designer test mode. A JMS message should be sent out as soon as the data transformation is completed.

    10. Inspect the execution trail and instance information in the dashboard of WaitFile composite.

    Figure 13: Dashboard

    11. Inspect the File adapter output file in the output directory.
    We configured the file adapter to output in c:\, so you should find a file "fileInfo.txt" under this folder. Open the file and inspect the content, you should get something like this.

    
       EMP-OUT00A-20101013-10-21-56.XML
       1646
       2010-10-13T10:21:56.296+11:00
       
          
          
          
          
       
    
    

    Voila, that is a proof of concept of how to connect to and consume JMS message of a TIBCO JMS topic from an Oracle SOA 11g Application.

    Download the Oracle SOA 11g Application source code (JDeveloper project) here.

    Cheers,

    Tuesday, October 12, 2010

    A TIBCO BusinessWorks-based file gateway – Part 3

    Publishing an event to TIBCO EMS topic from BusinessWorks.


    We will look at the mechanism to publish the file processing completion events from the FileGateway. The following use case describes the flow.

    Trigger: FileGateway finished writing the XML file to the outbound folder.

    Flow:
    1. FileGateway publishes event to FGW.FILEREADY topic.
    2. End of use case.

    What we need

    A target topic
    We have configured the TIBCO EMS to address part of this requirement. Refer to this article for details of setting up the topic, user and access control list.

    An xml schema for event message
    This schema is used by both the producer and the consumer of the event message. The TIBCO BusinessWorks JMS Publish activity will publish the message according to this schema and the consumer will reference this schema when parsing the message.

    As usual, create the schema using your favorite xml tool. Here is the completed schema.

    <?xml version="1.0" encoding="UTF-8"?>
    
      
        
          
            
            
            
            
              
                
                  
                    
                      
                      
                    
                  
                
                
              
            
          
        
      
    
    

    Import the xml schema into the TIBCO Designer project.

    If you haven't been following the series of articles on FileGateway, you can learn about the FileGateway in the following posts.


    You may also simply download and examine the baselined TIBCO Designer project from here.

    A JMS Publish activity in the BusinessWorks process
    Here are the steps to add a publish JMS activity into the process
    1. Create a JMS Connection shared configuration.
    Under the PollEmpsCSV folder, create a JMS Connection. Uncheck the "Use JNDI for Connection Factory" as our consumers will be connecting directly without getting the resource handle from the JNDI. Enter the username and password of the fgwuser.


    Start the TIBCO EMS server and click on the "Test Connection" button to ensure correct configuration.


    2. Add a JMS Topic Publisher activity.
    In the PollDumpCompletion process, add a JMS Topic Publisher and name it as "PublishEvent". In the configuration tab, enter "FGW.FILEREADY" in the Destination Topic field. In the "Message Type" dropdown, select "XML Text".

    Create a transition from WriteXMLFile to PublishEvent, and from PublishEvent to End activities.

    With PublishEvent activity selected, go to the "Input Editor" tab. Click on the "+" icon and select "XML Element Reference" from the "Content" dropdown. Browse to the schema fileInfo.xsd and select the element "fileInfo"


    Go to the "Input" tab, map the fileName, fileSize and fileDateTime elements of the activity input to the corresponding fields of $WriteXMLFile process data.

    Duplicate the "property" element of the fileInfo instance to contain additional informations, such as the username and password of the ftp server where the output file is located, the url of the ftp server and so forth. The value of the "transport" element indicates how the output file is hosted. Possible values are ftp, http, https or even a "RESTful file server"?!. Well, the password is in plain-text, not an ideal implementation, but that is a separate exercise!

    Here we are, done. A FileGateway that broadcasts the file conversion event to interested parties. The output JMS body of the event is as follow.

    <?xml version="1.0" encoding="UTF-8"?>
    
        EMP-OUT00A-20101012-13-13-35.XML
        1646
        2010-10-12T13:13:36.234+11:00
        
            
            
            
            
        
    
    

    Download the update FileGateway here.

    In the next article, we will be looking at testing/consuming the publish feature from Oracle SOA Suite.

    Cheers.

    Thursday, October 7, 2010

    Configuring TIBCO EMS for FileGateway to broadcast completion event

    In our next article, we will add a new feature to the FileGateway. This article describes the steps to setup the EMS for that purpose.

    We need:
    • a secured topic
    • an EMS user
    • authorization enabled EMS
    • access control list (acl)

    Before you start

    Start EMS server.
    - simply execute tibemsd.exe in the bin folder of your TIBCO EMS installation (windows). The default EMS_HOME for win32 installation is c:\tibco\ems\5.1 for TIBCO EMS 5.1.x.

    %EMS_HOME%\bin\tibemsd.exe -config fullpath_to_your_tibemsd.conf_file
    

    Launch EMS admin console.
    In the same directory of tibemsd.exe, execute the tibemsadmin.exe

    %EMS_HOME%\bin\tibemsadmin.exe
    

    Connect to EMS server

    - In the TIBCO EMS Administration console, enter the command "connect". Assuming you have not changed the admin password, login as admin with no password.

    Creating a topic and securing it

    We will create a EMS topic called FGW.FILEREADY to which the FileGateway will publish its file completion events. Just to add a little security to it, we will secure this topic by allowing only authorized consumers to subscribe, effectively blocking the anonymous consumers.

    Enter the following commands into the admin console.

    create topic FGW.FILEREADY secure
    
    To see the newly created topic in the console, enter the following command.

    show topics
    
    Note the '+' sign under the column 'S', it indicates the topic is secured.

    Enable EMS authorization

    The 'secure' property of a EMS topic or queue will only come to effect if the server authorization is enabled. To enable authorization on EMS server, enter the following command at the admin console.

    set server authorization=enabled
    
    Authorization can also be turned on via the tibemsd.conf file.
    authorization = enabled
    
    Server restart is required if this method is used.

    Creating an EMS user

    To access to secured topics, the JMS consumer needs to provide credentials when subscribing. For that reason we will create a user called "fgwuser" with the password "fgwuser".

    Enter the following commands into the admin console.

    create user fgwuser "FileGateway User" password=fgwuser
    
    Use the following command to list the created user.

    show user fgwuser
    

    Configure the access control list (acl)

    The consumer of FGW.FILEREADY topic needs at least the 'subscribe' privilege in order to subscribe to the topic. If the consumer intends to become a durable subscriber, it also needs to be given the 'durable' privilege. Note that in our scenario, the consumer is not allowed to publish to this topic, hence the absence of 'publish' privilege.

    Enter the following command into the admin console.

    grant topic FGW.FILEREADY fgwuser subscribe, durable
    
    To inspect the privileges assigned to fgwuser, use the following commands

    showacl topic FGW.FILEREADY
    

    OR

    showacl user fgwuser
    

    Summary

    By now we have configured/created the following:
    • A secured EMS topic called FGW.FILEREADY
    • An EMS user called fgwuser
    • Access control on fgwuser
    • EMS server authorization = enabled

    We will update the FileGateway to publish file completion events to this topic in our next article.

    Cheers, happy publishing...