I'm quite new to these high level concurrency paradigms, and I've started using the scala RX bindings. So I'm trying to understand how RX differs from messaging queues like RabbitMQ or ZeroMQ?
They both appear to use the subscribe/publish paradigm. Somewhere I saw a tweet about RX being run atop RabbitMQ.
Could someone explain the differences between RX and messaging queues? Why would I choose one over the other? Can one be substituted for the other, or are they mutually exclusive? In what areas do they overlap?
Performance. ZeroMQ: ZeroMQ is much faster than RabbitMQ because it doesn't store messages on the disk, so you don't need to go back and forth to get messages. It stores messages in memory in small buffers. RabbitMQ: RabbitMQ promotes broker functionality; that is, it supports message persistence, so it is slower.
The system has different types of message queues: workstation message queue, user profile message queue, job message queue, system operator message queue, and history log message queue.
RabbitMQ is a message-queueing software also known as a message broker or queue manager. Simply said; it is software where queues are defined, to which applications connect in order to transfer a message or messages. A message can include any kind of information.
You may be thinking of data delivery, non-blocking operations or push notifications. Or you want to use publish / subscribe, asynchronous processing, or work queues. All these are patterns, and they form part of messaging. RabbitMQ is a messaging broker - an intermediary for messaging.
It's worth clicking the learn more link on the [system.reactive]
tag, we put a fair bit of info there!
From the intro there you can see that Rx is not a message queueing technology:
The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. System.Reactive is the root namespace used through the library. Using Rx, developers represent asychronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers.
So, Rx and message queueing are really distinct technologies that can complement each other quite well. A classic example is a stock price ticker service - this might be delivered via message queuing, but then transformed by Rx to group, aggregate and filter prices.
You can go further: much as Entity Framework turns IQueryable<T>
queries into SQL run directly on the database, you can create providers that turn Rx IQbservable<T>
queries into native queries - for example a Where
filter might leverage the native filtering capability that exists in many message queueing technologies to apply filters directly. This is quite a lot of work though, and hard.
It's much easier, and not uncommon to see message queue messages fed into an Rx Subject
so that incoming messages from a queue are transformed into an Rx stream for easy consumption in the client. Rx is also used extensively in GUIs to work with client side events like button presses and text box changes to make traditionally difficult scenarios like drag-n-drop and text auto-completion via asynchronous server queries dramatically easier. There's a good hands on lab covering the later scenario here. It was written against an early release of Rx, but still is very relevant.
I recommend looking at this video presentation by Bart de Smet for a fantastic intro: Curing Your Event Processing Blues with Reactive Extensions (Rx) - including the classic Rx demo that writes a query over a live feed from Kinect to interpret hand-waving!
Could someone explain the differences between RX and these other messaging queues?
Rx is simply an abstraction over Events (any kind of event!). Receiving a message from a distributed queue is an Event, and often, ZeroMQ / RabbitMQ solutions often have to use and combine different Events quite a bit, which Rx is very good at.
So often, Rx makes writing ZeroMQ / RabbitMQ apps much easier than it would be otherwise :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With