git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@424237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-07-21 09:00:35 +00:00
parent 4f131fdc26
commit 8dd454ed08
2 changed files with 90 additions and 64 deletions

View File

@ -127,6 +127,8 @@ namespace ActiveMQ
IMessage message = dispatcher.DequeueNoWait(); IMessage message = dispatcher.DequeueNoWait();
if (message != null) if (message != null)
{ {
//here we add the code that if do acknowledge action.
message = AutoAcknowledge(message);
Listener(message); Listener(message);
} }
else else

View File

@ -21,8 +21,7 @@ using System.Threading;
namespace NMS namespace NMS {
{
[ TestFixture ] [ TestFixture ]
public class AsyncConsumeTest : JMSTestSupport public class AsyncConsumeTest : JMSTestSupport
{ {
@ -59,7 +58,36 @@ namespace NMS
producer.Send(request); producer.Send(request);
WaitForMessageToArrive(); 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) protected void OnMessage(IMessage message)
@ -70,7 +98,6 @@ namespace NMS
received = true; received = true;
Monitor.PulseAll(semaphore); Monitor.PulseAll(semaphore);
} }
} }
protected void WaitForMessageToArrive() protected void WaitForMessageToArrive()
@ -84,8 +111,5 @@ namespace NMS
Assert.AreEqual(true, received, "Should have received a message by now!"); Assert.AreEqual(true, received, "Should have received a message by now!");
} }
} }
} }
} }