Get value from Coherence Cache using Coherence Adapter

This post is in continuation to Add Coherence node to Soa 12c’s integrated weblogic coherence cluster post.  As part of earlier post, we created another coherence node , added a value to out-of-box adapter-local cache.

As part of this blog, we will see how to get value from coherence cache using coherence Adapter.

Create  a SOA Application. Add a “Coherence Adapter” reference.

Enter a name for the reference.

Coherence Adapter Set Name
Coherence Adapter Set Name

Specify JNDI Name. “eis/Coherence/Local” is the out-of-box JNDI name configured which refers “adapter-local” cache.

Coherence Adapter Set JNDI
Coherence Adapter Set JNDI

Specify operation type as “Get”. We want to get the value of “username” key which was put by the standalone coherence node.

Coherence Adapter Operation Type
Coherence Adapter Operation Type

Configure get Operation. Select cache-type as POJO.  Cache name as “adapter-local”, key type as “String”.

Leave “Key” field as empty and click next. We will pass the key value via header property

Coherence Adapter Config Get
Coherence Adapter Config Get

Select the value type as “java.lang.String”. Uncheck “Auto-generate Metadata mapping” and click next.

Coherence Adapter Value Type
Coherence Adapter Value Type

Click Finish to create the reference.

Add a BPEL component.

Create Synch BPEL
Create BPEL

Wire the BPEL component to Coherence Adapter reference (GetValue).

Wire To Reference
Wire To Reference

Open BPEL component, add a invoke activity to call coherence Adapter. Create variable for input and output.

Let us get the key from user and pass it on to the adapter. Map user input to jca.coherence.key header property.

jca.coherence.Key Header property
Set Invoke Header

Add an Assign Activity after the invoke. Copy output of coherence call to BPEL’s output variable.

Copy Coherence Output to Output Var
Copy Coherence Output to Output Var

Deploy and test the Composite.

Give the input to the service as “username”.

“username” is the key name inserted into the cache via standalone coherence node.

Composite should return value for the key, “Krishna” in our case.

Test Result
Test Result

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *