
Using the Oracle WebLogic Technology Adapters with custom Java – Message Driven Bean (MDB) triggered by File Adapter (part of the story)
Oracle’s product portfolio contains the Technology Adapters. A set of JCA Connectors that provide a bridge between various technologies – such as JMS, AQ, Database (SQL and PL/SQL), FTP and File System – on the one hand and the world of JEE on the other. The SOA Suite 11g and Oracle Service Bus leverage these adapters to connect to and from these technologies. For example: through the adapters, instances of composite applications can be instantiated through the appearance of a file on the file system or a new record in a database table. And, in the outbound direction: OSB and SOA Suite can call out to PL/SQL procedures, send messages to JMS Topics or an AQ queue and write files to an FTP server.
The technology adapters comply with the JEE standard specification of JCA (Java Connector Architecture). They are deployed as a special type of resource – JCA Adapter – on WebLogic Server. And they can be connected to custom Java components – in addition to their better known usage with SOA Suite and Oracle Service Bus.
I have tried to use the File Adapter in an inbound fashion to trigger a Message Driven Bean when a new file is received in a specific directory. This article describes my findings. And I have to warning: the story is not yet complete(ly successful).
JCA Connectors can deliver their inbound messages to message driven beans (MDBs). Starting with the EJB 2.1 specification, MDBs can have a JCA Resource Adapter configured as their source of messages, instead of a JMS Topic or Queue. In addition to a reference to JCA Adapter, the MDB should be accompanied by the configuration of the Activation Configuration for the Resource Adapter. This is the set of property values that determine the behavior of the Adapter on behalf of the Message Driven Bean:

In this example, the FileAdapterClientMDBBean is configured in the ejb-jar.xml file. The activation-config element contains a collection of activation-config-properties. These properties are described in the documentation for the File Adapter (http://docs.oracle.com/cd/E21764_01/integration.1111/e10231/adptr_propertys.htm#CHDEDJEA) and they correspond with the bean properties for the class FileActivationSpec that can be found in the RAR file MW_HOME\soa\connectors\FileAdapter.rar that is used to deploy the File Adapter:

The rar file contains the fileAdapter.jar file that contains the FileActivationSpec class:

This class has the following bean properties:

These properties can be set – presumably at least, because I have not been able to try it out successfully or find confirmation anywhere – in the ejb-jar.xml file as shown above – and below.
<?xml version = '1.0' encoding = 'windows-1252'?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/ejb-jar_3_0.xsd"
version="3.0" xmlns="http://java.sun.com/xml/ns/javaee">
<enterprise-beans>
<message-driven>
<description>EJB 3.0 Message Driven Bean (MDB) that acts as client for the File Adapter</description>
<display-name>FileAdapterClientMDBBean</display-name>
<ejb-name>FileAdapterClientMDBBean</ejb-name>
<ejb-class>nl.amis.jca.FileAdapterListener</ejb-class>
<messaging-type>javax.resource.cci.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>physicalDirectory</activation-config-property-name>
<activation-config-property-value>d:\temp\custom</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>deleteFile</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>pollingFrequency</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>includeFiles</activation-config-property-name>
<activation-config-property-value>.*\.txt</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>minimumAge</activation-config-property-name>
<activation-config-property-value>0</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>
The class that implement the Message Driven Bean is referenced in this ejb-jar.xml through the ejb-class property: nl.amis.jca.FileAdapterListener. This class is just a regular MDB – at this point without any useful functionality, just logging of the messages that get received.
package nl.amis.jca;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.resource.cci.MessageListener;
import javax.resource.cci.Record;
/**
* EJB 3.0 Message Driven Bean (MDB) that acts as client for the File Adapter JCA Resource
* Adapter.
*
* @author Lucas Jellema (heavily leaning on Ronald van Luttikhuizen)
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "resourceAdapterJndiName", propertyValue = "eis/FileAdapter")
}, mappedName = "weblogic.wsee.DefaultQueue")
public class FileAdapterListener implements MessageListener {
/**
* Logger.
*/
private Logger logger = Logger.getLogger(FileAdapterListener.class.getName());
/**
* Default constructor.
*/
public FileAdapterListener() {
System.out.println("File Adapter Listener started");
logger.info("[START] FileAdapterListener()");
// Do nothing
logger.info("[END] FileAdapterListener()");
}
/*
* @see javax.resource.cci.MessageListener#onMessage(javax.resource.cci.Record)
*/
public Record onMessage(Record record) {
System.out.println("File Adapter Listener received record!!!");
logger.info("[START] onMessage()");
logger.info("\t" + "New record: " + record);
// JCA record information
logger.info("\t" + "Record name: " + record.getRecordName());
logger.info("\t" + "Record short description: " + record.getRecordShortDescription());
logger.info("[END] onMessage()");
return record;
}
}
Note how the class has annotations that contain the reference to the JCA Resource Adapter that is the source of messages for the MDB:

