You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by vijayaratha <ra...@wso2.com> on 2011/07/13 07:31:34 UTC

Messages are repetedly sends by the queue..

Hi,
I have an issue with activemq 5.4.2 version..
where QueueBrowser.getEnumeration().next element() retrieves same messages..
any idea on this?
this was working in 5.3.2. I version
       
any help regarding this would be helpful..

Thanks
-ratha..

This is my code segment;


   try{
            con = getReadConnection();
            session = JMSUtil.createSession(con,jmsSpec11);
            Destination destination = getDestination(session);

            browser = session.createBrowser((Queue) destination);
            Enumeration enumeration = browser.getEnumeration();

            if (enumeration.hasMoreElements()) {
                Object msg = enumeration.nextElement();

                JMSPersistentMessage jmsMeg = (JMSPersistentMessage)
((ObjectMessage) msg).getObject();
                messageContext =
jmsPersistentMessageHelper.createMessageContext(jmsMeg);
            }

        } catch (JMSException e) {
            log.error("JMS error while retrieving messages from the store: "
+ name, e);
            error = true;
            throw new SynapseException("JMS Message Store Exception " + e);
        } finally {
            cleanupJMSResources(con, session, browser, error,
ConnectionType.READ_CONNECTION);
        } 

--
View this message in context: http://activemq.2283324.n4.nabble.com/Messages-are-repetedly-sends-by-the-queue-tp3664255p3664255.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Messages are repetedly sends by the queue..

Posted by vijayaratha <ra...@wso2.com>.
Sorry for the wrong message..

What is actually happened is, i was polling the queue while browsing...
So i get same message again and again in the browser...

Error code;

 browser = session.createBrowser((Queue) destination);
 Enumeration enumeration = browser.getEnumeration();
      
  if (enumeration.hasMoreElements()) {
     	Object msg = enumeration.nextElement(); 
//code         
       }


After iterating part added i see all messages processed via the browser,
      
  if (enumeration.hasMoreElements()) {
     	Object msg = enumeration.nextElement(); 

/** this while block solved the issue***/
                   while (enumeration.hasMoreElements()) {
                	Object msg2 = enumeration.nextElement();                
<-------this msg2 object is not used by the later part of coding..extra
object..??
                }
             //code         
       }

I don't know how that while block solved the issue, which occurred with
polling the queue...
Any idea on this?

Or better solution for this?

Thanks
-ratha..


--
View this message in context: http://activemq.2283324.n4.nabble.com/Messages-are-repetedly-sends-by-the-queue-tp3664255p3665725.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Messages are repetedly sends by the queue..

Posted by Dejan Bosanac <de...@nighttale.net>.
Can you create a test case that reproduces it?

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Wed, Jul 13, 2011 at 7:31 AM, vijayaratha <ra...@wso2.com> wrote:

> Hi,
> I have an issue with activemq 5.4.2 version..
> where QueueBrowser.getEnumeration().next element() retrieves same
> messages..
> any idea on this?
> this was working in 5.3.2. I version
>
> any help regarding this would be helpful..
>
> Thanks
> -ratha..
>
> This is my code segment;
>
>
>   try{
>            con = getReadConnection();
>            session = JMSUtil.createSession(con,jmsSpec11);
>            Destination destination = getDestination(session);
>
>            browser = session.createBrowser((Queue) destination);
>            Enumeration enumeration = browser.getEnumeration();
>
>            if (enumeration.hasMoreElements()) {
>                Object msg = enumeration.nextElement();
>
>                JMSPersistentMessage jmsMeg = (JMSPersistentMessage)
> ((ObjectMessage) msg).getObject();
>                messageContext =
> jmsPersistentMessageHelper.createMessageContext(jmsMeg);
>            }
>
>        } catch (JMSException e) {
>            log.error("JMS error while retrieving messages from the store: "
> + name, e);
>            error = true;
>            throw new SynapseException("JMS Message Store Exception " + e);
>        } finally {
>            cleanupJMSResources(con, session, browser, error,
> ConnectionType.READ_CONNECTION);
>        }
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Messages-are-repetedly-sends-by-the-queue-tp3664255p3664255.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>