Event name cleanup in Subscriptions

To conform to Cloud Event specifications, sometimes Eventing must modify the event names to filter out non-alphanumeric characters. This tutorial presents one example of event name cleanup. You learn how Eventing behaves when you create a Subscription having alphanumeric characters in the event names. Read more about Event name format and cleanup.

Prerequisites

  1. Follow the Prerequisites steps for the Eventing tutorials.
  2. Create a Function.
  3. For this tutorial, instead of the default code sample, replace the Function source with the following code:

    • Kyma Dashboard
    • kubectl

Create a Subscription with Event type consisting of alphanumeric characters

Create a Subscription custom resource and subscribe for events of the type: order.payment-success.v1. Note that order.payment-success.v1 contains a non-alphanumeric character, the hyphen -.

  • Kyma Dashboard
  • kubectl

Check the Subscription cleaned Event type

To check the Subscription cleaned Event type, run:

Click to copy
kubectl get subscriptions lastorder-payment-sub -o=jsonpath="{.status.cleanEventTypes}"

Note that the returned event type ["sap.kyma.custom.myapp.order.paymentsuccess.v1"] does not contain the hyphen - in the payment-success part. That's because Kyma Eventing cleans out the non-alphanumeric characters from the event name and uses the cleaned event name in the underlying Eventing backend.

Trigger the workload with an event

You created the lastorder Function, and subscribed to the order.payment-success.v1 events by creating a Subscription CR. Next, you see that you can still publish events with the original Event name (i.e. order.payment-success.v1) even though it contains the non-alphanumeric character, and it will trigger the Function.

  1. Port-forward the Event Publisher Proxy 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 to trigger your Function. In another terminal window, run:

    • CloudEvents Conformance Tool
    • curl

Verify the event delivery

To verify that the event was properly delivered, check the logs of the Function (see Verify the event delivery).

You see the received event in the logs:

Click to copy
Received event: { orderCode: '3211213', orderAmount: '1250' } , Event Type: sap.kyma.custom.myapp.order.paymentsuccess.v1

Note that the Event Type of the received event is not the same as defined in the Subscription.

Conclusion

You see that Kyma Eventing modifies the event names to filter out non-alphanumeric character to conform to Cloud Event specifications.

CAUTION: This cleanup modification is abstract; you can still publish and subscribe to the original Event names. However, in some cases, it can lead to a naming collision as explained in Event names.