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.
Specify JNDI Name. “eis/Coherence/Local” is the out-of-box JNDI name configured which refers “adapter-local” cache.
Specify operation type as “Get”. We want to get the value of “username” key which was put by the standalone coherence node.
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
Select the value type as “java.lang.String”. Uncheck “Auto-generate Metadata mapping” and click next.
Click Finish to create the reference.
Add a BPEL component.
Wire the BPEL component to Coherence Adapter reference (GetValue).
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.
Add an Assign Activity after the invoke. Copy output of coherence call to BPEL’s output variable.
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.