Should I use Blocking.get in a ratpack.server.service implementation ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Should I use Blocking.get in a ratpack.server.service implementation ?

Massimo Lusetti
I need to get notified when something happen inside my DB and I'm using the neat and great NOTIFY feature from PostgreSQL.

So I've a Service implementation which onStart use my Hikari connection pool to get a connection and fire a LISTEN my_channel Statement .

This cause the connection use to fire the statement to be notified by the DB when someone do a NOTIFY my_channel query.

The question is: Should I use Blocking or any other sort of facilities provided by Ratpack o is fine calling this directly from within the onStart method ?

Thanks for any pointer.
Reply | Threaded
Open this post in threaded view
|

Re: Should I use Blocking.get in a ratpack.server.service implementation ?

Luke Daley
Administrator
You can just call it directly, no problem. Services are init’d one at a time, so you aren’t saving anything by using Blocking. 

If you do use Blocking though, it will still work. 
Reply | Threaded
Open this post in threaded view
|

Re: Should I use Blocking.get in a ratpack.server.service implementation ?

Massimo Lusetti
Thank you very much, especially for the fast reply!