Utility to manage transaction boundaries on Ehcache puts and gets

Overview
Currently, we do not have built-in webMethods IS services to manage transactions on Ehcache puts and gets. When needed, one may have to either implement whole solution as Java services using Ehcache Java API or come up with generic way of using them. I took the opportunity to develop this package which has got transaction management services for caching reads/ writes. I tried to keep the service names and signatures almost same as our “pub.art.transaction.* ” services. So it should be easy to use them straight forward.

Below details help you to understand this package in a better way and also gives information on how to configure and use this package

Download

Prerequisites
WmEhcacheTransactionManager.jar should be present under <IntergrationServer_dir>/lib/jars folder. (This is required only if planning to use xa or xa_strict transaction. This jar contains Transaction Manager Lookup implementation which is required by Ehcache for XA transactions)

Configuration
Transactions are enabled on a cache by cache basis with the transactionalMode cache attribute.
The allowed values are:

  • xa_strict
  • xa
  • local
  • off

The default value is off.

Local Transactions:
Enabling a cache for local transactions is shown in the following example:

  1. Shutdown your CacheManager from IS admin
  2. Shutdown terracotta server (if using for distributed caching)
  3. Open <IntergrationServer_dir>/config/Caching/<CacheManagerName>.xml file
  4. Add transactionMode attribute to desired cache element as shown below:

    	<cache name="localCache"
    		maxElementsInMemory="500"
    		eternal="false"
    		timeToIdleSeconds="300"
    		timeToLiveSeconds="600"
    		overflowToDisk="false"
    		diskPersistent="false"
    		diskExpiryThreadIntervalSeconds="1"
    		transactionalMode="local">
    	</cache>
  5. Save file and Start terracotta server (if using for distributed caching)
  6. Start your CacheManager from IS admin
  7. If CacheManager started successfully then you are good to go and use transaction services from WxEhcache package.
  8. If CacheManager does not start successfully then please try restarting Integration Server and then Starting Cache Manager again.

XA or XA_STRICT Transactions:

Enabling a cache for xa or xa_strict transactions is shown in the following example:

  1. Shutdown your CacheManager from IS admin
  2. Shutdown terracotta server (if using for distributed caching)
  3. Open <IntergrationServer_dir>/config/Caching/<CacheManagerName>.xml file
  4. Add below transactionManagerLookup tag in XML file.

    	<transactionManagerLookup
    	class= "com.wm.ehcache.transactionmanager.WmTransactionManagerLookup"
    	properties="" propertySeparator=":"/>
  5. Add transactionMode attribute to desired cache element as shown below:

    	<cache name="xaCache"
    		maxElementsInMemory="500"
    		eternal="false"
    		timeToIdleSeconds="300"
    		timeToLiveSeconds="600"
    		overflowToDisk="false"
    		diskPersistent="false"
    		diskExpiryThreadIntervalSeconds="1"
    		transactionalMode="xa">
    	</cache>
  6. Save file and Start terracotta server (if using for distributed caching)
  7. Start your CacheManager from IS admin
  8. If CacheManager started successfully then you are good to go and use transaction services from WxEhcache package.
  9. If CacheManager does not start successfully then please try restarting Integration Server and then Starting Cache Manager again.

 

Summary of Elements in this Folder
The following elements are available in this folder:

Element

Package and Description

pub.ehcache.transaction:startTransaction WxEhcache. Starts an explicit transaction
pub.ehcache.transaction:commitTransaction WxEhcache. Commits an explicit transaction
pub.ehcache.transaction:rollbackTransaction WxEhcache.Rolls back an explicit transaction
pub.ehcache.transaction:setTransactionTimeout WxEhcache. Manually sets a transaction timeout interval for explicit transactions

 

pub.ehcache.transaction:startTransaction
WxEhcache. Starts an explicit transaction

Input Parameters

startTransactionInput Document Information for each start transaction request

Key

Description

