Class: Qwirk::Adapter::JMS::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/qwirk/adapter/jms/util.rb

Class Method Summary collapse

Class Method Details

.create_message(session, marshaled_object, marshal_type) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/qwirk/adapter/jms/util.rb', line 6

def create_message(session, marshaled_object, marshal_type)
  case marshal_type
    when :text
      session.create_text_message(marshaled_object)
    when :bytes
      msg = session.create_bytes_message()
      msg.data = marshaled_object
      msg
    else raise "Invalid marshal type: #{marshal_type}"
  end
end

.parse_response(message) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/qwirk/adapter/jms/util.rb', line 18

def parse_response(message)
  if error_yaml = message['qwirk:exception']
    return Qwirk::RemoteException.unmarshal(error_yaml)
  end
  marshaler = Qwirk::MarshalStrategy.find(message['qwirk:marshal'] || WorkerConfig.default_marshal_sym)
  return marshaler.unmarshal(message.data)
end