qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject Re: catch resource exceptions in producer?
Date Mon, 07 Mar 2011 15:24:44 GMT
On 03/07/2011 03:09 PM, Matt Paul wrote:
> Gordon,
>
> Thanks for the info. Is there something similar in the client namespace?

Oops, my apologies! For some reason I ignored the fact that your code 
example doesn't use the qpid::messaging API...

In your code you should get the exception thrown on the session.sync() 
after the messageTransfer()[1]. You want to remove the 
session.executionSync() call, that is not necessary and may cause problems.

Try changing from 'qpid::framing::ResourceLimitExceededException& rex' 
to 'const qpid::framing::ResourceLimitExceededException& rex'.

[1] Note: you could do sync(session).messageTransfer(...) to make the 
transfer itself synchronous.

>
> Matt
>
> On Mon, Mar 7, 2011 at 3:37 AM, Gordon Sim<gsim@redhat.com>  wrote:
>
>> On 03/05/2011 09:24 PM, purplegherkin@gmail.com wrote:
>>
>>> Hi,
>>>
>>> I'ma relatively new qpid user, and I've run across an issue that I can't
>>>
>>> quite seem to figure out. we have our broker set to allow up to 51200000
>>> bytes of data (which I know is large), but when testing the actual
>>> limit, I'm getting the following printed to stderr in the producer (and
>>> it won't catch in a SessionException or any other exception):
>>>
>>
>> The exceptions thrown by the API in the qpid::messaging namespace are
>> defined in qpid/messaging/exceptions.h. The exception thrown in this case is
>> qpid::messaging::TargetCapacityExceeded.
>>
>> There is a connection level option - x-reconnect-on-limit-exceeded - that
>> controls whether the client library itself tries to handle this and it is
>> true by default. To handle it yourself you should set that option to false.
>>
>>
>>   2011-03-05 15:11:45 warning Exception received from broker:
>>> resource-limit-exceeded: resource-limit-exceeded: Policy exceeded on
>>> msaq.direct, policy: size: max=512000000, current=511998551; count:
>>> unlimited; type=reject (qpid/broker/QueuePolicy.cpp:86) [caused by 1
>>> \x00:\x00]
>>>
>>> Is there any way to catch this error? here's the producer side code:
>>>
>>> while (retryCount<  10)
>>> {
>>> Connection conn;
>>> try
>>> {
>>> if ((ip_addr)&&  (strlen(ip_addr)))
>>> conn.open(ip_addr,port);
>>> else
>>> conn.open("127.0.0.1",port);
>>> Session session = conn.newSession();
>>> session.sync();
>>>
>>> // create message
>>> Message m;
>>> m.getDeliveryProperties().setRoutingKey(MSAQ_ROUTING_KEY);
>>> m.getDeliveryProperties().setDeliveryMode(DELIVERY_MODE_PERSISTENT);
>>> m.setData(msgXml);
>>>
>>> // set the message id
>>> session.messageTransfer(arg::content=m, arg::destination=exchange);
>>> session.sync();
>>> session.executionSync(true);
>>> conn.close();
>>> break;
>>> }
>>> catch (const qpid::framing::NotFoundException&)
>>> {
>>> ++retryCount;
>>> pthread_sleep(5);
>>> continue;
>>> }
>>> catch (qpid::framing::ResourceLimitExceededException&rex)
>>> {
>>> std::string error = rex.what();
>>> conn.close();
>>> TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
>>> LEAVE;
>>> return -1;
>>> }
>>> catch (qpid::SessionException&sex)
>>> {
>>> std::string error = sex.what();
>>> conn.close();
>>> TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
>>> LEAVE;
>>> return -1;
>>> }
>>> catch (const std::exception&ex)
>>> {
>>> std::string error = ex.what();
>>> conn.close();
>>> TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
>>> LEAVE;
>>> return -1;
>>> }
>>>
>>> Any help at all would really be appreciated and thanks in advance,
>>>
>>> Matt Paul
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>


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


Mime
View raw message