lib/legion/transport/message.rb in legion-transport-1.1.9 vs lib/legion/transport/message.rb in legion-transport-1.2.0

- old
+ new

@@ -17,18 +17,51 @@ content_type: options[:content_type] || content_type, content_encoding: options[:content_encoding] || content_encoding, type: options[:type] || type, priority: options[:priority] || priority, expiration: options[:expiration] || expiration, - headers: headers) + headers: headers, + persistent: persistent, + message_id: message_id, + timestamp: timestamp) end + def app_id + @options[:app_id] if @options.key? :app_id + + 'legion' + end + + def message_id + @options[:message_id] || @options[:task_id] + end + + # user_id Sender's identifier. https://www.rabbitmq.com/extensions.html#validated-user-id + def user_id + @options[:user_id] || Legion::Transport.settings[:connection][:user] + end + + def reply_to + @options[:reply_to] + end + + # ID of the message that this message is a reply to + def correlation_id + nil + end + + def persistent + @options[:persistent] || Legion::Transport.settings[:messages][:persistent] + end + def expiration if @options.key? :expiration @options[:expiration] elsif @options.key? :ttl @options[:ttl] + elsif Legion::Transport.settings[:messages].key? :expiration + Legion::Transport.settings[:messages][:expiration] end end def message @options @@ -78,12 +111,12 @@ @options[:headers][header] = @options[header].to_s end @options[:headers] rescue StandardError => e - Legion::Logging.error e.message - Legion::Logging.error e.backtrace + Legion::Transport.logger.error e.message + Legion::Transport.logger.error e.backtrace end def priority 0 end @@ -99,10 +132,10 @@ def type 'task' end def timestamp - now.to_i + Time.now.to_i end def validate @valid = true end