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
ActiveMQBytesMessage
which a JMS consumer should receive. -
.from_kafka(message) ⇒ Stapfen::Message
Create an instance of Message from the passed in
String
which a Kafka 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.
5 6 7 8 9 10 11 |
# File 'lib/stapfen/message.rb', line 5 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.
3 4 5 |
# File 'lib/stapfen/message.rb', line 3 def body @body end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
3 4 5 |
# File 'lib/stapfen/message.rb', line 3 def destination @destination end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
3 4 5 |
# File 'lib/stapfen/message.rb', line 3 def @message_id end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
3 4 5 |
# File 'lib/stapfen/message.rb', line 3 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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stapfen/message.rb', line 34 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_kafka(message) ⇒ Stapfen::Message
Create an instance of Stapfen::Message from the passed in String
which a Kafka consumer should receive
50 51 52 53 54 55 56 |
# File 'lib/stapfen/message.rb', line 50 def self.from_kafka() unless .kind_of? String raise Stapfen::InvalidMessageError, .inspect end return self.new(:body => ) end |
.from_stomp(message) ⇒ Stapfen::Message
Create an instance of Stapfen::Message from the passed in Stomp::Message
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stapfen/message.rb', line 18 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 |