Is it recomended to publishOn after every database call? #418
kurt-jadson
started this conversation in
General
Replies: 1 comment 2 replies
-
What's the motivation for switching threads? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I tried to ask this on spring-data-r2dbc project, but since there is no discussion tab opened there I cannot get find a good place to ask this, hope that someone could clarify it to me because I do not find good answers in stackoverflow for that.
So, here is my Controller endpoint
and here is the Service class method:
In test #1 I just ran it without any publishing to other Scheduler. So the result is:
So, what I am understanding is that r2dbc driver is switching to a
reactor-tcp-nio
thread to execute the SQL statement. Once it gets result back, then all the consecutive operations such as map gets executed in the same thread.In test #2 I intencionally published the results of the query to a boundedElastic scheduler. Now you can see:
R2DBC executes the SQL statement in a
reactor-tcp-nio
thread, but the map and other operations takes place inboundedElastic
.So, my question is:
Is it a recomendation that we always
publishOn
the results of the database call to another scheduler?Here is a sample that I found in my researchs but using JDBC instead.
Beta Was this translation helpful? Give feedback.
All reactions