-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-422 Improvements in cloud event samples
Added initial README Polished tests
- Loading branch information
Showing
7 changed files
with
179 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
spring-cloud-function-samples/function-sample-cloudevent/README.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## Cloud Events with Spring samples | ||
|
||
### Introduction | ||
The current example uses spring-cloud-function framework as its core which allows users to only worry about functional aspects of | ||
their requirement while taking care-off non-functional aspects. For more information on Spring Cloud Function please visit | ||
our https://spring.io/projects/spring-cloud-function[project page]. | ||
The example provides dependency and instructions to demonstrate several distinct invocation models: | ||
|
||
- Direct function invocation | ||
- Function as a REST endpoint | ||
- Function as message handler (e.g., Kafka, RabbitMQ etc) | ||
- Function invocation via RSocket | ||
|
||
The POM file defines all the necessary dependency in a segregated way, so you can choose the one you're interested in. | ||
|
||
#### Direct function invocation | ||
|
||
#### Function as a REST endpoint | ||
|
||
Given that SCF allows function to be exposed as REST endpoints, you can post cloud event to any of the | ||
functions by using function name as path (e.g., localhost:8080/<function_name>) | ||
|
||
Here is an example of curl command posting a cloud event in binary-mode: | ||
|
||
[source, text] | ||
---- | ||
curl -w'\n' localhost:8080/asPOJO \ | ||
-H "ce-Specversion: 1.0" \ | ||
-H "ce-Type: com.example.springevent" \ | ||
-H "ce-Source: spring.io/spring-event" \ | ||
-H "Content-Type: application/json" \ | ||
-H "ce-Id: 0001" \ | ||
-d '{"releaseDate":"24-03-2004", "releaseName":"Spring Framework", "version":"1.0"}' | ||
---- | ||
|
||
And here is an example of curl command posting a cloud event in structured-mode: | ||
|
||
[source, text] | ||
---- | ||
curl -w'\n' localhost:8080/asString \ | ||
-H "ce-Specversion: 1.0" \ | ||
-H "ce-Type: com.example.springevent" \ | ||
-H "ce-Source: spring.io/spring-event" \ | ||
-H "Content-Type: application/cloudevents+json" \ | ||
-H "ce-Id: 0001" \ | ||
-d '{ | ||
"specversion" : "1.0", | ||
"type" : "org.springframework", | ||
"source" : "https://spring.io/", | ||
"id" : "A234-1234-1234", | ||
"datacontenttype" : "application/json", | ||
"data" : { | ||
"version" : "1.0", | ||
"releaseName" : "Spring Framework", | ||
"releaseDate" : "24-03-2004" | ||
} | ||
}' | ||
---- | ||
|
||
#### Function as message handler (e.g., Kafka, RabbitMQ etc) | ||
|
||
Streaming support for Kafka and Rabbit is provided via Spring Cloud Stream framework (link). In fact we're only mentioning Kafka and Rabbit here as an example. | ||
Streaming support is automatically provided for any existing binders (e.g., Solace, GCP, AWS etc) (link) | ||
Binders are components of SCSt responsible to bind user code (e.g., function) to broker destinations so execution is triggered | ||
by messages on broker destination and results of execution are sent to broker destinations. Binders also provide support consumer | ||
groups and partitioning for both Kafka and RabbitMQ messaging systems. | ||
|
||
|
||
#### Function invocation via RSocket | ||
|
||
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...e-cloudevent/src/test/java/io/spring/cloudevent/CloudeventDemoApplicationStreamTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2020-2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.spring.cloudevent; | ||
|
||
/** | ||
* | ||
* @author Oleg Zhurakousky | ||
* | ||
*/ | ||
public class CloudeventDemoApplicationStreamTests { | ||
|
||
|
||
} |