Class: RabbitMQClient::ReactiveMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/jessica/rabbitmq_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, delivery, body = nil) ⇒ ReactiveMessage

Returns a new instance of ReactiveMessage.



192
193
194
195
196
197
198
# File 'lib/jessica/rabbitmq_client.rb', line 192

def initialize(channel,delivery,body = nil)
  @channel,@delivery = channel,delivery
  @body = body || delivery.body
  @envelope = delivery.envelope
  @properties = delivery.properties
  @reacted = false
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



191
192
193
# File 'lib/jessica/rabbitmq_client.rb', line 191

def body
  @body
end

#envelopeObject (readonly)

Returns the value of attribute envelope.



191
192
193
# File 'lib/jessica/rabbitmq_client.rb', line 191

def envelope
  @envelope
end

#propertiesObject (readonly)

Returns the value of attribute properties.



191
192
193
# File 'lib/jessica/rabbitmq_client.rb', line 191

def properties
  @properties
end

Instance Method Details

#ack!(multiple = false) ⇒ Object



199
200
201
202
# File 'lib/jessica/rabbitmq_client.rb', line 199

def ack!(multiple=false)
  @channel.basic_ack(@envelope.delivery_tag, multiple)
  @reacted = true
end

#reject!(requeue = true) ⇒ Object



203
204
205
206
# File 'lib/jessica/rabbitmq_client.rb', line 203

def reject!(requeue = true)
  @channel.basic_reject(@envelope.delivery_tag, requeue)
  @reacted = true
end

#should_acknowledge?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/jessica/rabbitmq_client.rb', line 207

def should_acknowledge?
  !@reacted
end