Results 1 to 7 of 7

Thread: Confusion on concurrency in Listener template

Hybrid View

  1. #1

    Default Confusion on concurrency in Listener template

    Hi,

    I have few confusion. I will really appreciate if someone correct me.

    A)
    In Spring messaging, we have 2 things

    1) JMS Listener Container
    2) Message Driven POJP (MDP) - Which is a consumer (like EJB MDB)


    Now, in Listener Container we have a "concurrency" attribute. By "concurrency" what I understand is that the number of MDP instance to be created for a single Listener container. Please let me know whether my understanding is correct or not.

    As I understand everything in Spring by default is Singleton bean but if we mention the "concurrency" value more than 1, MDP will no longer be singleton. Please correct my understanding.


    B) Please let me know if there could be any thread related issue in MDP.

    C) I am also confused about the behavior of "prefetch" attribute

    Thanks a lot.

    Best Regards,

    ssroy

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    In both occasions you are wrong...

    The ListenerContainer will remain a singleton no matter how much you specify on concurrency, the same goes for your MDP. Concurrency is simply configuring how many work threads are assigned the task of retrieving messages (and how many connections/sessions are created), default is 1.

    I suggest the JMS chapter of the reference guide as well as the javadoc of the classes and also I suggest to take a look at the implementation of those classes.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Thanks a lot Marten for prompt reply.

    I got your point. But if we create multiple threads to consume messages from provider but have only one instance of MDP (since singleton) then how MDP is going to process these messages. Will these messages be queued or there could be thread safety issues as well? I am really sorry if I am missing something.

    Thanks again. I have read the reference doc but I will go through it again.

    Best Regards,

    ssroy

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    If your MDP is stateless there isn't an issue, if it isn't stateless it shouldn't be a singleton to start with.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Thanks for the inputs.

    Our MDP is implementing MessageListener interface and Stateless in nature.

    But the point that I had mentioned i.e., will the message be queued to be consumed by MDP" is not clear.

    Also, can you please tell me/refer to any article for how to create Stateful consumer.

    Thanks for all your valuable inputs.

    Best Regards - ssroy

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    They will simply be handled by a available thread, I suggest reading 'java concurrency in practice' it is a good read and explains concurrency.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •