Skip to content

Instantly share code, notes, and snippets.

@jmettraux
Created August 22, 2011 15:12
Show Gist options
  • Save jmettraux/1162615 to your computer and use it in GitHub Desktop.
Save jmettraux/1162615 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# multi.rb
#$:.unshift('~/w/ruote/lib')
#$:.unshift('~/w/ruote-redis/lib')
require 'rubygems'
require 'yajl' rescue require 'json'
require 'rufus-json/automatic'
require 'ruote'
require 'ruote-redis'
class HelloParticipant
include Ruote::LocalParticipant
def consume(workitem)
puts "hello on #{$$} #{Thread.current.object_id} (#{workitem.fields['msg']})"
reply_to_engine(workitem)
end
end
engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::Redis::Storage.new(
'host' => '127.0.0.1',
'db' => 12,
'thread_safe' => true,
'engine_id' => 'master')))
#engine.storage.purge!
engine.register 'hello', HelloParticipant
engine.noisy = true
pdef = Ruote.define do
7.times { wait '2s'; hello }
end
wfid = engine.launch(pdef, 'msg' => 'test0')
engine.wait_for(wfid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment