class RServiceBusBeanstalkAdmin

Public Instance Methods

convert_msg_to_hash(idx, body) click to toggle source
# File lib/rservicebus-beanstalk-webadmin.rb, line 67
def convert_msg_to_hash(idx, body)
  return convert_rservicebus2_msg_to_hash(idx, body) unless body.index('RServiceBus2::Message').nil?
  return convert_rservicebus_msg_to_hash(idx, body) unless body.index('RServiceBus::Message').nil?

  Hash['idx', 'id', 'error_list', []]
end
convert_rservicebus2_msg_to_hash(idx, body) click to toggle source
# File lib/rservicebus-beanstalk-webadmin.rb, line 20
def convert_rservicebus2_msg_to_hash(idx, body)
  if body.index('RServiceBus2::Message').nil?
    return Hash['idx', 'id', 'error_list', []]
  end

  msg_wrapper = YAML.load(body)

  hash = Hash['idx', idx,
              'msg_id', msg_wrapper.msg_id,
              'return_address', msg_wrapper.return_address,
              'body', body,
              'error_list', []]

  msg_wrapper.error_list.each do |e|
    h = Hash['occurredat', e.occurredat,
             'source_queue', e.source_queue,
             'error_msg', e.error_msg]
    hash['error_list'] << h
  end

  hash['name'] = body.match('ruby/object:([A-Za-z0-9_:]*?)[^A-Za-z0-9_:]',
                            '-- !ruby/object:RServiceBus2::Message'.length)[1]
  hash
end
convert_rservicebus_msg_to_hash(idx, body) click to toggle source
# File lib/rservicebus-beanstalk-webadmin.rb, line 45
def convert_rservicebus_msg_to_hash(idx, body)
  require 'rservicebus'
  msg_wrapper = YAML.load(body)

  hash = Hash['idx', idx,
              'msg_id', msg_wrapper.msgId,
              'return_address', msg_wrapper.returnAddress,
              'body', body,
              'error_list', []]

#  msg_wrapper.error_list.each do |e|
#    h = Hash['occurredat', e.occurredat,
#             'source_queue', e.source_queue,
#             'error_msg', e.error_msg]
#    hash['error_list'] << h
#  end

  hash['name'] = body.match('ruby/object:([A-Za-z0-9_:]*?)[^A-Za-z0-9_:]',
                            '-- !ruby/object:RServiceBus2::Message'.length)[1]
  hash
end