spring-nats icon indicating copy to clipboard operation
spring-nats copied to clipboard

Ideas: drain with close, connection bean without real connection

Open moleksyuk opened this issue 4 years ago • 0 comments

Hi guys,

After usage of nats java client with spring-boot-starter I found such inconvenient moments:

  1. Connection implements Autoclosable and it's called during Spring Applicaiton Shutdown but I'm expecting that drain() will be called as well. In this case I need to implement some Spring DispoasableBean and call drain there. 😞 Proposal: include drain() in close().

  2. I have an application that uses Nats. That part of the application is not critical and it's ok if for some period that Nats Cluster will be down. So if Nats Cluster is not up and running I can't:

  • start application
  • scale-up already running application because Nats.connect() will throw an exception and my spring context will not be constructed and application startup fail. Proposal: Maybe return some lazy connection that will try to connect during call some of its interface. But here could be a problem with subscribers that should be created for example in @PostConstruct method.

moleksyuk avatar May 04 '20 12:05 moleksyuk