You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by pu...@gmail.com on 2011/03/05 22:24:17 UTC

catch resource exceptions in producer?

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):

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

Re: catch resource exceptions in producer?

Posted by Matt Paul <pu...@gmail.com>.
Gordon,

nevermind, thanks for the help! The person testing your suggestions was
incorrect, I checked it myself and they work correctly, I apologize for the
mixup!

Matt

On Mon, Mar 7, 2011 at 11:27 AM, Gordon Sim <gs...@redhat.com> wrote:

> On 03/07/2011 04:56 PM, Matt Paul wrote:
>
>> Gordon,
>>
>> I tried the suggestions below, and still getting the same thing (I can
>> even
>> see the errros getting printed out on the screen in the test app:
>>
>> 2011-03-07 10:53:08 warning Exception received from broker:
>> resource-limit-exceeded: resource-limit-exceeded: Policy exceeded on
>> msaq.direct, policy: size: max=512000000, current=511997882; count:
>> unlimited; type=reject (qpid/broker/QueuePolicy.cpp:86) [caused by 1
>> \x00:\x00]
>>
>
> Hmm... the attached simplified test works as expected for me
> (ResourceLimitExceededException gets caught as expected).
>
> Does this work for you (you may need to alter the queue or configure up a
> new one)? Or can you create a simple reproducer where the exception is not
> thrown correctly? Is it intermittent or 100% failing for you?
>
>
>
>> Here's the producer code snippet now:
>>
>>       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);
>>          sync(session).messageTransfer(arg::content=m,
>> arg::destination=exchange);
>>          session.sync();
>>          conn.close();
>>          break;
>>       }
>>       catch (const qpid::framing::NotFoundException&)
>>       {
>>          ++retryCount;
>>          pthread_sleep(5);
>>          continue;
>>       }
>>       catch (const qpid::framing::ResourceLimitExceededException&rex)
>>       {
>>          std::string error = rex.what();
>>          conn.close();
>>          TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
>>          LEAVE;
>>          return -1;
>>       }
>>       catch (const 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;
>>       }
>>
>> I realize the sync after the sync call is probably redundant, but I'm kind
>> grasping at straws as to why I'm not catching the exception (especially
>> since I can see the screen output of the actual error)
>>
>> Matt
>>
>>
>> On Mon, Mar 7, 2011 at 9:24 AM, Gordon Sim<gs...@redhat.com>  wrote:
>>
>>  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<gs...@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
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>

Re: catch resource exceptions in producer?

Posted by Gordon Sim <gs...@redhat.com>.
On 03/07/2011 04:56 PM, Matt Paul wrote:
> Gordon,
>
> I tried the suggestions below, and still getting the same thing (I can even
> see the errros getting printed out on the screen in the test app:
>
> 2011-03-07 10:53:08 warning Exception received from broker:
> resource-limit-exceeded: resource-limit-exceeded: Policy exceeded on
> msaq.direct, policy: size: max=512000000, current=511997882; count:
> unlimited; type=reject (qpid/broker/QueuePolicy.cpp:86) [caused by 1
> \x00:\x00]

Hmm... the attached simplified test works as expected for me 
(ResourceLimitExceededException gets caught as expected).

Does this work for you (you may need to alter the queue or configure up 
a new one)? Or can you create a simple reproducer where the exception is 
not thrown correctly? Is it intermittent or 100% failing for you?

>
> Here's the producer code snippet now:
>
>        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);
>           sync(session).messageTransfer(arg::content=m,
> arg::destination=exchange);
>           session.sync();
>           conn.close();
>           break;
>        }
>        catch (const qpid::framing::NotFoundException&)
>        {
>           ++retryCount;
>           pthread_sleep(5);
>           continue;
>        }
>        catch (const qpid::framing::ResourceLimitExceededException&rex)
>        {
>           std::string error = rex.what();
>           conn.close();
>           TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
>           LEAVE;
>           return -1;
>        }
>        catch (const 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;
>        }
>
> I realize the sync after the sync call is probably redundant, but I'm kind
> grasping at straws as to why I'm not catching the exception (especially
> since I can see the screen output of the actual error)
>
> Matt
>
>
> On Mon, Mar 7, 2011 at 9:24 AM, Gordon Sim<gs...@redhat.com>  wrote:
>
>> 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<gs...@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
>>
>>
>


Re: catch resource exceptions in producer?

Posted by Matt Paul <pu...@gmail.com>.
Gordon,

I tried the suggestions below, and still getting the same thing (I can even
see the errros getting printed out on the screen in the test app:

2011-03-07 10:53:08 warning Exception received from broker:
resource-limit-exceeded: resource-limit-exceeded: Policy exceeded on
msaq.direct, policy: size: max=512000000, current=511997882; count:
unlimited; type=reject (qpid/broker/QueuePolicy.cpp:86) [caused by 1
\x00:\x00]

Here's the producer code snippet now:

      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);
         sync(session).messageTransfer(arg::content=m,
arg::destination=exchange);
         session.sync();
         conn.close();
         break;
      }
      catch (const qpid::framing::NotFoundException &)
      {
         ++retryCount;
         pthread_sleep(5);
         continue;
      }
      catch (const qpid::framing::ResourceLimitExceededException &rex)
      {
         std::string error = rex.what();
         conn.close();
         TRACE(TRACE_ERROR,(void *) "Error: %s", error.c_str());
         LEAVE;
         return -1;
      }
      catch (const 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;
      }

I realize the sync after the sync call is probably redundant, but I'm kind
grasping at straws as to why I'm not catching the exception (especially
since I can see the screen output of the actual error)

Matt


On Mon, Mar 7, 2011 at 9:24 AM, Gordon Sim <gs...@redhat.com> wrote:

> 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<gs...@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
>
>

Re: catch resource exceptions in producer?

Posted by Gordon Sim <gs...@redhat.com>.
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<gs...@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


Re: catch resource exceptions in producer?

Posted by Matt Paul <pu...@gmail.com>.
Gordon,

Thanks for the info. Is there something similar in the client namespace?

Matt

On Mon, Mar 7, 2011 at 3:37 AM, Gordon Sim <gs...@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
>
>

Re: catch resource exceptions in producer?

Posted by Gordon Sim <gs...@redhat.com>.
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