Create Subscription subscribing to multiple event types
The Subscription CustomResourceDefinition (CRD) is used to subscribe to events. In this tutorial, you learn how to subscribe to one or more event types using the Kyma Subscription.
Prerequisites
NOTE: Read about Istio sidecars in Kyma and why you want them. Then, check how to enable automatic Istio sidecar proxy injection. For more details, see Default Istio setup in Kyma.
- Follow the Prerequisites steps for the Eventing tutorials.
- Create a Function.
Create a Subscription with Multiple Filters
To subscribe to multiple events, you need a Subscription custom resource. In the following example, you learn how to subscribe to events of two types: order.received.v1
and order.changed.v1
.
- Kyma Dashboard
- kubectl
Trigger the workload with an event
You created the lastorder
Function, and subscribed to the order.received.v1
and order.changed.v1
events by creating a Subscription CR. Now it's time to publish the events and trigger the Function.
In the following example, you port-forward the Event Publisher Proxy Service to localhost.
- Port-forward the Event Publisher Proxy](../../05-technical-reference/00-architecture/evnt-01-architecture.md) Service to localhost, using port
3000
. Run:Click to copykubectl -n kyma-system port-forward service/eventing-event-publisher-proxy 3000:80 Publish an event of type
order.received.v1
to trigger your Function. In another terminal window, run:- CloudEvents Conformance Tool
- curl
Now, publish an event of type
order.changed.v1
to trigger your Function.- CloudEvents Conformance Tool
- curl
Verify the event delivery
To verify that the events were properly delivered, check the logs of the Function (see Verify the event delivery).
You will see the received event in the logs:
Received event: { orderCode: '3211213', orderStatus: 'received' }Received event: { orderCode: '3211213', orderStatus: 'changed' }