Author: tabish
Date: Mon Nov 23 19:17:51 2009
New Revision: 883469
URL: http://svn.apache.org/viewvc?rev=883469&view=rev
Log:
Fix an issue that would result with the same error as that seen in AMQ-2489
when clients ack messages in the async callback of a consumer.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?rev=883469&r1=883468&r2=883469&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
Mon Nov 23 19:17:51 2009
@@ -593,6 +593,23 @@
ackLater( message, ActiveMQConstants::ACK_TYPE_CONSUMED );
} else if( session->isClientAcknowledge() ||
session->isIndividualAcknowledge() ) {
ackLater( message, ActiveMQConstants::ACK_TYPE_DELIVERED );
+
+ bool messageUnackedByConsumer = false;
+
+ synchronized( &dispatchedMessages ) {
+ std::auto_ptr< Iterator< Pointer<MessageDispatch> > > iter(
this->dispatchedMessages.iterator() );
+ while( iter->hasNext() ) {
+ if( iter->next() == message ) {
+ messageUnackedByConsumer = true;
+ break;
+ }
+ }
+ }
+
+ if( messageUnackedByConsumer ) {
+ this->ackLater( message, ActiveMQConstants::ACK_TYPE_DELIVERED
);
+ }
+
} else {
throw IllegalStateException( __FILE__, __LINE__, "Invalid Session
State" );
}