initial commit of WebFlux sample#225
Conversation
|
@dschulten Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@dschulten Thank you for signing the Contributor License Agreement! |
artembilan
left a comment
There was a problem hiding this comment.
Grate stuff, @dschulten !
Just several minor concerns to consider!
| dependencies { | ||
| compile 'org.springframework.boot:spring-boot-starter-integration' | ||
| compile "org.springframework.boot:spring-boot-starter-webflux" | ||
| compile "org.springframework.integration:spring-integration-core" |
There was a problem hiding this comment.
We don't need this dependency - it is polled by the spring-boot-starter-integration, as well as by the spring-integration-webflux.
|
|
||
| This sample demonstrates the usage of the WebFlux protocol adapter to split incoming messages to different routes and provide the results as SSE events. | ||
|
|
||
| NOTE: at the time of this writing, [the WebFlux integration drops POST messages with empty request body](https://jira.spring.io/browse/INT-4462) |
There was a problem hiding this comment.
This has been fixed and 5.0.5 released.
We can remove this sentence altogether.
...ux/src/main/java/org/springframework/integration/samples/dsl/webflux/WebFluxApplication.java
Outdated
Show resolved
Hide resolved
| .requestPayloadType(JsonNode.class) | ||
| ) | ||
| .split() | ||
| .channel(MessageChannels.flux()) |
There was a problem hiding this comment.
Please, add this one before split() as well. This way we will have full Reactive flow.
| .split() | ||
| .channel(MessageChannels.flux()) | ||
| .<TextNode, String>route(o -> o.asText(), | ||
| m -> m.defaultOutputToParentFlow() |
There was a problem hiding this comment.
Why do we need defaultOutputToParentFlow()?
Is there some incoming values we cannot map with those subFlows ?
| .from(WebFlux.inboundGateway("/events") | ||
| .requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE))) | ||
| .handle((p, h) -> Flux.from(reactiveSource()) | ||
| .map(Message::getPayload)) |
There was a problem hiding this comment.
I think we don't need to extract just payload - the WebFlux.inboundGateway() will do that for us properly.
On the other hand we don't need to wrap to the Flux.from() I believe.
How does it work if you only have .handle((p, h) -> reactiveSource()) ?
| @@ -0,0 +1,2 @@ | |||
| logging.level.org.springframework.web: DEBUG | |||
| logging.level.org.springframework.integration: DEBUG No newline at end of file | |||
There was a problem hiding this comment.
New line in the end of each file.
You can configure your IDE to do that for your on file save.
|
|
||
| @Test | ||
| public void contextLoads() { | ||
| } |
There was a problem hiding this comment.
Would be great to have some content in this test to be sure that our flow is correct.
You can borrow some ideas how to test it from here: https://github.com/spring-projects/spring-integration/blob/master/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java
Although you can do it with the webEnvironment = WebEnvironment.RANDOM_PORT and WebTestClient.bindToServer().
No description provided.