Class: RServiceBus2::Message
- Inherits:
-
Object
- Object
- RServiceBus2::Message
- Defined in:
- lib/rservicebus2/message.rb
Overview
This is the top level message that is passed around the bus
Instance Attribute Summary collapse
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#error_list ⇒ Object
readonly
Returns the value of attribute error_list.
-
#last_error_source_queue ⇒ Object
readonly
Returns the value of attribute last_error_source_queue.
-
#last_error_string ⇒ Object
readonly
Returns the value of attribute last_error_string.
-
#msg_id ⇒ Object
readonly
Returns the value of attribute msg_id.
-
#remote_host_name ⇒ Object
Returns the value of attribute remote_host_name.
-
#remote_queue_name ⇒ Object
Returns the value of attribute remote_queue_name.
-
#return_address ⇒ Object
readonly
Returns the value of attribute return_address.
-
#send_at ⇒ Object
Returns the value of attribute send_at.
-
#sendat ⇒ Object
readonly
Returns the value of attribute sendat.
Instance Method Summary collapse
-
#add_error_msg(source_queue, error_string) ⇒ Object
If an error occurs while processing the message, this method allows details of the error to held next to the msg.
-
#initialize(msg, return_address, correlation_id = nil) ⇒ Message
constructor
Constructor.
-
#msg ⇒ Object
The msg to be sent.
Constructor Details
#initialize(msg, return_address, correlation_id = nil) ⇒ Message
Constructor
rubocop:disable Metrics/MethodLength
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rservicebus2/message.rb', line 22 def initialize(msg, return_address, correlation_id = nil) if RServiceBus2.check_environment_variable('RSBMSG_COMPRESS') @compressed = true @_msg = Zlib::Deflate.deflate(YAML.dump(msg)) else @compressed = false @_msg = YAML.dump(msg) end @correlation_id = correlation_id @return_address = return_address @createdat = Time.now @msg_id = UUIDTools::UUID.random_create @error_list = [] end |
Instance Attribute Details
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def correlation_id @correlation_id end |
#error_list ⇒ Object (readonly)
Returns the value of attribute error_list.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def error_list @error_list end |
#last_error_source_queue ⇒ Object (readonly)
Returns the value of attribute last_error_source_queue.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def last_error_source_queue @last_error_source_queue end |
#last_error_string ⇒ Object (readonly)
Returns the value of attribute last_error_string.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def last_error_string @last_error_string end |
#msg_id ⇒ Object (readonly)
Returns the value of attribute msg_id.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def msg_id @msg_id end |
#remote_host_name ⇒ Object
Returns the value of attribute remote_host_name.
14 15 16 |
# File 'lib/rservicebus2/message.rb', line 14 def remote_host_name @remote_host_name end |
#remote_queue_name ⇒ Object
Returns the value of attribute remote_queue_name.
14 15 16 |
# File 'lib/rservicebus2/message.rb', line 14 def remote_queue_name @remote_queue_name end |
#return_address ⇒ Object (readonly)
Returns the value of attribute return_address.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def return_address @return_address end |
#send_at ⇒ Object
Returns the value of attribute send_at.
14 15 16 |
# File 'lib/rservicebus2/message.rb', line 14 def send_at @send_at end |
#sendat ⇒ Object (readonly)
Returns the value of attribute sendat.
10 11 12 |
# File 'lib/rservicebus2/message.rb', line 10 def sendat @sendat end |
Instance Method Details
#add_error_msg(source_queue, error_string) ⇒ Object
If an error occurs while processing the message, this method allows details of the error to held next to the msg.
Error(s) are held in an array, which allows current error information to be held, while still retaining historical error messages.
49 50 51 52 53 54 |
# File 'lib/rservicebus2/message.rb', line 49 def add_error_msg(source_queue, error_string) @last_error_source_queue = source_queue @last_error_string = error_string @error_list << RServiceBus2::ErrorMessage.new(source_queue, error_string) end |
#msg ⇒ Object
Returns The msg to be sent.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rservicebus2/message.rb', line 57 def msg return RServiceBus2.safe_load(Zlib::Inflate.inflate(@_msg)) if @compressed == true RServiceBus2.safe_load(@_msg) rescue ArgumentError => e raise e if e..index('undefined class/module ').nil? puts e. msg_name = e..sub('undefined class/module ', '') raise ClassNotFoundForMsg, msg_name end |