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

  1. Follow the Prerequisites steps for the Eventing tutorials.
  2. 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.

  1. Port-forward the Event Publisher Proxy](../../05-technical-reference/00-architecture/evnt-01-architecture.md) Service to localhost, using port 3000. Run:
    Click to copy
    kubectl -n kyma-system port-forward service/eventing-event-publisher-proxy 3000:80
  2. Publish an event of type order.received.v1 to trigger your Function. In another terminal window, run:

    • CloudEvents Conformance Tool
    • curl
  3. 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:

Click to copy
Received event: { orderCode: '3211213', orderStatus: 'received' }
Received event: { orderCode: '3211213', orderStatus: 'changed' }