activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Posta <christian.po...@gmail.com>
Subject Re: trying to consume (remove) a message
Date Tue, 16 Jul 2013 20:25:35 GMT
Just tried test case on 5.7.0, works fine.
Maybe you can check your JMX console and see whether the broker is
dispatching, eg, can you see the "inflight" count go up correctly?

You could also try setting prefetch to 0 on your consumer to force the
consumer to pull a message. That's probably not the solution you want, but
it would be good to know whether the broker doesn't think it's there or
whether it just hasn't sent it to be prefetched on the consumer yet.


On Tue, Jul 16, 2013 at 4:11 PM, Leonardo K. Shikida <shikida@gmail.com>wrote:

> core jar manifest says 5.7.0
>
> []
>
> Leo
>
>
> On Tue, Jul 16, 2013 at 5:06 PM, Christian Posta
> <christian.posta@gmail.com> wrote:
> > Trunk.
> >
> > What version is in tomEE 1.5.2?
> >
> >
> > On Tue, Jul 16, 2013 at 3:56 PM, Leonardo K. Shikida <shikida@gmail.com
> >wrote:
> >
> >> I am using activemq from tomEE 1.5.2
> >>
> >> probably not the latest
> >>
> >> what version are you using?
> >>
> >> []
> >>
> >> Leo
> >>
> >>
> >> On Tue, Jul 16, 2013 at 4:51 PM, Christian Posta
> >> <christian.posta@gmail.com> wrote:
> >> > This unit test works:
> >> >
> >> >
> >> >     @Test
> >> >     public void remove() throws JMSException, InterruptedException {
> >> >
> >> >         boolean messageConsumed = false;
> >> >
> >> >         Connection connection = null;
> >> >         Session session = null;
> >> >         try {
> >> >             ConnectionFactory connectionFactory = new
> >> > ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
> >> >             connection = connectionFactory.createConnection();
> >> >             connection.start();
> >> >
> >> >             session = connection.createSession(false,
> >> > Session.AUTO_ACKNOWLEDGE);
> >> >             Queue queue = session.createQueue("FOO");
> >> >             MessageProducer producer = session.createProducer(queue);
> >> >             for (int i = 0; i < 5; i++) {
> >> >                 producer.send(session.createTextMessage("Hi" + i));
> >> >             }
> >> >
> >> >
> >> >             QueueBrowser browser = session.createBrowser(queue);
> >> >             Enumeration<?> messagesInQueue = browser.getEnumeration();
> >> >             String jmsMessageID = "nan";
> >> >             while (messagesInQueue.hasMoreElements()) {
> >> >                 Message queueMessage = (Message)
> >> > messagesInQueue.nextElement();
> >> >                 System.out.println("Enqueued > " +
> >> > queueMessage.getJMSMessageID());
> >> >                 jmsMessageID = queueMessage.getJMSMessageID();
> >> >
> >> >             }
> >> >
> >> >             System.out.println("Trying to delete > " + jmsMessageID);
> >> >
> >> >
> >> >             MessageConsumer consumer =
> >> >                     session.createConsumer(queue, "JMSMessageID='" +
> >> > jmsMessageID + "'");
> >> >             Message message = null;
> >> >             while ((message = consumer.receive(500)) != null) {
> >> >                 System.out.println("Consumed > " + message);
> >> >             }
> >> >
> >> >         } finally {
> >> >             if (session != null)
> >> >                 session.close();
> >> >             if (connection != null)
> >> >                 connection.close();
> >> >         }
> >> >
> >> >     }
> >> >
> >> >
> >> > On Tue, Jul 16, 2013 at 3:41 PM, Leonardo K. Shikida <
> shikida@gmail.com
> >> >wrote:
> >> >
> >> >> Hi
> >> >>
> >> >> I've tried
> >> >>
> >> >> consumer.receive(1000)
> >> >>
> >> >> without success
> >> >>
> >> >> []
> >> >>
> >> >> Leo
> >> >>
> >> >>
> >> >> On Tue, Jul 16, 2013 at 4:25 PM, Christian Posta
> >> >> <christian.posta@gmail.com> wrote:
> >> >> > Try giving a brief moment between creating your consumers and
the
> >> call to
> >> >> > receiveNoWait():
> >> >> >
> >> >> >             MessageConsumer consumer =
> >> >> >                     session.createConsumer(queue, "JMSMessageID='"
> +
> >> >> > jmsMessageID + "'");
> >> >> >             Message message = null;
> >> >> >             Thread.sleep(500);
> >> >> >             while ((message = consumer.receiveNoWait()) != null)
{
> >> >> >                 System.out.println("Consumed > " + message);
> >> >> >             }
> >> >> >
> >> >> > Alternatively, use consumer.receive(500)
> >> >> >
> >> >> >
> >> >> > On Tue, Jul 16, 2013 at 11:10 AM, Leonardo K. Shikida <
> >> shikida@gmail.com
> >> >> >wrote:
> >> >> >
> >> >> >> Hi
> >> >> >>
> >> >> >> I am trying to remove (consume) a message from the queue,
without
> >> >> success.
> >> >> >>
> >> >> >> Here's my code and the output
> >> >> >>
> >> >> >> public boolean remove(String jmsMessageID) throws JMSException{
> >> >> >>
> >> >> >> boolean messageConsumed = false;
> >> >> >>
> >> >> >> Connection connection = null;
> >> >> >> Session session = null;
> >> >> >> try {
> >> >> >> ConnectionFactory connectionFactory =
> >> >> >> this.baseService.getConnectionFactory();
> >> >> >> connection = connectionFactory.createConnection();
> >> >> >> connection.start();
> >> >> >>
> >> >> >> // Create a Session
> >> >> >> session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> >> >> >>
> >> >> >> QueueBrowser browser =
> >> >> session.createBrowser(this.baseService.getQueue());
> >> >> >>    Enumeration<?> messagesInQueue = browser.getEnumeration();
> >> >> >>
> >> >> >>    while (messagesInQueue.hasMoreElements()) {
> >> >> >>     Message queueMessage = (Message)
> messagesInQueue.nextElement();
> >> >> >>     System.out.println("Enqueued >
> "+queueMessage.getJMSMessageID());
> >> >> >>    }
> >> >> >>
> >> >> >>    System.out.println("Trying to delete > "+jmsMessageID);
> >> >> >>
> >> >> >> Queue queue = this.baseService.getQueue();
> >> >> >> MessageConsumer consumer =
> >> >> >> session.createConsumer(queue,"JMSMessageID='"+jmsMessageID+"'");
> >> >> >> Message message = null;
> >> >> >> while((message = consumer.receiveNoWait()) != null){
> >> >> >> System.out.println("Consumed > "+message);
> >> >> >> messageConsumed = true;
> >> >> >> }
> >> >> >>
> >> >> >> } finally {
> >> >> >> if (session != null)
> >> >> >> session.close();
> >> >> >> if (connection != null)
> >> >> >> connection.close();
> >> >> >> }
> >> >> >>
> >> >> >> return messageConsumed;
> >> >> >> }
> >> >> >>
> >> >> >> >>>>>>>
> >> >> >>
> >> >> >> Enqueued          >
> >> >> >> ID:7612866413.mydomain.com-58510-1373986917055-5:1:35:1:1
> >> >> >> Enqueued          >
> >> >> >> ID:7612866413.mydomain.com-58510-1373986917055-5:1:61:1:1
> >> >> >> Enqueued          >
> >> >> >> ID:7612866413.mydomain.com-58510-1373986917055-5:1:63:1:1
> >> >> >> Trying to delete  >
> >> >> >> ID:7612866413.mydomain.com-58510-1373986917055-5:1:63:1:1
> >> >> >>
> >> >> >> (never enter into System.out.println("Consumed > "+message);)
> >> >> >>
> >> >> >> Am I missing something here?
> >> >> >>
> >> >> >> []
> >> >> >>
> >> >> >> Leo
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > *Christian Posta*
> >> >> > http://www.christianposta.com/blog
> >> >> > twitter: @christianposta
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > *Christian Posta*
> >> > http://www.christianposta.com/blog
> >> > twitter: @christianposta
> >>
> >
> >
> >
> > --
> > *Christian Posta*
> > http://www.christianposta.com/blog
> > twitter: @christianposta
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message