Skip to content

Files

Latest commit

00ec64d · Mar 21, 2025

History

History

function-sample-cloudevent-sdk

Examples of integration with Cloud-Event SDK

Introduction

As described in these two blog posts (https://spring.io/blog/2020/12/10/cloud-events-and-spring-part-1 & https://spring.io/blog/2020/12/23/cloud-events-and-spring-part-2), Spring natively supports Cloud Event specification so to work with Cloud Events you don’t need anything and function-sample-cloudevent, function-sample-cloudevent-rsocket and function-sample-cloudevent-stream examples show exactly how you can benefit from Spring’s transparent handling of Cloud Events.

So this example shows integration of Spring with Cloud Event SDK (not managed by Spring).

Note
This is only to demonstrate the integration capabilities with Cloud Event SDK (regardless of the reason). It is NOT required to work with Cloud Events.

In this example the echo function uses CloudEvent type from java SDK to receive Cloud Event and echo it back using CloudEventBuilder. Note that you also need to register CloudEventMessageConverter

Simply start the DemoApplication. Once started access the echo function exposed as an HTTP endpoint

curl -v -d '{"value": "Foo"}' \
    -H'Content-type: application/json' \
    -H'ce-id: 1' \
    -H'ce-source: function-sample-cloudevent-sdk' \
    -H'ce-type: my.application.Foo' \
    -H'ce-specversion: 1.0' \
    http://localhost:8080/echo