Class: RServiceBus::Message
- Inherits:
-
Object
- Object
- RServiceBus::Message
- Defined in:
- lib/rservicebus/Message.rb
Overview
This is the top level message that is passed around the bus
Instance Attribute Summary collapse
-
#correlationId ⇒ Object
readonly
Returns the value of attribute correlationId.
-
#lastErrorSourceQueue ⇒ Object
readonly
Returns the value of attribute lastErrorSourceQueue.
-
#lastErrorString ⇒ Object
readonly
Returns the value of attribute lastErrorString.
-
#msgId ⇒ Object
readonly
Returns the value of attribute msgId.
-
#remoteHostName ⇒ Object
readonly
Returns the value of attribute remoteHostName.
-
#remoteQueueName ⇒ Object
readonly
Returns the value of attribute remoteQueueName.
-
#returnAddress ⇒ Object
readonly
Returns the value of attribute returnAddress.
-
#sendAt(timestamp) ⇒ Object
readonly
Returns the value of attribute sendAt.
Instance Method Summary collapse
-
#addErrorMsg(sourceQueue, errorString) ⇒ Object
If an error occurs while processing the message, this method allows details of the error to held next to the msg.
-
#initialize(msg, returnAddress, correlationId = nil) ⇒ Message
constructor
Constructor.
-
#msg ⇒ Object
The msg to be sent.
- #setRemoteHostName(hostName) ⇒ Object
- #setRemoteQueueName(queueName) ⇒ Object
Constructor Details
#initialize(msg, returnAddress, correlationId = nil) ⇒ Message
Constructor
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rservicebus/Message.rb', line 16 def initialize( msg, returnAddress, correlationId=nil ) unless RServiceBus.checkEnvironmentVariable('RSBMSG_COMPRESS') then @compressed = false @_msg=YAML::dump(msg) else @compressed = true @_msg=Zlib::Deflate.deflate(YAML::dump(msg)) end @correlationId = correlationId @returnAddress=returnAddress @createdAt = DateTime.now @msgId=UUIDTools::UUID.random_create @errorList = Array.new end |
Instance Attribute Details
#correlationId ⇒ Object (readonly)
Returns the value of attribute correlationId.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def correlationId @correlationId end |
#lastErrorSourceQueue ⇒ Object (readonly)
Returns the value of attribute lastErrorSourceQueue.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def lastErrorSourceQueue @lastErrorSourceQueue end |
#lastErrorString ⇒ Object (readonly)
Returns the value of attribute lastErrorString.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def lastErrorString @lastErrorString end |
#msgId ⇒ Object (readonly)
Returns the value of attribute msgId.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def msgId @msgId end |
#remoteHostName ⇒ Object (readonly)
Returns the value of attribute remoteHostName.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def remoteHostName @remoteHostName end |
#remoteQueueName ⇒ Object (readonly)
Returns the value of attribute remoteQueueName.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def remoteQueueName @remoteQueueName end |
#returnAddress ⇒ Object (readonly)
Returns the value of attribute returnAddress.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def returnAddress @returnAddress end |
#sendAt(timestamp) ⇒ Object (readonly)
Returns the value of attribute sendAt.
10 11 12 |
# File 'lib/rservicebus/Message.rb', line 10 def sendAt @sendAt end |
Instance Method Details
#addErrorMsg(sourceQueue, errorString) ⇒ 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.
42 43 44 45 46 47 |
# File 'lib/rservicebus/Message.rb', line 42 def addErrorMsg( sourceQueue, errorString ) @lastErrorSourceQueue = sourceQueue @lastErrorString = errorString @errorList << RServiceBus::ErrorMessage.new( sourceQueue, errorString ) end |
#msg ⇒ Object
Returns The msg to be sent.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rservicebus/Message.rb', line 62 def msg if @compressed == true then return YAML::load( Zlib::Inflate.inflate( @_msg )) else return YAML::load( @_msg ) end rescue ArgumentError => e raise e if e..index('undefined class/module ').nil? puts e. msg_name = e..sub( 'undefined class/module ', '') raise ClassNotFoundForMsg.new( msg_name ) end |
#setRemoteHostName(hostName) ⇒ Object
49 50 51 |
# File 'lib/rservicebus/Message.rb', line 49 def setRemoteHostName( hostName ) @remoteHostName = hostName end |
#setRemoteQueueName(queueName) ⇒ Object
53 54 55 |
# File 'lib/rservicebus/Message.rb', line 53 def setRemoteQueueName( queueName ) @remoteQueueName = queueName end |