On the way: filter and steps
Eventing 5 · 3:09
A filter decides which events an event subscription passes on, and a step changes each event before it reaches the channel, in this video by turning a JSON body into fields.
What it covers
- A filter with the JSONPath
$.invoicein the subscription document - Plain-text events that the filter removes, counted in the subscription's log
- Adding the
json-deserialize-actionstep understeps - Each change built as a new version and deployed with
weikio run - The subscription drawn as boxes in a row in the admin UI
- The flow, the version and the state in
weikio get eventsubscriptions
Commands in this video
Terminal
$ weikio run ./files-to-invoices
$ weikio run ./invoice-files
$ weikio logs sandbox/files-to-invoices -f --since 10m
$ weikio get eventsubscriptionsTranscript
- 0:02In video four, a type gave the channel its delivery.
- 0:05This video shapes what flows on the way, with a filter and steps.
- 0:16So far, the flow works end to end.
- 0:19The source publishes into invoice-files, the subscription forwards,
- 0:24and the watcher reads invoice-created.
- 0:27The channel still has its type from video four, and the receiver gets every invoice.
- 0:33This video shapes what the subscription does with the events.
- 0:42A filter is the test an event must pass before it flows on.
- 0:46The test is a jsonPath of $.invoice,
- 0:49and it passes an event when the path matches at least one node of its body.
- 0:54The filter is a member of the subscription document.
- 0:57Dropped events are counted in the subscription's own log line.
- 1:04Add a filter to the subscription file, with that jsonPath.
- 1:08Run the document: it applies the change and builds version 0.1.1.
- 1:14The run deploys it too, and that puts the filter on the agent.
- 1:18The flow is unchanged for now, because every event carries an invoice node.
- 1:23Change the source's message to plain text, and run the source again.
- 1:29Change the message back, and the invoices flow again.
- 1:39While it was plain, the subscription's log line counted each dropped event.
- 1:51Add one step to the subscription file, json-deserialize-action.
- 1:56A step is a kamelet action under steps, applied in the order listed.
- 2:01json-deserialize-action turns a JSON body into fields a later step can address.
- 2:08Run the document: it builds the next version, and the deploy puts it live,
- 2:14so the step runs before the event reaches the channel.
- 2:17The admin UI shows the same document, as boxes in a row.
- 2:21It names the source channel, the filter, the step and the channel.
- 2:30get eventsubscriptions lists the flow.
- 2:33The flow is invoice-files to invoice-created, as it was before.
- 2:38The version is the latest, and the state is started in devtest.
- 2:46Here is the whole picture.
- 2:48The source publishes, the filter keeps the invoices,
- 2:52the step turns them into fields, and the channel delivers.
- 2:56One filter and one step shaped the flow on the way.
Next in this track
Eventing 6 · 3:20 Dead letters Watched