activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xbhanu <xbh...@gmail.com>
Subject Re: Problems with the AMQP python messenger API
Date Thu, 12 Dec 2013 13:33:45 GMT
Yes, and infact i am doing exactly this. But the accept call has no effect
it seems.


    messenger = Messenger()
    messenger.start()

   messenger.subscribe(address)

    message = Message()

    while should_run:
        messenger.recv()
        while messenger.incoming:
            try:
                messenger.get(message)
                messenger.accept()
            except Exception, e:
                print "Exception occurred while retrieving the message: " +
e
            else:
                print "Destination: " + message.address + "\n" + \
                    "Properties: " + str(message.properties) + "\n" + \
                    "Body: " + str(message.body) + "\n"

   messenger.stop()

Output for the first time:

Destination: queue://test_accept.0
Properties: None
Body:
TestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestData

Destination: queue://test_accept.0
Properties: None
Body:
TestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestData

Destination: queue://test_accept.0
Properties: None
Body: SHUTDOWN

Output if I run the consumer again:
Destination: queue://test_accept.0
Properties: None
Body:

Destination: queue://test_accept.0
Properties: None
Body:

Destination: queue://test_accept.0
Properties: None
Body:

Thanks,
Bhanu



On Thu, Dec 12, 2013 at 6:38 PM, ceposta [via ActiveMQ] <
ml-node+s2283324n4675454h3@n4.nabble.com> wrote:

> Something like this..
>
>  44 msg = Message()
>  45 while True:
>  46   mng.recv()
>  47   while mng.incoming:
>  48     try:
>  49       mng.get(msg)
>  50       mng.accept()
>  51     except Exception, e:
>  52       print e
>  53     else:
>  54       print msg.address, msg.subject or "(no subject)",
> msg.properties, msg.body
>
> On Thu, Dec 12, 2013 at 5:58 AM, Christian Posta
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=4675454&i=0>>
> wrote:
>
> > That's right. You have to ack the message. Maybe you can post your
> consumer
> > python script?
> >
> >
> > On Thursday, December 12, 2013, xbhanu wrote:
> >>
> >> Hi,
> >>
> >> I am using AMQP Messenger API in Python and I am getting duplicate
> >> messages
> >> while using queues. Even though my consumer receives the message,
> ActiveMQ
> >> does not increment the dequeue count (seen through Jconsole). As a
> result,
> >> whenever I connect back the consumer I end up getting the same messages
> >> again and again. So a message once enqueued is received every time
> again.
> >> The other interesting thing here is I am printing the body of the
> message
> >> (a
> >> simple string), the body gets printed only the first time.
> >>
> >> Anybody, any idea on how to tell ActiveMQ that I have received the
> message
> >> !! Some sort of acknowledgement ?? I do not see any way of acking in
> the
> >> messenger API !!
> >>
> >> Thanks,
> >> Bhanu
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://activemq.2283324.n4.nabble.com/Problems-with-the-AMQP-python-messenger-API-tp4675451.html
> >> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
> >
> > --
> > Christian Posta
> > http://www.christianposta.com/blog
> > twitter: @christianposta
> >
>
>
>
> --
> Christian Posta
> http://www.christianposta.com/blog
> twitter: @christianposta
>  http://www.christianposta.com/blog
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://activemq.2283324.n4.nabble.com/Problems-with-the-AMQP-python-messenger-API-tp4675451p4675454.html
>  To unsubscribe from Problems with the AMQP python messenger API, click
> here<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675451&code=eGJoYW51QGdtYWlsLmNvbXw0Njc1NDUxfC04NDE4NTMxMTk=>
> .
> NAML<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Bhanu Choudhary
Senior Member Technical,
D E Shaw India Software Ltd.
Hyderabad.




--
View this message in context: http://activemq.2283324.n4.nabble.com/Problems-with-the-AMQP-python-messenger-API-tp4675451p4675456.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message