问题
I am planning to implement an integration flow as below:
IntegrationFlows.from(httpInboundGateway)
.transform(transformer-rest-api-1)
.transform(transformer-rest-api-2)
.handle(jdbc-outbound)
.handle(http-outbound-gateway-1)
.get();
The requirements that I want to fulfill are:
- to make this run in parallel threads as much as possible
- persist message at every end-point
- make very endpoint as rest-api (to make the flow scalable)
Does it make any sense to make the flow reactive? If so how to go about it? How do I log at every step? (Does wiretap help?), and Finally, can you please provide a concrete example that of a simple implementation for above in java dsl?
回答1:
To make it parallel you need to consider to use an
ExecutorChannel
in between endpoints:IntegrationFlows.from(httpInboundGateway) .channel(c -> c.executor(myTaskExecutor())) .transform(transformer-rest-api-1)
and so on.
However since you would like to have a persistence option, you need to consider to use a
QueueChannel
with a persistentMessageStore
: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management-chapter.html#message-store. Each endpoint then has to be supplied with the poller options, including atasExecutor
for parallel processing:.channel(c -> c.queue(jdbcMessageStore(), "queue1Channel")) .transform(transformer-rest-api-1, e -> e.poller(p -> p.fixedDelay(100).taskExecutor(myTaskExecutor())))
To make endpoints as REST API you just need to use
Http.outboundGateway()
. Or for reactive variant -WebFlux.outboundGateway()
in the.handle()
instead oftransform()
. Or just go ahead in the existing.handle(http-outbound-gateway-1)
in your flowTo make flow reactive you need to use a
.channel(c -> c.flux()))
, but you'l lose a persistence on the matter.To log each step, there is a
.log()
operator to be placed in between endpoints.Your requirements are not clear to share some sample...
来源:https://stackoverflow.com/questions/54405213/advice-on-integration-flow-design