Publish legacy events using Kyma Eventing
Kyma Eventing also supports sending and receiving of legacy events. In this tutorial we will show how to send legacy events.
NOTE: It is recommended to use CloudEvents specification for sending and receiving events in Kyma.
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
To subscribe to events, we need a Subscription custom resource. We're going to subscribe to events of the type order.received.v1
.
- Kyma Dashboard
- kubectl
Publish a legacy event to trigger the workload
You created the lastorder
Function, and subscribed to the order.received.v1
events by creating a Subscription CR. Now it's time to send an event and trigger 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:
Click to copycurl -v -X POST \--data @<(<<EOF{"event-type": "order.received","event-type-version": "v1","event-time": "2020-09-28T14:47:16.491Z","data": {"orderCode":"3211213"}}EOF) \-H "Content-Type: application/json" \http://localhost:3000/myapp/v1/eventsNOTE: If you want to use a Function to publish a CloudEvent, see the Event object SDK specification.
Verify the legacy 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' }