Spring amqp: detect shutdown and reconnect to another queue -
we have setup call webservice create queue, , receive queue name response.
then set simplemessagelistenercontainer , set queue name there, , start it.
however, time time, queue deleted - resulting in "404 not declare queue xxxxxxxxx" error. in these cases, need call webservice again , add new queuename simplemessagelistenercontainer , removing old one.
the way figured out trigger code handle create custom cachedconnectionfactory , overriding shutdowncompleted method.
however, shutdowncompleted seems trigger when simplemessagelistenercontainer switches on well, sticks in loop. shutdownsignalexception sent shutdowncompleted not seem different if trigger external server or client handling new queue, can't figure out how skip handling on "second" go.
so usual way detect , run custom handling when server kills queue?
the container publishes listenercontainerconsumerfailedevent
when listener fails.
add applicationlistener<listenercontainerconsumerfailedevent>
, stop container, change queues , restart.
you multiple events because, default, container try reconnect 3 times before giving , stopping itself.
Comments
Post a Comment