I'm having a bit of trouble while testing how resilient Rhino Queues is to
failures - most likely it is something I am doing wrong or not
understanding! Basically, I am intermittently receiving the same message
multiple times, even though it has previously been received within a
transaction.
Here is the code for a console application that I wrote just to play around:
using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Net;
> using System.Text;
> using System.Transactions;
>
> using Rhino.Queues;
>
> namespace Test
> {
> class Program : IDisposable
> {
> private static QueueManager receiver;
> private static QueueManager sender;
>
> static void Main(string[] args)
> {
> var receiver = new QueueManager(new
> IPEndPoint(IPAddress.Loopback, 4545), "receiver.esent");
> receiver.CreateQueues("test");
> receiver.Start();
>
> var sender = new QueueManager(new
> IPEndPoint(IPAddress.Loopback, 4546), "sender.esent");
> sender.Start();
>
> using (var tx = new TransactionScope())
> {
> sender.Send(new Uri("rhino.queues://localhost:4545/test"),
> new MessagePayload
> {
> Data = Encoding.ASCII.GetBytes("Test message")
> });
>
> tx.Complete();
> }
>
> while (true)
> {
> using (var tx = new TransactionScope())
> {
> try
> {
> var msg = receiver.Receive("test", new TimeSpan(0,
> 0, 5));
>
>
> Console.WriteLine(msg.Id.MessageIdentifier.ToString() + ": " +
> Encoding.ASCII.GetString(msg.Data));
>
> tx.Complete();
>
> Console.WriteLine("\tTX complete");
> }
> catch (TimeoutException)
> {
> Console.WriteLine("\tTimeout");
> break;
> }
> }
> Console.WriteLine("\tTX end");
> System.Diagnostics.Process.GetCurrentProcess().Kill();
> }
>
> Console.WriteLine("Press Enter to exit");
> Console.ReadLine();
> }
>
> public void Dispose()
> {
> if (sender != null)
> sender.Dispose();
>
> if (receiver != null)
> receiver.Dispose();
> }
> }
> }
>
First, I run it once, with the
System.Diagnostics.Process.GetCurrentProcess().Kill();
uncommented. Next I comment out the
System.Diagnostics.Process.GetCurrentProcess().Kill();
and run it again.
So, here is my understanding of what happened on the first run:
1. One message was sent, and was received within a transaction
2. That transaction completed sucessfully
3. The process terminated
And here is my understanding of what *should *happen on the second run:
1. One message is sent, and will be received within a transaction
2. Thre are no moe messages left to receive, so we will timeout and exit
gracefully
However, *sometimes *on the second run I am receiving both the new message,
*and *the message that I received on the previous run.
Is this the expected behaviour?
Thanks!
Colin
--
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rhino-tools-dev/-/Q4YMdLpCo60J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en.