Ayende @ Rahien

Hi!
My name is Ayende Rahien
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

@

Posts: 5,947 | Comments: 44,540

filter by tags archive

Raven MQ – The Real API


Originally posted at 11/17/2010

This is now a passing test…

public class UntypedMessages : IDisposable
{
    private readonly RavenMqServer ravenMqServer;
    private readonly RavenConfiguration configuration;

    public UntypedMessages()
    {
        configuration = new RavenConfiguration
        {
            RunInMemory = true,
            AnonymousUserAccessMode = AnonymousUserAccessMode.All
        };
        ravenMqServer = new RavenMqServer(configuration);
    }

    [Fact]
    public void Can_get_message_from_client_connection()
    {
        using(var connection = new RavenMQConnection(
            new Uri(configuration.ServerUrl), 
            new IPEndPoint(IPAddress.Loopback, 8181)))
        {
            var manualResetEventSlim = new ManualResetEventSlim(false);
            OutgoingMessage msg = null;
            connection.Subscribe("/queues/abc", (context, message) =>
            {
                msg = message;
                manualResetEventSlim.Set();
            });

            WaitForSubscription();

            ravenMqServer.Queues.Enqueue(new IncomingMessage
            {
                Data = new byte[] {1, 2, 3},
                Queue = "/queues/abc"
            });

            manualResetEventSlim.Wait();

            Assert.Equal(new byte[]{1,2,3}, msg.Data);
        }
    }

    private void WaitForSubscription()
    {
        // not important
    }

    public void Dispose()
    {
        ravenMqServer.Dispose();
    }
}

Unlike the previous posts, which were more design and up front, this post shows working code. I am still not completely happy witht his, mostly because of the RavenMQConnection ctor parameters, but I can live with this for now.


Comments

Dave

RavenMQ is using RavenDB as underlying storage engine. Can I assume that messages are persisted in the document database when RunInMemory=false? As it is (and has roughly the same performance as rhino.queues) I have a ton of usages for it..

With a simple wrapper you can almost use it as an dropin for the Queue <t class. The wrapper can verify if the message is of type T.

Ayende Rahien

Dave,

RavenMQ uses the same storage technology as RavenDB, not RavenDB.

But yes, it persists to disk.

Scooletz

Seems that you want to run your tests as fast as possible, using ManualResetEventSlim:> Does internals of RavenMQ use it as well?

Ayende Rahien

Scooletz,

Actually, no. We don't do any locking inside RavenMQ

Dave

Ayende, thanks for that clarification. I know it's early, but do you have any timeline on a alpha release?

zvolkov

1) What is WaitForSubscription? Why is it required? Why do you say it's not important?

2) Why are IncomingMessage and OutgoingMessage reversed? From the perspective of consumer, shouldn't you Enqueue OutgoingMessage and Subscribe for IncomingMessage? Did you name them from the perspective of the queue server?

configurator

What happens if you don't wait for the subscription? The message should still be handled once the subscription is set up, shouldn't it?

Ayende Rahien

Dave,

I hope to have something out in a month

Ayende Rahien

zvolkov,

1) WaitForSubscriptions is there because I still didn't implement immediate queue check,mostly.

2) Mostly because you are looking at the very low level API. And yes, they are from the POV of the queues server

Ayende Rahien

Configurator,

Yes, but that isn't implemented yet.

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. RavenDB Sharding (2):
    21 May 2015 - Adding a new shard to an existing cluster, the easy way
  2. The RavenDB Comic Strip (2):
    20 May 2015 - Part II – a team in trouble!
  3. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  4. Interview question (2):
    30 Mar 2015 - fix the index
  5. Excerpts from the RavenDB Performance team report (20):
    20 Feb 2015 - Optimizing Compare – The circle of life (a post-mortem)
View all series

RECENT COMMENTS

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats