25 lines
1.4 KiB
Plaintext
25 lines
1.4 KiB
Plaintext
## 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 https://github.com/cloudevents/sdk-java[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
|
|
``` |