Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

int-http:inbound-gateway with pollable request channel

I'm looking through some code that is based on spring integration and I've noticed that all int-http:inbound-gateways use pollable request channels:

<int-http:inbound-gateway id="someId"
                                  request-channel="queue-channel"
                                  reply-channel="reply-channel"
                                  request-payload-type="java.lang.String"
                                  supported-methods="POST"
                                  path="/rest/notifications"
                                  auto-startup="true" />

<int:channel id="queue-channel" datatype="java.lang.String">
    <int:queue capacity="100" />
</int:channel>

An explicit poller is specified in the configuration:

<int:poller id="mainSystemPoller" default="true" fixed-delay="500" max-messages-per-poll="1">
    <int:transactional transaction-manager="transactionManager" propagation="REQUIRES_NEW" isolation="DEFAULT"/>
</int:poller>

So the very first channel up the stream is pollable. What are the benefits of using this approach? Does it just give us more flexibility over the business flow(transactional configurations, queue capacity, etc)?

like image 559
yuranos Avatar asked Mar 20 '26 09:03

yuranos


1 Answers

Without the transaction configuration, there is little, if any, value in using a poller there because the http thread will wait in the gateway for the reply anyway.

However, in your case, it will start a transaction and cause everything downstream of the gateway to run in a transaction. But, as configured, this will single-thread your requests; you would need a task executor to handle multiple concurrent requests.

There are other ways to run concurrent web requests in transactions; you can use a transactional gateway instead and then the flow will run on on the web container thread, with the concurrency managed by your web container.

like image 68
Gary Russell Avatar answered Mar 21 '26 22:03

Gary Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!