vendredi 7 septembre 2018

RabbitMQ with sidekiq

I have two rails applications, App1 and App2(added cloudAMQP gem), App1 is producing some message when click on a button

App1

class Publisher
   def publish
    # Start a communication session with RabbitMQ
    connection = Bunny.new(:host => "chimpanzee.rmq.cloudamqp.com", :vhost => "test", :user => "test", :password => "password")
    connection.start

    # open a channel
    channel = connection.create_channel

    # declare a queue
    queue  = channel.queue("test1")

    # publish a message to the default exchange which then gets routed to this queue
    queue.publish("Hello, everybody!")

   end
end

so in the App2 i have to consume all the messages without any button click and put that in sidekiq to process the data, but i am stuck on how can i automatically read from that queue, i know the code how to read values from queue, people are saying sneakers gem, but i am bit confused with sidekiq and sneakers, any idea of how can we do it in heroku?

Aucun commentaire:

Enregistrer un commentaire