Sha256: 175b2b41db3ca728512a6a29b98758689d8a21c8d64cfb141e19d9097560f74b

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# This monkey patch allows you to customize the message format that you publish to your broker.
# By default, Outboxable publishes a CloudEvent message to your broker.
module Outboxable
  module RabbitMq
    class Publisher
      # Override this method to customize the message format that you publish to your broker
      # DO NOT CHANGE THE METHOD SIGNATURE
      def to_envelope(resource:)
        {
          id: resource.id,
          source: 'http://localhost:3000',
          specversion: '1.0',
          type: resource.routing_key,
          datacontenttype: 'application/json',
          data: resource.payload
        }.to_json
      end
    end
  end
end

Outboxable.configure do |config|
  # Specify the ORM you are using. For now, only ActiveRecord is supported.
  config.orm = :activerecord

  # Specify the ORM you are using. Supported values are :activerecord and :mongoid
  config.message_broker = :rabbitmq

  # RabbitMQ configurations
  config.rabbitmq_host = ENV.fetch('RABBITMQ__HOST')
  config.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', 5672)
  config.rabbitmq_user = ENV.fetch('RABBITMQ__USERNAME')
  config.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD')
  config.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST')
  config.rabbitmq_exchange_name = ENV.fetch('RABBITMQ__EXCHANGE_NAME')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outboxable-1.0.6 lib/templates/activerecord_initializer.rb