Event name cleanup in Subscriptions
To conform to Cloud Event specifications, sometimes Eventing must modify the event names to filter out prohibited characters. This tutorial presents one example of event name cleanup. You learn how Eventing behaves when you create a Subscription having prohibited characters in the event names. Read more about Event name format and cleanup.
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.
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 prohibited character, the asterisk *
.
- Kyma Dashboard
- kubectl
Check the Subscription cleaned Event type
To check the Subscription cleaned Event type, run:
kubectl get subscriptions lastorder-payment-sub -o=jsonpath="{.status.types}"
Note that the returned event type ["order.paymentsuccess.v1"]
does not contain the asterisk *
in the payment*success
part. That's because Kyma Eventing cleans out the prohibited 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 prohibited character, and it triggers the Function.
- Port-forward the Event Publisher Proxy 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 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:
Received event: { orderCode: '3211213', orderAmount: '1250' } , Event Type: 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 prohibited characters 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.