Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dschulten
Copy link

No description provided.

@pivotal-issuemaster
Copy link

@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.

@pivotal-issuemaster
Copy link

@dschulten Thank you for signing the Contributor License Agreement!

Copy link
Member

@artembilan artembilan left a 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"
Copy link
Member

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)
Copy link
Member

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.

.requestPayloadType(JsonNode.class)
)
.split()
.channel(MessageChannels.flux())
Copy link
Member

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()
Copy link
Member

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))
Copy link
Member

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
Copy link
Member

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() {
}
Copy link
Member

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().

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.

3 participants