/jms-feed-action

OpenWhisk JMS Feed Action

Primary LanguageJavaApache License 2.0Apache-2.0

Feed Action

This feed action is responsible for creating the JMS Feed 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 artemis and jms-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/jms-feed \
 target/jms-feed-action.jar --main org.workspace7.openwhisk.JmsFeedAction
  1. if you have WSK CLI installed, post package

Create Trigger

Pre-requisite

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

Create Trigger, Action and Rule

wsk -i trigger create jmsTrigger --feed redhatdevelopers/jms-feed \
		-p destinationName demo_queue (1)

wsk action create jmsTriggerAction src/handler.js (4)
wsk rule create jmsEntryRule jmsTrigger jmsTriggerAction (5)
  1. If you deployed Artemis using method referenced in Pre-requisite, then the default artemis client name would be is artemis-client and by default this is accessible only from within OpenShift cluster. We make this trigger to have Event Source only from the JMS Destination demo_queue

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

  3. 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/{destinationName} which can be used to add dummy entry to see the cache entry event triggering the jmsTriggerAction

curl -X GET  --data "hello world"  $(minishift openshift service jms-feed-provider -n myproject --url)/data/add/demo_queue (1)
wsk activation list -limit 1 jmsTriggerAction (2)
wsk activation result <activation-id> (3)
  1. Send a message to JMS Destination demo_queue

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

  3. Check what payload the jmsTriggerAction has recevied