mirror of https://github.com/apache/activemq.git
added patch from Matthew Xie. For background see: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5429771
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@424237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4f131fdc26
commit
8dd454ed08
|
@ -127,6 +127,8 @@ namespace ActiveMQ
|
|||
IMessage message = dispatcher.DequeueNoWait();
|
||||
if (message != null)
|
||||
{
|
||||
//here we add the code that if do acknowledge action.
|
||||
message = AutoAcknowledge(message);
|
||||
Listener(message);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -21,8 +21,7 @@ using System.Threading;
|
|||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
namespace NMS {
|
||||
[ TestFixture ]
|
||||
public class AsyncConsumeTest : JMSTestSupport
|
||||
{
|
||||
|
@ -59,7 +58,36 @@ namespace NMS
|
|||
producer.Send(request);
|
||||
|
||||
WaitForMessageToArrive();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public void textMessageSRExample()
|
||||
{
|
||||
using (IConnection connection = Factory.CreateConnection())
|
||||
{
|
||||
AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
|
||||
ISession session = connection.CreateSession(acknowledgementMode);
|
||||
|
||||
IDestination destination = session.GetQueue("FOO.BAR");
|
||||
|
||||
// lets create a consumer and producer
|
||||
IMessageConsumer consumer = session.CreateConsumer(destination);
|
||||
consumer.Listener += new MessageListener(OnMessage);
|
||||
|
||||
IMessageProducer producer = session.CreateProducer(destination);
|
||||
producer.Persistent = true;
|
||||
|
||||
// lets send a message
|
||||
ITextMessage request = session.CreateTextMessage(
|
||||
"HelloWorld!");
|
||||
request.NMSCorrelationID = "abc";
|
||||
request.Properties["JMSXGroupID"] = "cheese";
|
||||
request.Properties["myHeader"] = "James";
|
||||
|
||||
producer.Send(request);
|
||||
|
||||
WaitForMessageToArrive();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnMessage(IMessage message)
|
||||
|
@ -70,7 +98,6 @@ namespace NMS
|
|||
received = true;
|
||||
Monitor.PulseAll(semaphore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void WaitForMessageToArrive()
|
||||
|
@ -84,8 +111,5 @@ namespace NMS
|
|||
Assert.AreEqual(true, received, "Should have received a message by now!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue