README.md in smart-que-0.1.2 vs README.md in smart-que-0.2.0

- old
+ new

@@ -21,20 +21,21 @@ ## Usage 1. Setup [RabbitMq](https://www.rabbitmq.com/#getstarted) 2. Add `smart-que` gem to your Gemfile and perform bundle install -3. Create Publisher/Consumer classes & start publish/consume messages +3. Require `smart_que` in the application.rb file +4. Create Publisher/Consumer classes & start publish/consume messages ## SmartQue Publisher SmartQue publisher is used to publish messages to the previously setup RabbitMq server. All messages are converted to JSON format before publishing to the queue. RabbitMq server details and queue lists can be configured as follows ``` -file: config/initializers/smart_que.rb +# File: config/initializers/smart_que.rb SmartQue.configure do |f| f.host = ENV[:rabbit_mq][:host'] f.port = ENV[:rabbit_mq][:port'] f.username = ENV[:rabbit_mq][:username'] @@ -47,10 +48,14 @@ ] end $publisher = SmartQue::Publisher.new +# Add this below mentioned line to your application.rb +# File : config/application.rb + +require 'smart_que' ``` After initializing SmartQue publisher, it can be accessed anywhere in the rails application to publish messages to the RabbitMq server. @@ -63,16 +68,17 @@ The consumer class should be inherited from SmartQue::Consumer, and each consumer will be listening to a defined Queue. The queue name and `run` method should be defined properly in each consumer class. ``` -Class OtpSmsConsumer < SmartQue::Consumer +class OtpSmsConsumer < SmartQue::Consumer QUEUE_NAME = 'sms.otp' def run(payload) # Payload: { number: '+919898123123', message: 'Test Message' } # Method implementation goes here + puts payload end end ``` Note that, queue name words are separated by `.` while defining it with consumer class. @@ -100,9 +106,21 @@ end # Task can be initiated by rake RAILS_ENV=staging bundle exec rake rabbitmq:send_otp_sms ``` + +## RabbitMq Web Interface + +You can enable rabbitmq_management plugin so that rabbitmq server informations +are viewed and managed via web console interface. Management plugin can be enabled +by running this command and can be accessed through [web browser](localhost:15672) + +``` +rabbitmq-plugins enable rabbitmq_management +``` + +More informations are available on RabbitMq [management plugin documentations](https://www.rabbitmq.com/management.html). ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.