qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joseluis <jleah...@gmail.com>
Subject receptor out of scope with no calling receptor.close();
Date Tue, 04 Oct 2011 11:31:48 GMT
Hi,

With other program, I'm sending 1000 messages per second on exchante
testing/PRD1


In program bellow, I'm receiving those messages
The receptor gets out of scope and is created a new one per 1000 messages

If line  receptor.close(); is commented, the client program increase quickly
the cpu usage and memory

If line receptor.close(); is not commented, it works fine




#include &lt;qpid/messaging/Connection.h&gt;
#include &lt;qpid/messaging/Message.h&gt;
#include &lt;qpid/messaging/Receiver.h&gt;
#include &lt;qpid/messaging/Sender.h&gt;
#include &lt;qpid/messaging/Session.h&gt;

#include <iostream>



using namespace qpid::messaging;

int main(int /*argc*/, char** /*argv*/) {
    std::string broker = "127.0.0.1:5672";

    Connection connection(broker, "");
    try {
        connection.open();

        Session session = connection.createSession();

        std::string  address =
                "testing/PRD1; "
                "{ "
                "  assert: allways, "
                //"  create: never, "
                "  node : "
                "  { "
                "    type: topic "
                "  }, "
                "  link: "
                "  { "
                "    durable: false, "
                "    x-declare: "
                "    { "
                "      auto-delete: true, "
                "      exclusive: True, "
                "      arguments: "
                "      { "
                "        'qpid.max_count': 1000, "
                "        'qpid.max_size': 1000000, "        //  in bytes
                "        'qpid.policy_type': ring "
                "      } "
                "    } "
                "  } "
                "} ";


        int messages_received=1;
        while(true)
        {
            {   //  begin receiver scope. Create receiver on reduced scope
                Receiver receiver = session.createReceiver(address);
                receiver.setCapacity(100);
                while(messages_received % 1000 != 0)       //  every 1000
messages we will destroy and create a new receiver
                {
                    if(messages_received % 1000)
                    {
                        receiver.fetch(Duration::SECOND*1);
                        ++messages_received;
                        if(messages_received % 100 == 0)
                            std::cout << (messages_received/100)%10 <<
std::flush;
                    }
                }
                receiver.close();       //  if commented, the program
increase cpu and memory
            }   //  end receiver scope, it will create a new receiver
instance
            std::cout << std::endl << "receiver out of scope, creating a new
one with same configuration" << std::endl;
            ++messages_received;
        }

    } catch(const std::exception& error) {
        std::cerr << error.what() << std::endl;
        connection.close();
        return 1;
    }
}


kind regards

--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/receptor-out-of-scope-with-no-calling-receptor-close-tp6858408p6858408.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message