14 Oracle JCA Adapter for Coherence
14.1 Oracle Coherence and Oracle JCA Coherence Adapter Concepts
Coherence provides replicated and distributed (partitioned) data management and caching services on top of a reliable, highly scalable peer-to-peer clustering protocol.
14.1.1 Coherence Cache
A Coherence cache is a collection of data objects that serves as an intermediary between the database and the client applications. Database data can be loaded into a cache and made available to different applications. Thus, Coherence cache reduces load on the database and provides faster access to database data. Objects in the cache can either be of XML or POJO (Plain Old Java Object) type.
Note:
A POJO Java class must be Serialized to use with the Coherence Adapter. That is, a Java class you use with the Coherence Adapter should implement either java.io.Serializable
or com.tangosol.io.pof.PortableObject
.
For more information about Coherence, see the Oracle Coherence library. For information related to Coherence security, refer to Securing Oracle Coherence.
14.1.2 The Coherence Adapter
The Coherence Adapter is a JCA 1.5-compliant resource adapter for Oracle Coherence. When deployed in a SOA environment, the Coherence Adapter is used as an integration vehicle by SOA composite applications when they integrate with Oracle Coherence.
The Coherence Adapter enables you to perform useful Coherence operations such as adding an item to a Coherence cache, obtaining an item from a Coherence cache, removing an item and querying from a Coherence cache.
14.1.3 Compatibilty
When using a version of the Coherence Adapter, you are not able to interact with a remote Coherence cluster other than the same version or a newer version. For example, when using the Coherence Adapter in 12.1.3, you would not be able to interact with a remote Coherence cluster other than 12.1.3 or a newer version. This is due to a Coherence product limitation on the use of the Coherence extend client with older versions of the extend proxy.
Specifically, regarding compatibility between a Coherence server and an extend client, only forward compatibility is maintained from extend clients to cluster proxy servers. That is, an extend client can connect to cluster servers that have either the same or higher version numbers, but not the lower version numbers.
See Compatibility Between Coherence*Extend Versions in Installing Oracle Coherence for the limitation imposed by the Coherence product.
14.1.4 Oracle Coherence Adapter Features
You can use the Oracle Coherence Adapter to perform the following activities associated with Oracle Coherence:
-
Add a Cache Entry: Create a new entry in the Coherence Cache.
-
Remove Cache entries: Identify an item to be removed from the Cache, and the system removes the entry from the Cache. You can also remove multiple entries from the cache by providing a filter or search criteria which match the multiple records in cache.
-
Get Cache entry value: After specifying an entry to obtain the associated value, the system returns the value of that entry to you.
-
Query Cache: After you identify the Cache, and specify search criteria, the system returns the entries that match the search criteria.
14.1.4.1 Basic Use Cases
There are two basic use cases for the Coherence Adapter.
-
A Coherence Adapter connecting to a local cluster. This configuration supports transactional caches.
-
A Coherence Adapter connecting to a standalone Coherence cluster or a WebLogic Server. This configuration does not support transactional caches.
Note that the local Coherence Adapter operations described in this chapter are similar for a remote cache, with limitations as noted. The main difference is that the name of the cache you specify when you do operations against a remote cache is the name of the remote cache and not that related to a local cluster.
The Coherence Adapter uses the Coherence extend client to connect to the remote cluster. See the next section for a discussion of configuring a remote cache that you can access using the Coherence Adapter.
14.1.4.1.1 Configuring the Coherence Adapter Connection to a Remote Cluster
You can use the Coherence Adapter to access remote caches.
The name of the remote cache is captured in a configuration file; in the following example, the file is called extend-config.xml
file. The location of this configuration file needs to be specified as the value for property CacheConfigLocation
. In addition to containing the cache name, the configuration file also requires information to connect to a remote Coherence cluster.
The access to remote caches is enabled using <remote-cache-scheme>
.
Note that the ManagedConnectionFactory
example here also points to a location for the PojoJarFile
.
For more information, see Introduction to Coherence*Extend and Best Practices for Coherence*Extend in Developing Remote Clients for Oracle Coherence.
Example - ManagedConnectionFactory for a Remote Cluster
<connection-instance> <jndi-name>eis/Coherence/Remote</jndi-name> <connection-properties> <properties> <property> <name>CacheConfigLocation</name> <value>/scratch/amahajan/Temp/coherence/dhqa/extend-config.xml</value> </property> <property> <name>ClassLoaderMode</name> <value>CUSTOM</value> </property> <property> <name>PojoJarFile</name> <value>/scratch/amahajan/Temp/coherence/dhqa/book.jar</value> </property> <property> <name>WLSExtendProxy</name> <value>false</value> </property> </properties> </connection-properties> </connection-instance>
Example - Sample extend-config to Define a Remote Cache
In this example, the extend configuration enables the adapter to connect to an extend proxy running at address 10.240.82.123
and listening on port 14777
.
<?xml version="1.0"?> <!DOCTYPE cache-config SYSTEM "cache-config.dtd"> <cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>samples-cache</cache-name> <scheme-name>extend-dist</scheme-name> </cache-mapping> <cache-mapping> <cache-name>samples-cache-binxml</cache-name> <scheme-name>extend-dist</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <remote-cache-scheme> <scheme-name>extend-dist</scheme-name> <service-name>ExtendTcpCacheService</service-name> <initiator-config> <tcp-initiator> <remote-addresses> <socket-address> <address>10.240.82.123</address> <port>14777</port> </socket-address> </remote-addresses> <connect-timeout>10s</connect-timeout> </tcp-initiator> <outgoing-message-handler> <request-timeout>5s</request-timeout> </outgoing-message-handler> </initiator-config> </remote-cache-scheme> </caching-schemes> </cache-config>
14.1.4.1.2 Coherence Adapter Connection to Local Cluster
The Coherence Adapter provides a default connection factory to connect to an out-of-box Coherence cache and also a cache called adapter-local
.
Coherence adapter employs transactions for access to local caches (local coherence cluster). So the supported scheme for local caches is <transactional-scheme>
14.2 Configuring the Coherence Adapter
Learn how to configure the Coherence Adapter using the Coherence Adapter Configuration Wizard.
14.4 Defining Messages for Put, Get and Query Operations if XML is Chosen
Learn how to define messages for Put, Get and Query Operations if you have chosen XML as the cache type.
If you have chosen XML as the cache type on any of the Put, Get or Query operations, the Specify Schema Page appears. On this page, you select a schema for the Coherence cache object. See Figure 14-7.
Figure 14-7 Coherence Adapter Configuration Wizard Messages (Specify Schema) Screen
Description of "Figure 14-7 Coherence Adapter Configuration Wizard Messages (Specify Schema) Screen"
14.4.1 Defining Messages for Put, Get and Query Operations if Pojo is Chosen
If you choose POJO as the cache type for a Get, Put, or Query operation, the Specify Value Type Class Screen appears.
Figure 14-8 Coherence Adapter Configuration Wizard Value Type Class Screen
Description of "Figure 14-8 Coherence Adapter Configuration Wizard Value Type Class Screen"
To define messages when you have specified POJO as the cache type:
14.5 Coherence Adapter Files and Artifacts
This section provides examples of Coherence Adapter design-time artifacts.
14.5.1 JCA File
The JCA file stores JCA property values for each of the supported operations.
Example - JCA File Created
<adapter-config name="cohPut1" adapter="Coherence Adapter" wsdlLocation="../WSDLs/cohPut1.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata"> <connection-factory location="eis/coherence"/> <endpoint-interaction portType="Put_ptt" operation="Put"> <interaction-spec className= "oracle.tip.adapter.coherence.CoherenceInteractionSpec"> <property name="CacheName" value="TestCache"/> <property name="Key" value="ABC12345678"/> <property name="KeyType" value="String"/> <property name="ValueType" value="com.coherence.vt.Book"/> <property name="TimeToLive" value="60"/> <property name="MappingsMetadataFile" value="book-oxm-mappings.xml"/> </interaction-spec> </endpoint-interaction> </adapter-config>
14.5.2 WSDL for Put Operation
The following example shows the WSDL for the Coherence Adapter Put Operation
Example - WSDL for Coherence Adapter Put Operation
<wsdl:definitions name="cohPut1" targetNamespace= "http://xmlns.oracle.com/pcbpel/adapter/coherence/Application1/Project1/cohPut1" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns=http://xmlns.oracle.com/pcbpel/adapter/coherence/Application1/ Project1/cohPut1 xmlns:imp1=" http://xmlns.oracle.com/pcbpel/adapter/coherence" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"> <plt:partnerLinkType name="Put_plt"> <plt:role name="Put_role"> <plt:portType name="tns:Put_ptt"/> </plt:role> </plt:partnerLinkType> <wsdl:types> <schema targetNamespace= “http://xmlns.oracle.com/pcbpel/adapter/coherence/Application1/Project1/cohPut1" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace=" http://xmlns.oracle.com/pcbpel/adapter/coherence " schemaLocation="xsd/book_cache.xsd"/> </schema> <schema <schema targetNamespace= “http://xmlns.oracle.com/pcbpel /adapter/coherence/Application1/Project1/cohPut1" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="returnId" type="xsd:string"/> </schema> </wsdl:types> <wsdl:message name="Request_msg"> <wsdl:part name="body" element="imp1:book"/> </wsdl:message> <wsdl:message name="Response_msg"> <wsdl:part name="body" element="tns: returnId "/> </wsdl:message> <wsdl:portType name="Put_ptt"> <wsdl:operation name="Put"> <wsdl:input message="tns:Request_msg"/> <wsdl:output message="tns:Response_msg"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>
14.5.3 WSDL for Remove with Filter Expression Having Bind Variables
shows the WSDL for the Coherence Remove Operation with a Filter Expression
Example - WSDL for Coherence Remove Operation with a Filter Expression
<wsdl:definitions name="cohRem1" targetNamespace="http://xmlns.oracle.com/pcbpel/adapter /coherence/Application1/Project1/cohRem1" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns=http://xmlns.oracle.com/pcbpel/adapter/coherence /Application1/Project1/cohRem1 xmlns:plt="http://schemas.xmlsoap.org/ws/ 2003/05/partner-link/"> <plt:partnerLinkType name="Remove_plt"> <plt:role name="Remove_role"> <plt:portType name="tns:Remove_ptt"/> </plt:role> </plt:partnerLinkType> <wsdl:types> <schema targetNamespace= “http://xmlns.oracle.com/pcbpel/adapter /coherence/Application1/Project1/cohRem1" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="RemoveRequest"> <complexType> <element name="bind1" type="string"/> <element name="bind2" type="string"/> </complexType> </element> </schema> <schema targetNamespace= “http://xmlns.oracle.com/ pcbpel/adapter/coherence /Application1/Project1/cohRem1" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="ReturnCount" type="integer"/> </schema> </wsdl:types> <wsdl:message name="Request_msg"> <wsdl:part name="body" element="tns:RemoveRequest "/> </wsdl:message> <wsdl:message name="Response_msg"> <wsdl:part name="body" element="tns: ReturnCount "/> </wsdl:message> <wsdl:portType name="Remove_ptt"> <wsdl:operation name="Remove"> <wsdl:input message="tns:Request_msg"/> <wsdl:output message="tns:Response_msg"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>
14.5.4 WSDL for Get Operation
The following example shows a generated WSDL for the Coherence Get Operation.
Example - WSDL for Get Operation
<wsdl:definitions name="cohRem1" targetNamespace= "http://xmlns.oracle.com/ pcbpel/adapter/coherence/Application1/Project1/cohGet1" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns=http://xmlns.oracle.com/pcbpel/ adapter/coherence/Application1/Project1/cohGet1 xmlns:imp1=" http://xmlns.oracle.com/pcbpel/ adapter/coherence" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"> <plt:partnerLinkType name="Get_plt"> <plt:role name="Get_role"> <plt:portType name="tns:Get_ptt"/> </plt:role> </plt:partnerLinkType> <wsdl:types> <schema targetNamespace= “http://xmlns.oracle.com/pcbpel/adapter /coherence/Application1/Project1/cohGet1" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="empty"><complexType/></element> </schema> <schema targetNamespace= “http://xmlns.oracle.com/pcbpel/adapter/ coherence/Application1/Project1/cohGet1" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace= "http://xmlns.oracle.com/pcbpel/adapter/coherence "schemaLocation="xsd/book_cache.xsd"/> </schema> </wsdl:types> <wsdl:message name="Request_msg"> <wsdl:part name="body" element="tns:empty "/> </wsdl:message> <wsdl:message name="Response_msg"> <wsdl:part name="body" element="imp1:book "/> </wsdl:message> <wsdl:portType name="Get_ptt"> <wsdl:operation name="Get"> <wsdl:input message="tns:Request_msg"/> <wsdl:output message="tns:Response_msg"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>
14.5.5 WSDL for Query with Filter Expression having Bind Variables
The following example shows the WSDL for the Query Operation, with a Filter Expression including Bind variables.
Example - WSDL for Query with Filter Expression Having Bind Variables
<wsdl:definitions name="cohQuery1" targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/coherence /Application1/Project1/cohQuery1" xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns=http://xmlns.oracle.com/pcbpel/adapter /coherence/Application1/Project1/cohQuery1 xmlns:imp1=" http://xmlns.oracle.com/pcbpel/ adapter/coherence" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"> <plt:partnerLinkType name="Query_plt"> <plt:role name="Query_role"> <plt:portType name="tns:Query_ptt"/> </plt:role> </plt:partnerLinkType> <wsdl:types> <schema targetNamespace= “http://xmlns.oracle.com/ pcbpel/adapter/coherence /Application1/Project1/cohQuery1" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="QueryRequest"> <complexType> <element name="bind1" type="string"/> <element name="bind2" type="string"/> </complexType> </element> </schema> <schema targetNamespace= “http://xmlns.oracle.com/ pcbpel/adapter/coherence /Application1/Project1/cohQuery1" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace=" http://xmlns.oracle.com/ pcbpel/adapter/coherence" schemaLocation="xsd/book_cache.xsd"/> </schema> </wsdl:types> <wsdl:message name="Request_msg"> <wsdl:part name="body" element="tns:QueryRequest "/> </wsdl:message> <wsdl:message name="Response_msg"> <wsdl:part name="body" element="imp1:book "/> </wsdl:message> <wsdl:portType name="Query_ptt"> <wsdl:operation name="Query"> <wsdl:input message="tns:Request_msg"/> <wsdl:output message="tns:Response_msg"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>
14.6 Tips for Using the Coherence Adapter
The following tips would come handy while using the Coherence Adapter.
If you see the following error:
Execute of operation 'Put' failed due to: Service "TransactionalCache" has been started by a different configurable cache factory.; nested exception is: java.lang.IllegalStateException: Service "TransactionalCache" has been started by a different configurable cache factory.
This message means that the Service TransactionalCache
is defined in multiple places. Obtaining this error is not limited only to the Coherence Adapter Put operation. You can get this exception for all operations supported by Coherence Adapter.
This issue occurs when you have the configuration files as below.
The first configuration file, a-config.xml
contains the following:
<cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>adapter-local</cache-name> <scheme-name>transactional</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <transactional-scheme> <scheme-name>transactional</scheme-name> <service-name>TransactionalCache</service-name> <autostart>true</autostart> </transactional-scheme> </caching-schemes> </cache-config>
The second configuration file, b-config.xml
, contains the following:
<cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>movie-local</cache-name> <scheme-name>transactional</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <transactional-scheme> <scheme-name>transactional</scheme-name> <service-name>TransactionalCache</service-name> <autostart>true</autostart> </transactional-scheme> </caching-schemes> </cache-config>
You use a-config.xml
for one jndi and b-config.xml
in another jndi and two composites use these two different jndis. When you deploy the first configuration, it completes acceptably, but the second deployment fails because the service TransactionalCache
has already been started by the first one.
The solution is to have only one config.xml
file and use the same config.xml
across different jndis. For example, you can use the following config.xml file
across different jndis.
<cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>adapter-local</cache-name> <scheme-name>transactional</scheme-name> </cache-mapping> <cache-mapping> <cache-name>movie-local</cache-name> <scheme-name>transactional</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <transactional-scheme> <scheme-name>transactional</scheme-name> <service-name>TransactionalCache</service-name> <autostart>true</autostart> </transactional-scheme> </caching-schemes> </cache-config>