transactionName String Optional.
Specifies the name of the transaction to be started. If you leave this parameter blank, Integration Server will generate a name for you. In most implementations it is not necessary to provide your own transaction name.
transactionType String
Specifies the type of the transaction to be started. Allowed values are local, xa and xa_strict
cacheManagerName String Optional.
Specifies the name of cache manager whose cache is participating in the transaction. This input is mandatory when transaction type is LOCAL. Otherwise optional
timeoutSeconds Integer Optional.
The number of seconds that the explicit transaction stays open before the transaction manager marks it for rollback. If you leave this parameter blank, Integration Server will use default value from system property settings

Output Parameters

startTransactionOutput Document Information for each start transaction request

Key

Description

transactionName String
The name of the transaction the service just started
transactionType String
The type of the transaction the service just started. Expected values are local, xa and xa_strict

 

pub.ehcache.transaction:commitTransaction
WxEhcache. Commits an explicit transaction

Input Parameters

commitTransactionInput Document Information for each commit request

Key

Description

transactionName String
The name of an explicit transaction that you want to commit. The transactionName must have been previously used in a call pub.ehcache.transaction:startTransaction. This value must be mapped from the most recent
pub.ehcache.transaction:startTransaction
that has not previously been committed or rolled back.
transactionType String
The type of an explicit transaction that you want to commit. The transactionType must have been previously used in a call to
pub.ehcache.transaction:startTransaction
. This value must be mapped from the most recent
pub.ehcache.transaction:startTransaction
that has not previously been committed or rolled back.

Output Parameters

None

 

pub.ehcache.transaction:rollbackTransaction
WxEhcache. Rolls back an explicit transaction

Input Parameters

rollbackTransactionInput Document Information for each rollback request

Key

Description

transactionName String
The name of an explicit transaction that you want to rollback. The transactionName must have been previously used in a call to
pub.ehcache.transaction:startTransaction
This value must be mapped from the most recent
pub.ehcache.transaction:startTransaction
that has not previously been committed or rolled back.
transactionType String
The type of an explicit transaction that you want to rollback. The transactionType must have been previously used in a call to
pub.ehcache.transaction:startTransaction
. This value must be mapped from the most recent
pub.ehcache.transaction:startTransaction
that has not previously been committed or rolled back.

Output Parameters

None

 

pub.ehcache.transaction:setTransactionTimeout
WxEhcache. Manually sets a transaction timeout interval for explicit transactions.

Input Parameters

timeoutSeconds Integer
The number of seconds that the explicit transaction stays open before the transaction manager marks it for rollback. If you leave this parameter blank, Integration Server will use default value from system property settings
transactionName String
The name of an explicit transaction for which you want to set timeout. The transactionName must have been previously used in a call to pub.ehcache.transaction:startTransaction. This value must be mapped from the most recent pub.ehcache.transaction:startTransaction that has not previously been committed or rolled back.
transactionType String
The type of an explicit transaction for which you want to set timeout. The transactionType must have been previously used in a call to pub.ehcache.transaction:startTransaction. This value must be mapped from the most recent pub.ehcache.transaction:startTransaction that has not previously been committed or rolled back.

Output Parameters

None

 

FAQs

1) What is this package used for?

Ans) This package helps to develop IS flow services with transaction contexts on Ehcache operations

2) What kind of transaction scopes are allowed?

Ans) local, xa and xa_strict

3) Does this package depend on any other packages?

Ans) NO. But this package does require WmEhcacheTransactionManager.jar placed under Integration Server lib/jars

4) What is the purpose of WmEhcacheTransactionManager.jar?

Ans) This jar contains the implementation of Transaction Lookup Manager which Ehcache needs to register XAEhcacheResources for XA transaction contexts

5) Are services provided under this package useful to do XA or XA_STRICT transactions with combination of webMethods JDBC Adapter or JMS services?

Ans) YES. One can use the Start, Commit or Rollback transaction services from this package with XA or XA_STRICT transaction type to do ehcache operations in combination with webMethods JDBC Adapter or JMS services

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s