2 Replies Latest reply on Oct 19, 2010 9:04 PM by rajks

    Producer, Server and Consumer

    rajks Newbie

      Hi,

       

      I am trying to use the HQ in our development and I would appreciate any help from the forum on with the following questions

       

      We want to have many producers and many instances of  (server+consumer) with multiple threads per queue to consume the mesage and process it.

       

      We plan to use the CORE API and not use JMS.

       

      1. Producers

       

          a. will be multithreaded in our case - hence can the producer use the same session factory, session and client producer in mutiple threads concurrently or should we create instances of the above (sf, session, producer) per thread.

       

          b. we have three queues - again how should we handle producers per queue in multi-threaded situation where there could be concurrent posting to same queue from multiple threads.

       

       

      2. Server and Consumers

       

          a) can the Server and Consumer coexists in one process.

       

          b) Consumer - we would like to have N threads per queue to process the message.

              Hence how should we create session factory, session and Consumers  in this scenario.

              What can be shared across in this mutiple consumer threads ( sf, session, consumer per queue) -

       

      3. How do we handle redelivery with max attempts. As it is possible that we could not process the queue item and we would like to retry the queue item later on again.

       

      Appreciate some details in multithreaded scenarios.

        • 1. Re: Producer, Server and Consumer
          Clebert Suconic Master

          A Session object is meant to be used by a single thread at any point.

           

          You could specify multiple sessions (one for each thread),

           

          or you could protect the access with synchronized blocks (you would be making it single thread on this case).  I mean.. you could but you shouldn't... just create one for each thread.

           

           

          2. Same as above... use multiple sessions. You can also use Message Listeners.

           

          When you say server and consumer on the same process, I assume you're talking about embedding the server? We do that all the time. It's part of the docs and there are a few examples doing it.

           

           

          3. Look at the DLA (Dead Letter Address) documentation. I'm not sure if you have a more specific question. Maybe you could ask something more specific?

          • 2. Re: Producer, Server and Consumer
            rajks Newbie

            Thanks for taking time to respond.

            As you have mentioned it is better that each thread should have its own session, does it mean that the following handles should be created every thread

                - ClientSessionFactory,

                - ClientSession

                - ClientConsumer

             

            or the client session factory can be shared by multiple threads to create individual instances of ClientSession per thread.

             

            What about the client consumer - can we use a single client consumer instance with N multiple threads to process that one queue ????

             

            On Redelivery -

            Ideally we would like to configure the AddressSettings for each queue with a redeliveryDelay of N minutes and MaxDeliveryAttempts say 10.

            Say when we consume an item from the queue and if there is a failure to process that queue item - in this case we would like to not ACK.

            What should be done in the code to to get this redelivered if we don't want to ack (based on the address settings). Should we do session.rollback ???

            Also we would like to get the current number of delivery count when we get the queue item so we could do some action on our end before this goes to DLA.

             

            Thanks in advance.