Lesson 1: Create an Event Provider using App Builder
In this lesson, we will do the follow steps:
- Create an event provider using App Builder template
- Register the App as event provider
- Fire Events
- Scheduling cron jobs with alarms
Create an event provider using App Builder template
In this codelab, to provide an end to end solution, we need to have an event provider generating tons of events sending to journaling API, and the events provider need to be configurable to send x events/min to help user to test. so we choose to use OpenWhisk Alarms Package in App Builder application to create cron jobs.
First, let's create a new App Builder App from template by follow the below codelab:
here
please make sure you add I/O management API
in console and choose publish-event
in the cli template.
Register the App as Event Provider
Now we use cli to register the app as event provider, we need to install the Adobe I/O event cli plugin, simply run below:
Copied to your clipboardnpm install -g @adobe/aio-cli-plugin-events
and then follow below codelab step by step: here
Fire Events and set up consume Events
Now we can set up fire event by follow this and make sure that you choose journaling API as the way to consume events by follow this
Scheduling cron jobs with alarms
Follow this codelab to automatically fire event by using runtime alarms package Scheduling Cron Jobs with Alarms
Your app.config.yaml
should look like this as below.
Copied to your clipboardapplication:actions: actionsweb: web-srcruntimeManifest:packages:my-app:license: Apache-2.0actions:generic:function: actions/generic/index.jsweb: 'yes'runtime: 'nodejs:14'inputs:LOG_LEVEL: debugannotations:require-adobe-auth: truefinal: truepublish-events:function: actions/publish-events/index.jsweb: 'yes'runtime: 'nodejs:14'inputs:LOG_LEVEL: debugapiKey: $SERVICE_API_KEYproviderId: $PROVIDER_IDeventCode: $EVENT_CODEclient_id: $CLIENT_IDclient_secret: $CLIENT_SECRETtechnical_account_email: $TECH_ACCOUNT_EMAILtechnical_account_id: $TECH_ACCOUNT_IDims_org_id: $IMS_ORG_IDprivate_key: $PRIVATE_KEYannotations:final: trueTriggers:everyMin:feed: /whisk.system/alarms/intervalinputs:minutes: 1rules:everyMinRule:trigger: everyMinaction: publish-events
In order to test the action, you could execute aio app deploy
in the VSCode terminal. Once the deployment is finished, run aio rt action invoke your-app-name/generic
, and then verify its result and logs using aio rt activation get ID
and aio rt activation logs ID
If successful, the event provider should automatically send the events, you should be able to use postman or curl to verify the journaling API to receive events.