-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial commit of WebFlux sample #225
base: main
Are you sure you want to change the base?
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.