Class: Stapfen::Message
- Inherits:
-
Object
- Object
- Stapfen::Message
- Defined in:
- lib/stapfen/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Class Method Summary collapse
-
.from_jms(message) ⇒ Stapfen::Message
Create an instance of Message from the passed in
ActiveMQBytesMessagewhich a JMS consumer should receive. -
.from_stomp(message) ⇒ Stapfen::Message
Create an instance of Message from the passed in Stomp::Message.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(opts = {}) ⇒ Message
Returns a new instance of Message.
6 7 8 9 10 11 12 |
# File 'lib/stapfen/message.rb', line 6 def initialize(opts={}) super() @body = opts[:body] @destination = opts[:destination] @message_id = opts[:message_id] @original = opts[:original] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/stapfen/message.rb', line 4 def body @body end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
4 5 6 |
# File 'lib/stapfen/message.rb', line 4 def destination @destination end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
4 5 6 |
# File 'lib/stapfen/message.rb', line 4 def @message_id end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
4 5 6 |
# File 'lib/stapfen/message.rb', line 4 def original @original end |
Class Method Details
.from_jms(message) ⇒ Stapfen::Message
Create an instance of Stapfen::Message from the passed in ActiveMQBytesMessage which a JMS consumer should receive
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/stapfen/message.rb', line 35 def self.from_jms() unless .kind_of? Java::JavaxJms::Message raise Stapfen::InvalidMessageError, .inspect end return self.new(:body => .data, :destination => .jms_destination.getQualifiedName, :message_id => ., :original => ) end |
.from_stomp(message) ⇒ Stapfen::Message
Create an instance of Stapfen::Message from the passed in Stomp::Message
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/stapfen/message.rb', line 19 def self.from_stomp() unless .kind_of? Stomp::Message raise Stapfen::InvalidMessageError, .inspect end return self.new(:body => .body, :destination => .headers['destination'], :message_id => .headers['message-id'], :original => ) end |