What are the available messaging solutions for interprocess communication in ruby?

I have a rails application using delayed_job. I need my assignments to communicate with each other for things like "task 5" or "this is a list of things that need to be processed for task 5".

Now I have a special table just for this, and I always get access to the table inside the transaction. It works great. I want to create a clean api / dsl for it, but first I wanted to check if there are already existing solutions for this. It is strange that I did not find a single thing, I am either completely mistaken, or the task is so simple (given and gets the values โ€‹โ€‹inside the transaction) that no one has abstracted it yet.

Did I miss something?

Explanation: I am not looking for a new queuing system; I am looking for a way for background tasks to interact with each other. Basically just safe shared variables. Are the scope of this facility below? It is a pity that deferred work does not work.

use: "complete these 5 tasks in parallel, and then when everything is done, complete this 1 final task." Thus, each of the 5 tasks checks whether it is the last, and if it is, then it completes the final task.

+5
source share
3 answers

resque. plugins, .

redis : pub-sub /.

( ): http://www.zeromq.org/, ruby โ€‹โ€‹bindings. , zeromq.


// :

DelayedJobs Resque - , , Redis .

:

DJ, redis zeromq/0mq ( ), .

ActiveRecord/MySQL ( !), , .

, , memcache; , .

. , . ?

, - DRb ( ), . ( )

DRb, .

: () > >

+3

Pipes:

reader, writer = IO.pipe

fork do
  loop do
    payload = { name: 'Kris' }
    writer.puts Marshal.dump(payload)
    sleep(0.5)
  end
end

loop do
  begin
    Timeout::timeout(1) do
      puts Marshal.load(reader.gets) # => { name: 'Kris' }
    end
  rescue Timeout::Error
    # no-op, no messages to receive
  end
end

, . , .

0

All Articles