lib/postman.rb
# Our consumer operates in another thread. It is non blocking.
# While a blocking consumer would be convenient, it causes problems:
# 1. @consumer never gets set, requiring up instead to instantiate it first, then use subscribe_with
# 2. We are still unable to call @consumer.cancel in our trap, give the aforementioned restrictions
# 3. However, as our main thread is locked, we don't have anywhere else to handle the shutdown from
# 4. There doesn't seem to be much gained from spinning up the control loop in its own thread
Our consumer operates in another thread. It is non blocking.
While a blocking consumer would be convenient, it causes problems:
1. @consumer never gets set, requiring up instead to instantiate it first, then use subscribe_with
2. We are still unable to call @consumer.cancel in our trap, give the aforementioned restrictions
3. However, as our main thread is locked, we don't have anywhere else to handle the shutdown from
4. There doesn't seem to be much gained from spinning up the control loop in its own thread
Our consumer operates in another thread . It is non blocking . While a blocking consumer would be convenient it causes problems : 1 . @consumer never gets set requiring up instead to instantiate it first then use subscribe_with 2 . We are still unable to call @consumer . cancel in our trap give the aforementioned restrictions 3 . However as our main thread is locked we don ' t have anywhere else to handle the shutdown from 4 . There doesn ' t seem to be much gained from spinning up the control loop in its own thread
def subscribe!
    raise StandardError, "Consumer already exists" unless @consumer.nil?
    @consumer ||= @main_exchange.subscribe(@consumer_tag) do |delivery_info, metadata, payload|
      process(delivery_info, metadata, payload)
    end
  end
def subscribe! raise StandardError , "Consumer already exists" unless @consumer . nil? @consumer ||= @main_exchange . subscribe ( @consumer_tag ) do | delivery_info , metadata , payload | process ( delivery_info , metadata , payload ) end end
Our consumer operates in another thread.
Our consumer operates in another thread .