activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Co <...@exist.com>
Subject Re: QueueBrowser acknowledge
Date Thu, 23 Nov 2006 20:11:47 GMT
Hi,

I don't think you can remove a message from a queue using a queue 
browser. You'd generally use a queue receiver for that.

zizou77 wrote:
> Hi,
>
> I use a queueBrowser with a selector in my program. So I get some Message.
> But when I use message's acknowledge method, messages are still in the
> queue. Why?
> I use Session.CLIENT_ACKNOWLEDGE, but i've got the same problem with
> Session.AUTO_ACKNOWLEDGE.
>
> This a part of my program:
>
>  public void run() {
>         ActiveMQConnectionFactory factory = new
> ActiveMQConnectionFactory(broker);
>
>         try {
>             QueueConnection connexion = factory.createQueueConnection();
>             connexion.start();
>             QueueSession session = connexion.createQueueSession(false,
> Session.CLIENT_ACKNOWLEDGE);
>             Queue groupMsgQueueReceiver = session.createQueue(queueIn);
>             QueueReceiver queueReceiver =
> session.createReceiver(groupMsgQueueReceiver);
>             Queue groupMsgQueueSender = session.createQueue(queueOut);
>             QueueSender queueSender =
> session.createSender(groupMsgQueueSender);
>         } catch (JMSException e) {
>             e.printStackTrace();
>         }
>     }
>
> //lookForGroupDocuments is a method started by a job scheduler quartz
>  private void lookForGroupDocuments()
>     {
>
>       QueueBrowser queueBrowser = session.createBrowser(queue, selector);
>       Enumeration enumeration;
>       List<Message> messageDocumentsList = new ArrayList();
>       enumeration = queueBrowser.getEnumeration();
>       while (enumeration.hasMoreElements()) {
>             Message message = (Message) enumeration.nextElement();
>             messageDocumentsList.add(message);
>        }
>           
> ........
>
> then i do:
>
> for (int i = 0; i < messageDocumentsList.size(); i++) {
>        messageDocumentsList.get(i).acknowledge();
> }
>
>   


Mime
View raw message