You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Matthew Xie <an...@163.com> on 2006/07/19 04:45:57 UTC
Message recieved but can't removed from the amq server problem
Hi everyone.
I meet a trouble while i using amq .net to recieve message from amq server.
here i run the nunit test(AsyncConsumeTest.cs) from amq .net src code, i
find that the test runs successfully(message send and revieve successfully).
but while i monitor the amq server,unexpected i find that the message still
in amq server and then i run a consumer and message could be revieved again.
i just find that only this test use the asynchronous approach.
is anyone meet such problem?
i don't know how to solve it?
could someone do me a favor?
thanks!
Matt
--
View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5389938
Sent from the ActiveMQ - User forum at Nabble.com.
Re: Message recieved but can't removed from the amq server problem
Posted by Matthew Xie <an...@163.com>.
so i think you are preparing to fix it.
here i expect the new bug fixed version for openwire dotnet.
Thanks James!
Matt.
James.Strachan wrote:
>
> I wonder if there's a bug in the auto-ack code in the C# code so that
> the message is delivered but not actually acknowledged on the broker
> causing it to remain there?
>
> On 7/19/06, Matthew Xie <an...@163.com> wrote:
>>
>> Hi everyone.
>> I meet a trouble while i using amq .net to recieve message from amq
>> server.
>> here i run the nunit test(AsyncConsumeTest.cs) from amq .net src code, i
>> find that the test runs successfully(message send and revieve
>> successfully).
>> but while i monitor the amq server,unexpected i find that the message
>> still
>> in amq server and then i run a consumer and message could be revieved
>> again.
>>
>> i just find that only this test use the asynchronous approach.
>> is anyone meet such problem?
>> i don't know how to solve it?
>> could someone do me a favor?
>>
>> thanks!
>>
>> Matt
>> --
>> View this message in context:
>> http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5389938
>> Sent from the ActiveMQ - User forum at Nabble.com.
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
--
View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5407111
Sent from the ActiveMQ - User forum at Nabble.com.
Re: Message recieved but can't removed from the amq server problem
Posted by James Strachan <ja...@gmail.com>.
I wonder if there's a bug in the auto-ack code in the C# code so that
the message is delivered but not actually acknowledged on the broker
causing it to remain there?
On 7/19/06, Matthew Xie <an...@163.com> wrote:
>
> Hi everyone.
> I meet a trouble while i using amq .net to recieve message from amq server.
> here i run the nunit test(AsyncConsumeTest.cs) from amq .net src code, i
> find that the test runs successfully(message send and revieve successfully).
> but while i monitor the amq server,unexpected i find that the message still
> in amq server and then i run a consumer and message could be revieved again.
>
> i just find that only this test use the asynchronous approach.
> is anyone meet such problem?
> i don't know how to solve it?
> could someone do me a favor?
>
> thanks!
>
> Matt
> --
> View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5389938
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: Message recieved but can't removed from the amq server problem
Posted by James Strachan <ja...@gmail.com>.
Many thanks for the patch Matthew! I've commited it on trunk - I
wonder if you could please double check I've applied it correctly and
that it works for you now. All the tests worked for me locally.
On 7/21/06, Matthew Xie <an...@163.com> wrote:
>
> I think i found the problem why the message recieved but still live in mq
> server by asynchronous approach using AutoAcknowledge mode.
>
> here is changes in MessageConsumer.cs
>
> /// <summary>
> /// Dispatch any pending messages to the asynchronous listener
> /// </summary>
> public void DispatchAsyncMessages()
> {
> while (Listener != null)
> {
> IMessage message = dispatcher.DequeueNoWait();
> if (message != null)
> {
> //here we add the code that if do acknowledge action.
> message = AutoAcknowledge(message);
> Listener(message);
> }
> else
> {
> break;
> }
> }
> }
>
> Then rebuild the project and run the test. it should be works.
>
> Matt.
>
> --
> View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5429771
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: Message recieved but can't removed from the amq server problem
Posted by Matthew Xie <an...@163.com>.
I think i found the problem why the message recieved but still live in mq
server by asynchronous approach using AutoAcknowledge mode.
here is changes in MessageConsumer.cs
/// <summary>
/// Dispatch any pending messages to the asynchronous listener
/// </summary>
public void DispatchAsyncMessages()
{
while (Listener != null)
{
IMessage message = dispatcher.DequeueNoWait();
if (message != null)
{
//here we add the code that if do acknowledge action.
message = AutoAcknowledge(message);
Listener(message);
}
else
{
break;
}
}
}
Then rebuild the project and run the test. it should be works.
Matt.
--
View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5429771
Sent from the ActiveMQ - User forum at Nabble.com.
Re: Message recieved but can't removed from the amq server problem
Posted by Matthew Xie <an...@163.com>.
following is the my test code.
after run the test, a problem found that the message recieved successfully,
but while monitor the mq server that the this message still in the mq
server. if you run a simple consumer test, the message could be recieved
agian.
public class AsyncConsumer
{
IConnectionFactory factory;
protected object semaphore = new object();
protected bool received;
protected int receiveTimeout = 1000;
public AsyncConsumer()
{
Uri uri = new Uri("tcp://localhost:61616");
factory = new ConnectionFactory(uri);
}
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("Hello
World!");
request.NMSCorrelationID = "abc";
request.Properties["JMSXGroupID"] = "cheese";
request.Properties["myHeader"] = "James";
producer.Send(request);
WaitForMessageToArrive();
}
}
protected void OnMessage(IMessage message)
{
ActiveMQTextMessage textmessage = (ActiveMQTextMessage) message;
Console.WriteLine("Received message with ID: " +
textmessage.NMSMessageId);
Console.WriteLine("Received message with text: " +
textmessage.Text);
lock (semaphore)
{
received = true;
Monitor.PulseAll(semaphore);
}
}
protected void WaitForMessageToArrive()
{
lock (semaphore)
{
if (!received)
{
Monitor.Wait(semaphore, receiveTimeout);
}
}
}
}
--
View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5409632
Sent from the ActiveMQ - User forum at Nabble.com.
Re: Message recieved but can't removed from the amq server problem
Posted by James Strachan <ja...@gmail.com>.
To help us fix it, it would be a great help if someone could create an
NUnit test case that demonstrates the bug (and so fails).
e.g. send a message to a queue, create a consumer and consume it. Then
close the consumer, recreate it and check that the message is not
received again
On 7/19/06, Matthew Xie <an...@163.com> wrote:
>
> Hi everyone.
> I meet a trouble while i using amq .net to recieve message from amq server.
> here i run the nunit test(AsyncConsumeTest.cs) from amq .net src code, i
> find that the test runs successfully(message send and revieve successfully).
> but while i monitor the amq server,unexpected i find that the message still
> in amq server and then i run a consumer and message could be revieved again.
>
> i just find that only this test use the asynchronous approach.
> is anyone meet such problem?
> i don't know how to solve it?
> could someone do me a favor?
>
> thanks!
>
> Matt
> --
> View this message in context: http://www.nabble.com/Message-recieved-but-can%27t-removed-from-the-amq-server-problem-tf1964193.html#a5389938
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/