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 Fri, 24 Nov 2006 09:50:31 GMT
Maybe using a selector is a better alternative. This approach seems 
inefficient as you are receiving over the network all messages in the 
queue, and you are receiving them twice, even though you only need some 
of the messages.


zizou77 wrote:
> thanks,
>
> I resolved my problem with this:
>
>             Message receiverMsg;
>             for (int i = 0; i < msgList.size(); i++) {
>                 // I delete messages that I select by queueBrowser
>                 receiverMsg =
> groupMsgQueueManager.getQueueReceiver().receive();
>                 if
> (receiverMsg.getJMSMessageID().equals(msgList.get(i).getJMSMessageID())){
>                     receiverMsg.acknowledge();
>                 }
>             }
>
>
>
>
> Adrian Co wrote:
>   
>> 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