Skip to content

kameshsampath/infinispan-feed-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feed Action

This feed action is responsible for creating the Infinispan cach listener and associating it with a Trigger

Pre-requisite

Important
  • For all the CLI commands to work as it is, deploy OpenWhisk to a OpenShift Project called openwhisk

  • Deploy applications infinispan and infinispan-feed-provider to myproject workspace

  • make user developer as admin for both these projects via

 oc adm policy add-role-to-user admin developer -n openwhisk

Build and Deploy

Create Package

wsk -i package create --shared yes redhatdevelopers (1)
  1. this could be anything, if you change it please update pom.xml openwhisk.package property

Create Feed Action

mvn clean package (1)
wsk -i action update -a feed true redhatdevelopers/infinispan-feed \
 target/infinispan-feed-action.jar --main org.workspace7.openwhisk.InfinispanFeedAction
  1. if you have WSK CLI installed, post package

Create Trigger

Pre-requisite

You will need to deploy the Infinispan Feed Provider before creating the trigger. Refer to the README on the deployment.

Create Trigger, Action and Rule

wsk -i trigger create cacheEntryTrigger --feed redhatdevelopers/infinispan-feed \
		-p hotrod_server_host infinispan-app-hotrod \ (1)
		-p hotrod_port 11222 \ (2)
		-p cache_name default (3)

wsk action create cacheEntryTriggerAction src/handler.js (4)
wsk rule create cacheEntryRule cacheEntryTrigger cacheEntryTriggerAction (5)
  1. If you deployed Infinispan using method referenced in Pre-requisite, then the default hostname is infinispan-app-hotrod and by default this is accessible only from within OpenShift cluster

  2. The HotRod Client Port to connect to

  3. The Cache Name for which the listener to be registered

  4. Create a dummy action just to see what parameters are sent via the event source

  5. Associate the Trigger with Action via a rule

Tip
  • Whenever you delete and recreate trigger, you need to enable the rule via wsk -i rule enable cacheEntryRule. As deleting trigger will disable any active rules associated with it

Testing Application

Infinispan Feed Provider provides a REST path called /data/add/{key} which can be used to add dummy entry to see the cache entry event triggering the cacheEntryTriggerAction

curl -X GET  --data "hello world"  $(minishift openshift service infinispan-feed-provider -n myproject --url)/data/add/testKey2018 (1)
wsk activation list -limit 1 cacheEntryTriggerAction (2)
wsk activation result <activation-id> (3)
  1. Add a test cache entry, this by default adds to default cache

  2. Check if the cacheEntryTriggerAction action is triggered as a result of cache entry addition

  3. Check what payload the cacheEntryTriggerAction has recevied

About

OpenWhisk Feed Action for Infinispan Event Source

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published