AWS SNS Free Equivalent - LMAX Disruptor/MQTT/RabbitMQ/ based Real-time x-Platform Notification Framework
#Why we need RealTimeNotification Framework?
As you all know Publish/Subscribe is one of the Key Design paradigms that has a place in most distributed architecutres. For instance Mobile Push Notification is nothing but a distributed Pub/Sub. APNS and GCM are doing cloud backed Pub/Sub for apps.
- Are you imaptient and need to deploy a X-platform MQTT Push Notification Infrastructure for iOS and Android?
- Are you using distributed notification service($$) like AMAZON Simple Notification Service and looking for free alternative?
- Are you willing to deploy a highly scalable distributed Pub/Sub system for IoT / Big data backed systems?
RTN is the a unified framework that will take care of the above use-cases with minimal effort from your side.
- By default this can run in a single machine and the requirment is to have to have RabbitMQ with MQTT plugin enabled and Elastic Search installed locally.
- Uses LMAX disruptor for high speed thread communciation.
- Uses RabbitMQ as a AMQP and MQTT Broker.
- Can use Commodity hardware for horizontal scalability. (Ofcourse you need to spin out additional hardware)
The Horizontal scalability here needs a bit of explanation and I dont want to Risk misguiding you on the inner working of RTN.
Heart of the RTN is a high speed Inter Threading component using LMAX disruptor pattern called RTNAgent. RTNAgent itself runs in single machine. i.e RTNAgent is vertically scalable. All it does is checks ElasticSearch for subscriptions for a particular Event and sends notifications to the respective subscribers i.e sends notification messages to RabbitMQ queues. Matching the event load you can scale RabbitMQ. If you have lots of subscriptions and ElasticSearch seem to slow you down you could scale and shard it, but that wouldnt be the case 99% of the time.
For v1.0 RTN supports only MQTTNotifiers and for most requiremets RabbitMQ scale wouldnt be required as this is already high performant.
- Items highlighted in green in the Architecture diagram are available as a part of v1.0
- Download and install RabbitMQ.
- Download and install ElasticSearch (if you have requirements for Broadcast/Multicast notifications).
- Override config.properties K,V pairs as required.
- Down RTN code and start RTNAgent
- Refer pushtest.java to create Server side push code.
- To create mobile notifiction listener On mobile side refer to my other library here
- Create subscriptions in ElasticSearch using if you have requirements for Broadcast/Multicast notifications.
- Create an Index called rtn - PUT http://localhost:9200/rtn/
- Create a sample subscription - POST http://localhost:9200/rtn/subscriptions/1 Refer this gist for a sample subscription
#Creating your own Notification message
You have to tweak GPMessage.java, PushEntry.java and PublishRequest.java to have your own messages. This isnt trivial you need to change RingBufferConsumer.java as well accordingly.
- Add support Email, SMS, Queue end points.
- Add Publish and Subscribe as REST API.
- Add support for some more protocols like STOMP, CoAP.
- If I get enough requests and/or use-cases to have RTNAgent Horizontally scalable - I would introduce Apache storm.