Sha256: b3df955130519e594c04243cb7cb396fe9db0ee17fcfbe4970e4de1a87ad7344

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

require 'thread'

class Alice
  include Vx::Lib::Consumer

  content_type 'text/plain'
  routing_key 'mykey'
  fanout
end

class Kenny
  include Vx::Lib::Consumer

  class << self
    def m_kill(value)
      "rep: #{value}"
    end
  end

  rpc.action :kill, method(:m_kill)
end

class Bob
  include Vx::Lib::Consumer

  exchange 'bob_exch',  durable: false, auto_delete: true
  queue    'bob_queue', durable: false, auto_delete: true
  ack

  @@m         = Mutex.new
  @@collected = []

  class << self

    attr_accessor :timeout

    def _collected
      @@collected
    end

    def _reset
      @@m.synchronize do
        @@collected = []
      end
    end

    def _save(payload)
      @@m.synchronize do
        @@collected << payload
      end
    end
  end

  def perform(payload)
    self.class._save payload
    sleep self.class.timeout
    ack
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vx-lib-consumer-0.3.4 spec/support/test_consumers.rb
vx-lib-consumer-0.3.3 spec/support/test_consumers.rb
vx-lib-consumer-0.3.2 spec/support/test_consumers.rb
vx-lib-consumer-0.3.1 spec/support/test_consumers.rb
vx-lib-consumer-0.3.0 spec/support/test_consumers.rb
vx-lib-consumer-0.2.2 spec/support/test_consumers.rb
vx-lib-consumer-0.2.1 spec/support/test_consumers.rb