Announcement Announcement Module
Collapse
No announcement yet.
Tell thread worker to complete msg processing completely before another one Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tell thread worker to complete msg processing completely before another one

    Greetings,

    I am in process of converting legacy Message Broker API code, Activesw - which was bought by WebMethods - which was bought by SoftwareAG, to JMS. We are many generations behind. We will still use the WebMethod broker and have installed JMS adapter which will allow us the use JMS and spring-frame work container.

    Anyways I have a message type (A) with concurrency set to 3 and number of thread worker set to 3. I am using Default Message Container. The java code, observer, that subscribes to the message type (A) is not thread safe. In fact java code is stateful. Keep in mind, this is legacy code and very expensive to rewrite. I need to be able to process 3 messages at a time in parallel.

    The problem is that the thread worker share the DB connection when processing messages parallel , thus corrupt the data.

    1) Is there a way to tell the thread not to share resources among thread workers.
    2) Is there a way to tell the thread worker to complete the message processing in entirety before processing next one in queue.

    Any help will be greatly appreciated,
    Naresh M.

  • #2
    Is there any way to isolate the part that is not thread safe - either creating some "worker" instance on the fly that you can delegate to when a message is received, or else using an object pool for those stateful instances that can only be used to process one message at a time?

    You can control some settings, such as setting the "concurrent-consumers" value to 1, but that basically has the same drawbacks as using the single-threaded Servlet model.

    Comment


    • #3
      If the only bit that's not threadsafe is the DB, can't you use a connection pool with a max value of one? Worker threads will just have to wait until the DB connection is available.

      Something like apache dbcp?

      http://commons.apache.org/dbcp/

      Comment


      • #4
        Thanks for suggestion. I sort of had idea of the worker but wasn't sure how to implement it. How do I tell the Message Adapter of completion, success/failure? Our System was build in 2000 when EJBs spec had just come out and it seems like everything was coded using EJBs but really did not need it. Anyways, I'll need to do more research.

        Thanks,
        Naresh M.

        Comment

        Working...
        X