title: JMS Queue with 2 Listeners
body: <p>I have a question as regards JMS Queues.</p>
  
  <p>I have implemented a jms sender/reciever using a shared queue as its the only queue avaialbe to me and the only one i can use.  </p>
  
  <p>The problem that i am now faced with is that i as this first come first served i cannot guarentee that the messages that i am sending from my producer will be consumed by my consumer and not the other sharing this queue and vice versa. So i am consuming the other apps messages and they are consuming mine.</p>
  
  <p>Is there a way i can just listen for my messages and not consume them from the queue or is this more of a topic implementation? </p>
  
  <p>Or perhaps i can explicitly set an identifier that only my consumer will pick up.</p>
  
  <p>My main code:</p>
  
  <pre><code>public class AsyncReceiver implements MessageListener, ExceptionListener
  {
  public static void main(String[] args) throws Exception
  {                                                                          
      //create queue factory
          factory = new TibjmsQueueConnectionFactory(serverUrl);
          //create queue connection
          queueConn = factory.createQueueConnection(userName, password);
          queueConn.setExceptionListener(this);
          //create queue session
          session = queueConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  
          //receive message by QueueReceiver
          final Queue queue = session.createQueue(queueName);
          final QueueReceiver queueReceiver = session.createReceiver(queue);
          queueReceiver.setMessageListener(this);
          queueConn.start  ();                                                                      
    }
  </code></pre>