Instead of using this EJB 3.0 annotation, the application can also use a WebLogic Server specific deployment descriptor file – weblogic-ejb-jar.xml – with the identification of the Message Driven Bean and the descriptor with the resource-adapter-jndi-name property:

<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar">
<weblogic-enterprise-bean>
<ejb-name>FileAdapterClientMDBBean</ejb-name>
<message-driven-descriptor>
<resource-adapter-jndi-name>eis/FileAdapter</resource-adapter-jndi-name>
</message-driven-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Note: since the thing is not working right now, I cannot be sure that my reference to eis/FileAdapter is the correct one. However, when checking the WebLogic Server Administration Console for the File Adapter deployment, this seems the correct JNDI name:

Note that this same name is used in the JCA configuration files created in SOA Composite applications that make use of the File Adapter.
Deployment Challenges
After I completed the application – MDB and ejb-jar.xml file – I defined an EAR deployment profile and tried to build and deploy it (to WebLogic Server 10.3.4, aka 11g PS3). Unfortunately, deployment failed with the following output:

This message: “The ResourceAdapterJNDIName configuration attributes cannot be mixed with any of the following settings:” does not seem justified, because only the ResourceAdapterJNDIName property is set and none of the other properties mentioned is available in either the MDB itself or any of the associated descriptors. Even the code described by Ronald van Luttikhuizen – apparently successfully tested – does not deploy successfully on my local WLS instance.
I have thusfar not been able to resolve the problem. Googling with the messages in the console resulted in a promising hit:

http://forums.oracle.com/forums/thread.jspa?threadID=2136029
Unfortunately, Oracle’s Discussion Forums (OTN) are down because of maintenance:

I am stuck for the moment. It feels like I have done what one should do in order to have one’s Message Driven Beans triggered by the File Adapter.
Right now, I will quit and hope for the Forums to come available again or some helpful and knowledgeable reader to post a comments that helps me out. Note: I will complement this article with the solution when I have found one.
Resources
Documentation: Fusion Middleware User’s Guide for Technology Adapters
11g Release 1 (11.1.1.5.0) – http://docs.oracle.com/cd/E21764_01/integration.1111/e10231/intro.htm
Article on OTN by Ronald van Luttikhuizen on the development and deployment of a custom (inbound) JCA Resource Adapter and the creation and deployment of a Java Client to be triggered by the adapter -
The OTN Discussion Forum thread that hopefully provides an answers to my problem: http://forums.oracle.com/forums/thread.jspa?threadID=2136029
Develop inbound connectors with JCA 1.5 (Article on JavaWorld, 2005) – http://www.javaworld.com/javaworld/jw-06-2005/jw-0606-jca.html
Fusion Middleware Programming Message-Driven Beans for Oracle WebLogic Server 11g Release 1 (10.3.4) -Deployment Elements and Annotations for MDBs http://docs.oracle.com/cd/E17904_01/web.1111/e15493/summary.htm
No trackbacks yet.
WLST script to add DataSource and DBAdapter EIS Connection Factory
16/2/2012 - 1:21 pm
Tags: 12c, connectionfactory, data source, database adapter, eis, jdbc, scripting, weblogic, wlst
Posted in J(2)EE/Java, Java, JEE, OAS and WebLogic Server, SOA & Oracle Fusion Middleware, Web/Java | 4 comments
Creating a EIS ConnectionFactory in your Database Adapter can be done with the WebLogic Administration Console, but of course this is also “scriptable”. What I needed was a script that created a Data Source with EIS Connection factory bound to the specific datasource.
First I created a properties file, let’s call it DsCf.properties. Everything between <> [...]
WebLogic 12c: Use JPA in your Web Application
14/2/2012 - 3:06 pm
Tags: administration, console, jdbc, jee, jpa, weblogic, wls
Posted in General, J(2)EE/Java, Java, JEE, OAS and WebLogic Server, Web/Java | 2 comments
Where as in WebLogic 11g JPA was not support by default, in WebLogic 12c it is the default persistency provider.JPA 2.0 is part of JAVA EE 6.
I was trying some new JAVA EE 6 features in WebLogic 12c, so here is a is a way to create a Web Application with JPA under WebLogic 12c
Some [...]
Sharing session state between JEE web applications through WebLogic session descriptor of sharing-enabled
18/1/2012 - 9:43 am
Tags: jee, jsf, session, session state, shared session, web application, weblogic
Posted in ADF & JHeadstart, J(2)EE/Java, Java, JEE, OAS and WebLogic Server | 2 comments
Session state in Java Web application is associated with a single (user) browser session on the one hand and typically with a specific web application on the other (server side) hand. Session state is created and maintained in the context of a usually a single web application. However…
We ran into a situation where our web [...]
The Future of Forms is ….. Forms (and some friends) (UKOUG, 2011 – with Grant Ronald)
11/12/2011 - 8:28 am
Tags: forms, fusion middleware, future, migration, modernization, weblogic
Posted in ADF & JHeadstart, Devel. + PL/SQL tools, Java, JEE, OAS and WebLogic Server, Oracle | 2 comments
Slides for the presentation I did with Grant Ronald during UKOUG 2011, last week in Birmingham. The abstract for this presentation: “Many organizations run enterprise Oracle Forms applications created in the 90s. They now wonder about the future of their application.This session tells how modernization of the application landscape could take place, [...]
Implementing Web Services backed by a Database PL/SQL API using the Oracle Service Bus
1/12/2011 - 9:40 am
Tags: database adapter, Eclipse, jca, oracle service bus, osb, plsql, proxy service, xquery
Posted in Database, Databases, J(2)EE/Java, Java, Java, JEE, OAS and WebLogic Server, Oracle, SOA & Oracle Fusion Middleware | 1 comment
This article accompanies an article on the Architecture section of Oracle Technology Network (OTN): Implementing the Enterprise Service Bus Pattern to Expose Database Backed Services. It provides a detailed description of the implementation of the ESB architecture design pattern – the same that is introduced in the article on OTN – using Oracle Service Bus. [...]
Timeouts in Oracle SOA Suite 11g
18/11/2011 - 1:10 am
Tags: Oracle, soa suite, soa suite 11g, Web Services, weblogic
Posted in Oracle, SOA & Oracle Fusion Middleware, Software Engineering, Technical Architecture | 5 comments
Some time ago… at a Oracle SOA 11g project, we had to call an external webservice which took 1 to 5 minutes to respond. The composite calling this webservice was called by another composite from a BPEL process. As you might guess, we got an timeout resulting in faulted instances.
Increasing the timeout time wasn’t as [...]
Publishing the Product Details WebService based on an Excel based Product Catalog using the SOA Suite 11g File Adapter with Synchronous File Read
14/11/2011 - 1:51 pm
Tags: file adapter, soa suite, web service
Posted in Oracle, SOA & Oracle Fusion Middleware | 1 comment
On the one hand: the organization wants to publish a real Web Service, SOAP enabled and all. On the other: the data to be provided by this Web Service is maintained in Excel files and undergoes regular changes by people who are well versed in Excel but absolutely blank when it comes to Web Services.
This [...]
Oracle Tuxedo… A renewed acquaintance
27/10/2011 - 12:04 pm
Tags: exalogic, ora, Oracle, oracle open world, tuxedo, weblogic, weblogic server
Posted in Cloud, General, Java, JEE, OAS and WebLogic Server, Oracle, SOA & Oracle Fusion Middleware, Technical Architecture | 1 comment
Years ago, when I worked as an Application Support Analyst for a big triple-A Bank, I got acquainted with the BEA product stack.
One of those products was BEA Tuxedo, at that time at the release of 6. I worked at a settlements project, and Tuxedo was used for as distributed transaction processing, to process settlements [...]
SOA Suite File Adapter Pre and Post processing using Valves and Pipelines
24/10/2011 - 11:49 am
Tags: file adapter, Java, jdeveloper, pre processing, soa suite, valve
Posted in Java, JEE, OAS and WebLogic Server, Oracle, SOA & Oracle Fusion Middleware | 3 comments
A quick note on the notion of valves and pipelines that can be configured in File (and FTP) Adapter Services and References (inbound and outbound) to perform file pre- and post processing on the files before they enter the composite application proper as XML or after they have left the composite application, turned from XML [...]
Some explorations around Java Stored Procedures in the Oracle Database
22/10/2011 - 11:58 pm
Tags: aurora, initialcontext, java stored procedure, jsp, loadjava, ojvm, weblogic
Posted in Database, Devel. + PL/SQL tools, Java, Java, JEE, OAS and WebLogic Server, Oracle | 3 comments
While working on the challenge to publish a message to a JMS Queue in a remote WebLogic Server from within the Oracle Database – using a Java Stored Procedure – I came across a few things that I would like to record for future reference. Note that unfortunately I have not [yet?] succeeded in making [...]



1/2/2012 - 1:02 pm
Hi Lucas
Have you considered using a weblogic-ra.xml as an additional descriptor? This contains parameters that are specific to configuring and deploying resource adapters in WebLogic Server. As I can see you are now using the ejb-jar.xml for you ra config and it seems it gives conflicts with your EJB specific settings
kind regards
Michel
1/2/2012 - 1:15 pm
Hi Michel,
Thanks for your reaction. However, I am not trying to configure the adapter here, I am trying to deploy an application that registers with the inbound adapter in order to get notified by the adapter. To that end, a message driven bean is hooked into the adapter, instead of a JMS destination (Topic or Queue) as is normally the case. The configuration applies to the MDS – not to the adapter!
Lucas