Skip to content

Conversation

@salaboy
Copy link

@salaboy salaboy commented Jul 20, 2020

Here are some helpers for Spring Boot (web and webflux) to parse and send Cloud Events from Spring Boot applications.
This is based on this blog post which contains some examples (examples in the blog post needs to be updated to use the new version of the helpers provided in this PR)

https://salaboy.com/2020/02/20/getting-started-with-knative-2020/

@salaboy salaboy mentioned this pull request Jul 20, 2020
@salaboy
Copy link
Author

salaboy commented Jul 20, 2020

@spencergibb @cmoulliard @olegz @slinkydeveloper I am happy to accept feedback to make this better..

salaboy added 2 commits July 20, 2020 11:36
Signed-off-by: salaboy <salaboy@gmail.com>
Signed-off-by: salaboy <salaboy@gmail.com>
@slinkydeveloper
Copy link
Member

slinkydeveloper commented Jul 20, 2020

Hi @salaboy! Thanks for looking at this! I wonder, can you use the message reader/writer APIs like in https://github.com/cloudevents/sdk-java/tree/master/http? I can guide you through, look at the vertx or restful ws module implementations and they should give you an idea of how it looks like

@slinkydeveloper slinkydeveloper self-requested a review July 20, 2020 10:38
Copy link
Member

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the .DS_Store file and the LICENSEs (we don't need them because they're already in the root of the project)

@salaboy
Copy link
Author

salaboy commented Jul 20, 2020

@slinkydeveloper sure I can.. sorry about the .DS_Store files.. I am adding them to .gitignore now.

Also @slinkydeveloper you mean doing something like:

implements CloudEventWriter<Void>, MessageWriter<RestfulWSMessageWriter, Void>

For spring boot?

Signed-off-by: salaboy <salaboy@gmail.com>
@slinkydeveloper
Copy link
Member

@salaboy exactly. You need to think at these Reader/Writer as kind of builders, that allows you to read write cloudevents without caring about the differences between spec versions and "modes". If you need any help with these, feel free to reach me on cncf slack at @slinkydeveloper

Signed-off-by: salaboy <salaboy@gmail.com>

```java
@PostMapping
public String recieveCloudEvent(@RequestHeader Map<String, String> headers, @RequestBody Object body) {
Copy link

@metacosm metacosm Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: recieve -> receive 😄

Suggested change
public String recieveCloudEvent(@RequestHeader Map<String, String> headers, @RequestBody Object body) {
public String receiveCloudEvent(@RequestHeader Map<String, String> headers, @RequestBody Object body) {

```xml
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>spring-boot-starter-web-cloudevents</artifactId>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is gonna to release/maintain such a starter like also the WebFlux one ? @salaboy


```java
// Create the CloudEvent with the builder
final CloudEvent myCloudEvent = CloudEventBuilder.v03()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding the version of the spec or the version of the builder (v03, V1, ....) is perhaps not a great idea. I would prefer that this version is part of the GAV consumed by the starter to make it available publicly to all the users.

@slinkydeveloper
Copy link
Member

@salaboy check out this one #288

@salaboy
Copy link
Author

salaboy commented Nov 20, 2020

@slinkydeveloper I will be happy to check if the new PR is covering what I needed to do from my side..

@salaboy
Copy link
Author

salaboy commented Dec 30, 2020

@slinkydeveloper I will close this PR because this was solved already! I am super happy with the results! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants