Tuesday, February 21, 2012

JCA File Adapter process the same file twice in a clustered envrionment causing duplicate records

I use JCA File Adapter in a clustered environment, both nodes of the cluster processes the same file, causing duplicate records in final system. The simple answer is to use "HAFileAdapter" instead of "FileAdapter". In your .jca file:

<adapter-config name="JcaFileCopy" adapter="File Adapter"

<connection-factory location="eis/HAFileAdapter"...

HAFileAdapter uses database behind the scene to create mutex to make sure only one node will process one file.

Ideally, that's all you need to do. However, I use this JCA file adapter inside my OSB. Simply changing to "HAFileAdatper" is not good enough. By default, HAFileAdapter uses SOADataSource for the behind scene locking mechanism. By default SOADataSource deployment target contains SOA server only ("soa_server1" in my case or whatever your SOA server name happens to be), so you need to re-configure SOADataSource, add your OSB server (osb_server1) to the deployment target list of  the data source. Otherwise, you may scratch your head forever.


  1. I had to re-configure HAFileAdapter on a new server again. This time I'm recording my steps, so i don't have to scramble again.

    1. go to deployments\fileAdapter -> configuration -> outbound connection pools -> eisHAFileAdapter
    I first messed around with "controlDir" properties to set it to a real existing path (i created a temp directory for it), then saved and updated the fileAdapter. But I don't believe it mattered at all. However, the important part is to make sure the inboundDataSource (or outboundDataSource) is really configured correctly. It should be jdbc/SOADataSource by default.

    2. go to SOADataSource, click on Targets, make sure the targets include your server. The default is "soa_server1" (or whatever your soa server name is). But in my case, I am using my file adapter in OSB, so I need to check osb_server1. Save the change.

    3. I went to my OSB file adapter proxy, disable, then re-enable the proxy, boom, it started to work!

    1. I did the above steps. However my file is still bing processed twice, by both the managed servers in the cluster.

  2. We are creating multiple JCA BindingService to listen to a different JMS Queue/Topic . How can we setup these services in a clustered environment?