module Banter

Internal database logger that saves the publish message before it is send and also acts as a sink for messages.

Middleware to ensure that we clear the context with every request

Internal log class that is used to log envelopes before sending, after receiving, and failure to send

In order to use the server, the caller must be able to bring in the necessary classes for require before instantiating the instance.

This class provders the worker for executing the subscriber. It receives a message from rabbitmq and creates an instance of the subscriber to execute with the message and context

Constants

VERSION

Public Class Methods

configure() { |Configuration| ... } click to toggle source

A convenience methods, specially for non-rails applications to configure Banter Usage: Banter.configure do |config|

config.default_queue_ttl = 2.hours

end

# File lib/banter.rb, line 62
def self.configure
  yield Banter::Configuration
end
delay_messages() { || ... } click to toggle source

Delay actual publishing of messages to rabbitmq. Any messages published using Banter.publish will be delayed till after the block. if any errors happen in this block, then no messages are published to the rabbitmq. Usage: Banter.delay_messages do

Banter.publish('foo.bar', {}) # -> message will not be published here

end # -> message will be published here

# File lib/banter.rb, line 41
def self.delay_messages
  Publisher.instance.delay_messages{ yield }
end
logger() click to toggle source

@return [Logger] Logger used for logging through the Banter gem

# File lib/banter.rb, line 46
def self.logger
  return Banter::Configuration.logger if Banter::Configuration.logger
  @logger ||= ActiveSupport::TaggedLogging.new(Logger.new($stdout))
end
logger=(logger) click to toggle source

@param [Logger] logger Logger for publish, message received and error events

# File lib/banter.rb, line 52
def self.logger=(logger)
  Banter::Configuration.logger = ActiveSupport::TaggedLogging.new(logger)
end
publish(routing_key, payload) click to toggle source

This method publishes payload to rabbitmq. All listeners with appropriate routing keys will receive the payload. @param [String] routing_key Identifier of the message type @param [Hash] payload The data that will be passed to the subscriber

# File lib/banter.rb, line 31
def self.publish(routing_key, payload)
  Publisher.instance.publish(Banter::Context.instance, routing_key, payload)
end