问题
I'm trying to solve following problem:
- I have 2 SimpleMessageListenerContainer defined in java conf.
- Each of them has it's own listener wrapped with adapter and they both use same CachingConnectionFactory(is it ok?). In addition each of them handles different queue(with constant name)
- I'm testing scenario when for whatever reason one of the queues is deleted.
- When I'm deleting it manually from web admin console the container tries to redefine this queue and fails(all retries fail). The exception is not really tells the reason of the failure.
- Eventually all the consumer threads of this queue are "restarted" however they wont consume any messages further. Even though somebody else will redefine this queue(e.g. producer)
so there are several questions:
- Can I fix redefinition of the queue somehow, or check why the redefinition fails? On fresh start the definition of queues works. Which brings me to next question
- Might be I can make heartbeat sender to use daemon thread somehow? It prevents jvm from exiting, so the restart isn't happening. It won't solve problem, but fresh jvm process succeeds to redefine queues. Restart will be caused by supervisor.
Meanwhile I'm getting situation when all consumers(under first container) for deleted queue are not really working, I'd expect that jvm will exit, however probably since I have second container which is ok(all consumers alive and queue exists), the jvm continues to live(might be when second container will be shutdown the heartbeat sender also will stop?)
any suggestions will be appreciated. If needed I'll post code snippets of java configuration.
回答1:
We just "fixed" this by adding a missing-queues-fatal
attribute to the listener container.
See the pull request here.
We can't make schema changes in point releases so there's a couple of ways to configure it in 1.3.x; it has been added to the schema in 1.4.x and will be available in <rabbit:listener-container/>
; you can see the 1.4.x Pull Request here.
1.3.5 should be available later this week, or next, but you can try 1.3.5.BUILD-SNAPSHOT
now if you want.
When it is set to false (default true), the container will go into recovery mode, using the recovery-interval
.
Documentation for the 1.3.5. snapshot is here.
来源:https://stackoverflow.com/questions/24373588/deleted-queue-is-not-redefined-consumers-stop-to-handle-messages