lib/message_driver/destination.rb in message-driver-0.4.0 vs lib/message_driver/destination.rb in message-driver-0.5.0
- old
+ new
@@ -8,27 +8,45 @@
@name = name
@dest_options = dest_options
@message_props = message_props
end
- def publish(body, headers={}, properties={})
- adapter.broker.client.publish(self, body, headers, properties)
+ def publish(body, headers = {}, properties = {})
+ current_adapter_context.publish(self, body, headers, properties)
end
- def pop_message(options={})
- adapter.broker.client.pop_message(self, options)
+ def pop_message(options = {})
+ current_adapter_context.pop_message(self, options)
end
def after_initialize(_adapter_context)
- #does nothing, feel free to override as needed
+ # does nothing, feel free to override as needed
end
def message_count
- raise "#message_count is not supported by #{self.class}"
+ fail "#message_count is not supported by #{self.class}"
end
- def subscribe(&_consumer)
- raise "#subscribe is not supported by #{self.class}"
+ def subscribe(_options = {}, &_consumer)
+ fail "#subscribe is not supported by #{self.class}"
+ end
+
+ def consumer_count
+ fail "#consumer_count is not supported by #{self.class}"
+ end
+
+ def middleware
+ @middleware ||= Middleware::MiddlewareStack.new(self)
+ end
+
+ private
+
+ def current_adapter_context
+ adapter.broker.client.current_adapter_context
+ end
+
+ def client
+ @client ||= adapter.broker.client
end
end
end
end