Multiple Consumers on a set of Queues

Is there any better way of implementing this other than polling all the queues?
or is there are any 3rd party library, which can do this already.
Regards
Gopal

Sure, you use wait/notify. The consumer syncrhonizes on a suitable monitor, then checks all the queues, and waits if they are all empty. Producers for any of the queues notify all the consumers.
You'd probably want the consumer threads to check the queues cyclically, rather than starting at the beginning each time they find an object so that they don't favour one queue excessively.

Similar Messages

  • Could multiple consumers attach to a JMS queue simultaneously?

    Could a JMS message queue have multiple consumers simultaneously? If can, how to implement that? My experiences showed that at any time there is only one consumer allowed for a JMS message queue. If a subsequent consumer tried to attach to the same queue, the following exception would be thrown out:
    =====================================================
    javax.jms.ResourceAllocationException: [C4073]: A JMS destination limit was reached. Too many Subscribers/Receivers for Queue : PhysicalQueue user=guest, broker=CTPLIT015PC:7676(1462)======================================================
    On the contrary, definitely multiple consumers can be attached to the same Topic.

    Well I need tor receive a message only once and this is why I would still have to use a queue. I have heard selector are slow so I do not want to use them.
    Now the problem is since I am using onMessage event; the message push is like 150 message/second. While the message dequeue process always stuck up at 14 message/second.
    I really need to increase the speed some good number may be 50 messages/second. I need to know whether I need to setup a threadmanager (with threadpool) in onMessage event, or I need to create multiple queue session.
    If I create multiple queue session what would be the behavior of queue?
    My main concern is to get this number up.
    regards
    shantanu

  • Single queue: concurrent processing of messages in multiple consumers

    Hi,
    I am new to jms . The goal is to  process messages concurrently from a queue in an asynchronous listener's onMessage method  by attaching a listener instance to multiple consumer's with each consumer using its own session and running in a separate thread, that way the messages are passed on to the different consumers for concurrent processing. 
    1) Is it ossible to process messsages concurrently from a single queue by creating multiple consumers ?
    2)  I came up with the below code, but would like to get your thoughts on whether the below code looks correct for what I want to accomplish.  
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Properties;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import com.walmart.platform.jms.client.JMSConnectionFactory;
    public class QueueConsumer implements Runnable, MessageListener {
      public static void main(String[] args) {
       // Create an instance of the client
        QueueConsumer consumer1 = new QueueConsumer();
        QueueConsumer consumer2 = new QueueConsumer();
        try {
        consumer1.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON");   //US.Q.CHECKOUT-ORDER.1.0.JSON   is the queue name
        consumer2.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON");
        }catch( JMSException ex ){
        ex.printStackTrace();
        System.exit(-1);
        // Start the client running
        Thread newThread1 = new Thread(consumer1);
        Thread newThread2 = new Thread(consumer1);
        newThread1.start();newThread2.start();
        InputStreamReader aISR = new InputStreamReader(System.in);
              char aAnswer = ' ';
              do {
                  try {
      aAnswer = (char) aISR.read();
    catch (IOException e)
      // TODO Auto-generated catch block
      e.printStackTrace();
    } while ((aAnswer != 'q') && (aAnswer != 'Q'));
              newThread1.interrupt();
              newThread2.interrupt();
              try {
      newThread1.join();newThread2.join();
      } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
              System.out
      .println("--------------------exiting main thread------------------------"+Thread.currentThread().getId());
            System.exit(0);
    // values will be read from a resource properties file
    private static String connectionFactoryName = null;
    private static String queueName = null;
    // thread safe object ref
      private static ConnectionFactory qcf = null;
      private static Connection queueConnection = null;
    // not thread safe
      private Session ses = null;
      private Destination queue = null;
      private MessageConsumer msgConsumer = null;
      public static final Logger logger = LoggerFactory
      .getLogger(QueueConsumer.class);
      public QueueConsumer() {
      super();
      public void onMessage(Message msg) {
      if (msg instanceof TextMessage) {
      try {
      System.out
      .println("listener is "+Thread.currentThread().getId()+"--------------------Message recieved from queue is ------------------------"
      + ((TextMessage) msg).getJMSMessageID());
      } catch (JMSException ex) {
      ex.printStackTrace();
      public void run() {
      // Start listening
      try {
      queueConnection.start();
      } catch (JMSException e) {
      e.printStackTrace();
      System.exit(-1);
      while (!Thread.currentThread().isInterrupted()) {
      synchronized (this) {
      try {
      wait();
      } catch (InterruptedException ex) {
      break;
      * This method is called to set up and initialize the necessary Session,
      * destination and message listener
      * @param queue2
      * @param factoryName
      public void init(String factoryName, String queue2) throws JMSException {
      try {
      qcf = new JMSConnectionFactory(factoryName);
      /* create the connection */
      queueConnection = qcf.createConnection();
      * Create a session that is non-transacted and is client
      * acknowledged
      ses = queueConnection.createSession(false,
      Session.CLIENT_ACKNOWLEDGE);
      queue = ses.createQueue(queue2);
      logger.info("Subscribing to destination: " + queue2);
      msgConsumer = ses.createConsumer(queue);
      /* set the listener  */
      msgConsumer.setMessageListener(this);
      System.out.println("Listening on queue " +queue2);
      } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
      private static void setConnectionFactoryName(String name) {
      connectionFactoryName = name;
      private static String getQueueName() {
      return queueName;
      private static void setQueueName(String name) {
      queueName = name;

    Hi Mark,
    if the messages are sent with quality of service EO (=exactly once) you can add queues.
    From documentation:
    Netweaver XI -> Runtime -> Processing xml messages -> Queues for asynchronous message processing
    ...For incoming messages you set the parameter EO_INBOUND_PARALLEL from the Tuning category.
    If more than one message is sent to the same receiver, use the configuration parameter EO_OUTBOUND_PARALLEL of the Tuning category to process messages simultaneously in different queues.
    Transaction: SXMB_ADM
    Regards
    Holger

  • IP_IN_QUEUE : Multiple Consumers

    Hi,
    This might be more of a AQ question but just wanted to check if anyone has had the requirement to use the IP_IN_QUEUE as a topic rather than a queue. i.e. use multiple consumers with the same consumer name receiving the same message. Is it advisable to create a custom topic as the point of entry as opposed to using the built in queue to forward to a topic.
    regards,
    Narayanan

    Hi Narayanan,
    Actually, IP_IN_QUEUE and IP_OUT_QUEUE are topics instead of queues because they can have multiple consumer names. The Document Routing ID is used to set the consumer name when B2B enqueues to IP_IN_QUEUE.
    This sql statement is used to create the queue table.
    execute dbms_aqadm.create_queue_table (queue_table => 'B2B.IP_QTAB', queue_payload_type => 'B2B.IP_MESSAGE_TYPE', multiple_consumers => TRUE);
    Hope this helps,
    Eng

  • HT2688 Working on a single computer with multiple users, I have set things up to allow each user to view and listen to the others' music libraries under the "Shared Library" function.  Can you then connect an iPod touch and copy music from a shared librar

    Working on a single computer with multiple users, I have set things up to allow each user to view and listen to the others' music libraries under the "Shared Library" function.  Can you then connect an iPod touch and copy music from a shared library?

    Was your wife logged into the libray at the time you tried to log in? I have had a similar problem and it was because another user was logged into the library when I attempted to. I got the permission denied banner.

  • HP Photosmart all in one C309a printing multiple copies when its set to print only one copy.

    having issues with my C309a its now printing multiple copys when its set to print only one copy.it started doing this 4 days ago and its happening on both my Windows 7 64 bit computer and my Vista 32 computer that both have the latest release drivers already installed need help.HP please sort this issue out.still under warranty do i have to return it? 

    I am using a Motorola SBG900 Wirless Surfboard Gateway - supplied with Bigpond Cable. It is set to be using WPA security and have never had a problem with it before whilst connecting any wireless devices such as a laptop, PDA etc.
    My feeling is that the wireless functionality of this printer needs some serious work before the next release. And furthermore they should never have released it the way it is as it wouldn't pass 5% of user acceptance tests if using wireless. There are too many complaints on this forum and others about similar problems to suggest that I am not by myself here. Dissapointing considering this is the feature that would be at the top of the list of most purchasing this model. It lets down what could of been a vg printer.
    I agree, I think if I want to get this printer working on a wirless network, I will have to set the IP address manually. The problem is the printer refuses to connect to the router now even after it connected a few days ago with no intervention. I have powered down both the router, PC, and printer without any luck yet. I will set the IP address manually first on the printer and see how it goes, then if it connects will see if the PC/router can see the printer during the SW install procedure which has failed >10 times to date.
    For now I think I will stick with Ethernet as it is no doubt much faster anyway and will try the wirless setup again in a few days when my patience grows back. Does anyone know differences in speed between USB/Wireless/Ethernet? I know this is dependant on a number of things but just interested in ball park figures here.

  • Get/set message Queue ID in PI 7.1 Adapter module

    Hello,
    I have a special requirment to  get and set message Queue ID in PI 7.1 adapter module.
    I tried to use the method setConversationID  for the Message Class, but this doest seem to available any more.
    Any pointers to which class and method can be used.
    Thanks in advance
    Regards,
    Abhishek

    Hi, try [setSequenceId|http://help.sap.com/javadocs/pi/pi711sp03/com/sap/engine/interfaces/messaging/api/Message.html#setSequenceId(java.lang.String)]. Maybe you have to use setDeliverySemantics before in order to set EOIO.
    regards, Martin

  • Is QuickTime support Mp4 file with Multiple SPS(Sequence Paramter Set) ?

    Hello EveryOne.
    I am in much trouble... plz help me. Thanks
    I have a Mp4 file with Multiple SPS(Sequence Parameter Set) and PPS(Picture Parameter Set.
    When i play into latest QuickTime then only Audio come. Blank White screen come in case of Video..Means no Video..
    i want to ask :
    Is QuickTime support Multiple SPS Mp4 file ?
    Thanks
    Shakti Kapoor
      Windows 2000  

    You didn't answer probably the most important question: whether you're using hardware or software Mercury Playback Engine (MPE). However, since you've set Maximum Render Quality on, it's largely irrelevant.
    When you're using hardware MPE or have the MRQ flag set for your export, rendering is performed with linear color. Linear color processing affects how color channels and alpha channels are composited--anything less than 100% opacity is subject to linear color processing. Check out this article for more information on linear color/linear light: Linear Light - Artbeats
    Since it sounds like you're seeing the results you expect in the Program Monitor, but not export, I'll wager you're not using hardware MPE. Only by disabling the Maximum Render Quality flag on export will you be able to get results that match what you see in the Program Monitor (within reason, of course). The only way you could see the effects of linear color within Premiere would be to either use a qualified GPU that enables hardware MPE, or go into your Sequence Settings and check the "Maximum Render Quality" option and then render previews.
    Please let me know if that helps resolve the issue, or at least provide a little insight into the problem.

  • Different / multiple senders to the same EOIO queue name.

    Hello,
    I'd like to know if it is possible to send from different senders, different messages to different receivers but using always same EOIO queue?
    Scenarios are:
    1) SOAP SENDER -> PI ->  SOAP RECEIVER A
    2) IDOC SENDER -> PI -> SOAP RECEIVER B
    3) PROXY ABAP -> SOAP RECEIVER C.
    All messages need to be processed by receivers in the same order they were sent from the different senders.
    How this scenario should be implemented?
    Thanks in advance.

    Hi Michal. Thanks for response!
    As far as I know,
    1- Proxy Sender adds a prefix by defaul. Is it posible to change this behaviour?
    2- By Following note 856597, I understand that you can set your own queue name in parameter &QueueId=xxxxxxxxxxxxxxxx. So there should be no problem.
    3- In Idoc Adapter, you can set a queue name by using a Function Module, but I dont know whether this adds or not a prefix. Will it add a prefix to the queue name?
    So, in case I want to use for all this adapters the same queue, then I need to set in the Soap queueId param, and in the Idoc function module, the same queue name that is generated automatically in Proxy Sender (since this is fixed queue name based on Prefix + custom queue suffix).
    4-  Is that true? Can I guarantee that from IDOC I can use same queue as used by Proxy and IDOC won't add a prefix?
    Thanks again.

  • Delivery quantities only in multiples for a particular set of customers

    Hi all,
    I'm having a requirement and want to know is there any way to solve it by configuration:
    I have to deliver the products in multiples of 5.i have activated this in the material master and it functions properly and issues a warning message when i change the quantity while picking in delivery so  i have converted this message into ERROR message but my problem is i have to activate it only for a particular set of customers..is there any way to achieve it ..i have tried it by tick mark   "switching off rounding" in customer master but this error message is still there for these customers also .
    Can I  acitvate the delivery quantities only in multiples of a particular set of customers..?

    Hi all,
    I have gone through your suggestions but it didn't help me a lot..I am able to trigger rounding profile for a particular set of customers but this thing  can be achieved only in sales Order , i am unable to do this at Delivery level, at delivery level system is allowing me to change the quantity irrespective of the rounding profile.
    Can anyone suggest me how to achieve this at delivery level.
    I have gone through Logistics - General>Control for Quantity Optimizing>Assign Control Profiles
    here also , application for triggering of control profile is given only for sales order.
    plz help.

  • Multiple consumers of the same Queue

    In the past my use of JMS queues has been limited to a single message producer and a single consumer. I am now looking at having multiple copies of the same consumer running for load balancing and failover purposes, and this leads me to what I think is a basic question. BTW, we're running OpenMQ 4.4u1.
    I have messages being produced and saved in a single queue.
    I then have a consumer program whose logic is something like this:
    1. Create session with no transaction and CLIENT_ACKNOWLEDGE.
    2. Receive message from queue.
    3. Do some processing with message. Repeat processing attempts multiple times, if needed, until successful.
    4. Once processing is successful, acknowledge message.
    Assume that I am running multiple copies of the consumer in separate JVMs (or on separate servers, for that matter).
    Here are my related questions.
    1. If step 3 takes a long time (e.g., several minutes) can I be sure that only one instance of the consumer will receive the message?
    2. If a consumer is in step 3 and a catastrophic failure occurs (e.g., the JVM or server it is running on crashes) the message will never be acknowledged, but the session will not be shut down in an orderly fashion, either. Will the message that was received but never acknowledged eventually be delivered to another copy of the consumer?
    3. If step three takes a very long time (hours or days, rather than minutes), will the broker misinterpret this as a failure of the consumer and deliver the same message to another one of the consumers?
    Thank you for reading and/or responding to this question.
    Bill

    1. If step 3 takes a long time (e.g., several minutes) can I be sure that only one instance of the consumer will receive the message?A queue message will only be delivered and consumed by 1 consumer.
    2. If a consumer is in step 3 and a catastrophic failure occurs (e.g., the JVM or server it is running on crashes) the message will never be acknowledged, but the session will not be shut down in an orderly fashion, either. Will the message that was received but never acknowledged eventually be delivered to another copy of the consumer?Yes.
    3. If step three takes a very long time (hours or days, rather than minutes), will the broker misinterpret this as a failure of the consumer and deliver the same message to another one of the consumers?No, as long as the consumer's Session or Connection are intact

  • Queue: one producer vs multiple consumers

    Hi,
    This may be a simple question. In my application, I have a master/multiple slaves queue architecture. So the master enqueues messages. Each message is adressed to only one slave. Since all the slaves are waiting after queue elements, they all should receive the message and all dismiss it but one, the destinator. Apparently, it is not working like that. Once the message is dequeued by a slave, it is no more available in the queue and the others are not notified. Is that right?
    I could use a seperate queue for each slave, but when it comes to be 100 slaves, I find it a but heavy to manage hundred queues. I tried instead to do a router-like architecture. Everyone is listening and for each message they all verify who is the destinator. Only the destinator processes the message and the other ones simply dismiss it. Is there a way for me to implement that?
    Joe

    It actually sounds like a fairly dicey problem, depending on your need for response times and total messaging bandwidth.  Many of the issues seem to revolve around multiple producers and consumers wanting simultaneous read and write access to a continuously changing entity.  At least that's how it sounded to me, that all the consumers are independent and should be allowed to consume their own messages just as soon as they're able to notice them.
    For example:
    Consumer #3 performs a preview and discovers that there's a message waiting at position #9.  In order to pull it out of the queue, it must first dequeue the first 8 messages in line.  Then after dequeueing its own message, it must re-enqueue those 1st 8 messages, this time using "Enqueue at Opposite End" to restore the original sequence.
    However, before it can finish re-enqueue'ing those 8, Consumer #11 performs a preview and discovers that there's a message at (apparent) position 4.  This really *should* be position 12, but how can Consumer #11 know what #3 is in the middle of?
    Meanwhile, one of Consumer #3's 8 messages is addressed to Consumer #11, and it's actually quite important that Consumer #11 gets this one first instead of the one that it just found for itself
    And so on...
    Now, some (most?  all?)  of this kind of conflict can be resolved through the use of semaphores, but the penalty is that whenever any Consumer is accessing the shared queue, 100's of other Consumers are stuck waiting their turn.  And so all the independence and parallelism you were after in the first place with the producer / consumer pattern starts slipping away...
    I haven't personally built an app around a massively parallel messaging architecture.  I hope someone who has gets involved here because I'd like to learn how it's done.  I'd wager there are a few different elegant solutions, but all I can manage to think of are the pitfalls.
    -Kevin P.

  • Jms queue multiple consumers

    Hi,
    I am new to the JMS queue concept. I have two BPEL processes each having JMS adapter for consuming the data from the same queue. How do i differentiate which consumer consumes which data that is put into the queue. Is there any field in the queue that decides which consumer has to consume the message.
    Just to add to above query, if the message goes to all the consumers, is there any way that i put some logic there to let only the eligible consumer actually process that message.
    It would be helpful if i get any documentation on this.
    Thanks in advance for the Help!
    Edited by: Marius J on Jun 2, 2009 7:38 AM

    Thanks Sahil and JDT. Thanks for the response.
    Sahil,
    I was able to proceed the way u specified. I am using AQ. How do i send the corrid while enqueuing the data in the queue. I am using the following command to enqueue the data.
    CONNECT aq_user/aq_user@tsh9i
    DECLARE
    l_enqueue_options     DBMS_AQ.enqueue_options_t;
    l_message_properties  DBMS_AQ.message_properties_t;
    l_message_handle      RAW(16);
    l_event_msg           AQ_ADMIN.event_msg_type;
    BEGIN
    l_event_msg := AQ_ADMIN.event_msg_type('REPORTER', 1, 2);
    DBMS_AQ.enqueue(queue_name          => 'aq_admin.event_queue',
    enqueue_options     => l_enqueue_options,
    message_properties  => l_message_properties,
    payload             => l_event_msg,
    msgid               => l_message_handle);
    COMMIT;
    END
    But, as per your inputs, we need to send corrid in order to meet my requirement. Can u please guide me regarding this.
    Thanks again
    Regards,
    MJ
    Edited by: Marius J on Jun 4, 2009 7:39 AM

  • Multiple consumers for AQ-Adpater

    Hi,
    I want to use a generic queue that will be used by multiple BPEL process. Is there was to specify the channel rule OR AQ-adapter rule so that a content based routing can be done to specific BPEL processes. What are the different options that Adapters provide to achieve this? Is there a concept of dead letter channel/queue for the messages not satisfying any rules?
    Thanks,.
    Anil

    Thanks for info. Where do I set the property or the header variable for a JMS message in an adapter ?
    Should I set it using the adapter tab in invoke OR use the property tab in the adapter partnerlink when sending out the message?
    I have set the following in the invoke before producing the message and dropping on the queue
    <invoke name="Invoke_1" partnerLink="adapt"
    portType="ns1:Produce_Message_ptt"
    operation="Produce_Message"
    inputVariable="Invoke_1_Produce_Message_InputVariable"
    bpelx:inputHeaderVariable="Sender"/>
    On the receive side I have the message selector configured for the adapter as follows:
    <jca:operation
    ActivationSpec="oracle.tip.adapter.jms.inbound.JmsConsumeActivationSpec"
    DestinationName="dattjndi"
    UseMessageListener="false"
    MessageSelector="Sender=AdaptationRequest"
    PayloadType="TextMessage"
    OpaqueSchema="false" >
    </jca:operation>
    Where AdaptationRequest is the value for the Sender variable which will be used to filter the message. But this does not work. the messages are still not consumed. What could be the problem?
    Thanks,
    Anil

  • Conditionally sending messages to multiple consumers

    How would I best accomplish this requirement?
    I have one system which produces messages
    Multiple systems may want to consume those messages
    I want the producer to be able to send messages conditionally
    In one instance perhaps I send same message to each consumer
    However in another case maybe I only want to send a message to consumers A and B
    It would be OK if I could flag certain messages to be for certain consumers, and then those consumers only retrieve those messages designated to them. However I dont think this is possible as any such flag the consumer would have to read once it actually consumes the message and reads it, I dont think there is any way for the queue to make that decision for them.
    So it sounds like what I need is a hybrid of point-to-point and publish-subscribe
    I want a universal way to conditionally send messages to one or more consumers, and the conditions are dynamic.
    Any suggestions?
    Must it be a PTP with separate queue for every application?

    lozina wrote:
    Interesting... message filters. I like it.
    So with this approach, I can send some messages to everyone, and other messages I can have tailored to specific subscribers?pretty much.
    But the subscriber does not actually have to "fetch" each message to determine if the message is meant for him or not, right? When using message filters this act at the queue, not at the client? Basically I want to avoid a client downloading 1,000 messages only to find out none of them are for him. unfortunately, that's probably up to the implementation. the implementation may choose to work that way (download every message and check it), or it may have a way of applying the filter at the server. however, the filters work only on the message properties, so the impl may be able to just get message headers and filter w/out getting the entire message. you'll have to test with the jms impl you are planning on using and see how that works.
    Thanks!
    [Edit] these are called Message Selectors right? yes.
    And looks like they are specified at the time the client looks up the queue in JNDI?yes, these are provided at subscription time.
    Now is this limited to publish-subscribe?no you can use selectors when subscribing to a queue as well. but, queues won't scale very well to lots of consumers (and are hard to manage with dynamic numbers of consumers).

Maybe you are looking for

  • How can I stop streaming of a sound?

    Hello, after asking in another Forum without getting an answer, I'm now posting here: I have a Sound var and some buttons (mc's with eventhandlers) on the stage. I have an array including URLs of some mp3 files. For every mp3 there is one button. Whe

  • Using a characteristic value from an infoCube as a variable in a query

    Hi gurus! I have a query based on an infoCube where I make a restricted key figure. I restrict the key figure by selecting a specific month using 0calmonth. I need to create a variable that represents a specific month which will change every year. I

  • Port forwarding for external access to VNC server on multiple machines

    I will have 10 PCs connected to the WRT54GL wireless AP. I am testing with 1. It has a static addresses 10.155.22.51. It is running a VNC server at port 5951. If I  set my VNC client up to access 10.155.22.51:5951 it works through the WRT54GL wireles

  • Imported songs in strange order

    Imported songs are not in the correct order in iTunes. I've tried changing the order of the song names but it only reverses the order. The strange thing is after updating into my ipod the order is the same as the cd on my ipod but iTunes still has th

  • SuperDrive not working post Mt Lion upgrade

    My SuperDrive was working flawlessly on my 2010 Mini. I upgraded from Snow direct to Mt Lion and SuperDrive now only reads CDs I previously burned but not DVDs I burned. The discs I burned are back ups of photos so I can't speak to sound files, etc.