Class: QProcessor::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/qprocessor/message.rb

Overview

This is a class representing a message or job pulled from a queue with the intention of this class providing a unified interface around different library classes.

Direct Known Subclasses

BeanstalkMessage, SQSMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Message

Returns a new instance of Message.



6
7
8
# File 'lib/qprocessor/message.rb', line 6

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/qprocessor/message.rb', line 9

def source
  @source
end

Instance Method Details

#bodyObject

Retrieves the content of the message/job as a String.



12
13
14
# File 'lib/qprocessor/message.rb', line 12

def body
  @source.body
end

#disposeObject

This method should do whatever is necessary to clean up a message/job such that the underlying queuing mechanism will no longer deliver it. This is a ‘do nothing’ implementation that can be overridden by derived classes to provide for this functionality.



20
21
# File 'lib/qprocessor/message.rb', line 20

def dispose
end

#idObject

Fetches a unique identifer for the message/job. This default implementation raises an exception. Derived classes can override this to provide the required functionality.



26
27
28
# File 'lib/qprocessor/message.rb', line 26

def id
  raise "The #{self.class.name} class does not override the #id() method."
end

#releaseObject

This method should do whatever is necessary to return a message/job to the underlying queuing mechanism such that it becomes available again for delivery. This is a ‘do nothing’ implementation that can be overridden by derived classes to provide for this functionality.



34
35
# File 'lib/qprocessor/message.rb', line 34

def release
end