Search code examples
cloudantopenwhisk

OpenWhisk: how to include new/updated document in Cloudant change feed


Following the steps outlined in http://heidloff.net/article/how-to-trigger-openwhisk-cloudant, the triggered action does not receive the JSON document as a parameter, even though the trigger definition includes includeDocs true.

Details:

Define an action (displayEvent.js) that simply returns the parameters:

function main(params) {
  return {payload:  params};
}

Create action:

$ wsk action update displayEvent displayEvent.js
ok: updated action displayEvent

Bind Cloudant package:

$ wsk package bind /whisk.system/cloudant srcCloudant --param bluemixServiceName cloudant_for_openwhisk --param dbname src --param host *** --param overwrite false --param username *** --param password ***

Create trigger for Cloudant change feed:

$ wsk trigger create newTrackingEvent --feed /ptitzler_org_dev/srcCloudant/changes --param includeDocs true 
ok: invoked /...

(I also tried parameter include_docs but the results are the same.)

Activity log entries:

"2017-01-25T16:12:34.711142625Z stdout: cloudant trigger feed:  { bluemixServiceName: 'cloudant_for_openwhisk',",
"2017-01-25T16:12:34.711173464Z stdout: authKey: '***',",
"2017-01-25T16:12:34.711184757Z stdout: username: '***',",
"2017-01-25T16:12:34.711194489Z stdout: host: '***',",
"2017-01-25T16:12:34.711205213Z stdout: dbname: 'src',",
"2017-01-25T16:12:34.711214336Z stdout: includeDocs: true,",
"2017-01-25T16:12:34.711223392Z stdout: overwrite: false,",
"2017-01-25T16:12:34.711233436Z stdout: package_endpoint: '10.143.15.111:11000',",
"2017-01-25T16:12:34.711242728Z stdout: lifecycleEvent: 'CREATE',",
"2017-01-25T16:12:34.711251853Z stdout: triggerName: '/_/newTrackingEvent',",
"2017-01-25T16:12:34.711261256Z stdout: password: '***' }",
"2017-01-25T16:12:34.810688295Z stdout: cloudant trigger feed: done http request",
"2017-01-25T16:12:34.811401516Z stdout: { id: ':ptitzler_org_dev:newTrackingEvent',",
"2017-01-25T16:12:34.811430393Z stdout: accounturl: 'https://***-bluemix.cloudant.com',",
"2017-01-25T16:12:34.811441235Z stdout: dbname: 'src',",
"2017-01-25T16:12:34.811451032Z stdout: user: '***',",
"2017-01-25T16:12:34.811460676Z stdout: pass: '***',",
"2017-01-25T16:12:34.81147041Z  stdout: host: '***-bluemix.cloudant.com',",
"2017-01-25T16:12:34.811490203Z stdout: protocol: 'https',",
"2017-01-25T16:12:34.811500637Z stdout: apikey: '***',",
"2017-01-25T16:12:34.811518951Z stdout: callback: { action: { name: '/ptitzler_org_dev/newTrackingEvent' } },",
"2017-01-25T16:12:34.811528767Z stdout: maxTriggers: -1,",
"2017-01-25T16:12:34.811537989Z stdout: triggersLeft: -1,",
"2017-01-25T16:12:34.811558803Z stdout: retriesLeft: 10 }"

Create rule:

$ wsk rule create logEvent newTrackingEvent displayEvent
ok: created rule logEvent

Create new document in Cloudant

{
 "_id": "0689f19a88edd98512a33df24ab084a4",
 "myproperty": 123
}

The resulting displayEvent activity log output only includes the document metadata but not the document itself:

{

"duration": 64,
"name": "displayEvent",
"subject": "***",
"activationId": "8d81abfb258e4752bbe74d79601c5a7e",
"publish": false,
"annotations": [
    {
        "key": "limits",
        "value": {
            "timeout": 60000,
            "memory": 256,
            "logs": 10
        }
    },
    {
        "key": "path",
        "value": "ptitzler_org_dev/displayEvent"
    }
],
"version": "0.0.4",
"response": {
    "result": {
        "payload": {
            "seq": "10-g1...4",
            "id": "0689f19a88edd98512a33df24ab084a4",
            "changes": [
                {
                    "rev": "1-bf5fdf2758669105decf1fa0c6853626"
                }
            ],
            "dbname": "src"
        }
    },
    "success": true,
    "status": "success"
},
"end": 1485361317416,
"logs": [ ],
"start": 1485361317352,
"namespace": "ptitzler_org_dev"
}

What am I missing?


Solution

  • includeDocs is no longer supported. Please see the following: https://developer.ibm.com/openwhisk/2016/12/05/cloudant-feed-change-no-longer-support-includedocs/