Announcement Announcement Module
No announcement yet.
Thread allocation on SimpleMessageListenerContainer restart Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thread allocation on SimpleMessageListenerContainer restart

    I am just exposing some methods via jmx using which admin can do a
    1. start container
    2. stop container
    3. scale up/down consumers (concurrent consumers)

    I am able to do this, but while implementing this i just noticed one thing.

    When the container is running, on console i see:
    DEBUG SimpleAsyncTaskExecutor-1 [qp.rabbit.listener.BlockingQueueConsumer]: Retrieving delivery.......
    When i stop it and start it again, i now see:
    DEBUG SimpleAsyncTaskExecutor-2 [qp.rabbit.listener.BlockingQueueConsumer]: Retrieving delivery.......
    Now my question is what happend to SimpleAsyncTaskExecutor-1, when i restarted the container. Why did it create a new SimpleAsyncTaskexecutor-2?

    Does that mean on every restart, new executors are created ? If yes what happens to the old ones?
    Isn't this a possible memory leak?

    Please help

  • #2
    No; it's not a leak; that's just the way the SimpleAsyncTaskExecutor names its threads. You get a new thread for each task; stopping the listener container terminates the original thread (...-1).

    See the javadoc here

    If you want to reuse the original thread(s), use a thread-pooling TaskExecutor instead of the default SimpleAsyncTaskExecutor. You can inject your chosen TaskExecutor into the listener container.