mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 13:56:49 +00:00
Adds content_type configuration
This commit is contained in:
parent
e5ebfb84d0
commit
035a9822ee
@ -19,8 +19,19 @@ module Outboxable
|
||||
# Declare a exchange
|
||||
exchange = channel.topic(@resource.exchange, durable: true)
|
||||
|
||||
content_type = if @resource.respond_to?(:content_type) && @resource.content_type.present?
|
||||
@resource.content_type
|
||||
else
|
||||
'application/json'
|
||||
end
|
||||
|
||||
# Publish the CloudEvent resource to the exchange
|
||||
exchange.publish(to_envelope(resource: @resource), routing_key: @resource.routing_key, headers: @resource.try(:headers) || {})
|
||||
exchange.publish(
|
||||
to_envelope(resource: @resource),
|
||||
routing_key: @resource.routing_key,
|
||||
headers: @resource.try(:headers) || {},
|
||||
content_type:
|
||||
)
|
||||
|
||||
# Wait for confirmation
|
||||
confirmed = channel.wait_for_confirms
|
||||
|
||||
@ -7,6 +7,7 @@ class CreateOutboxableOutboxes < ActiveRecord::Migration[7.0]
|
||||
|
||||
t.string :exchange, null: false, default: ''
|
||||
t.string :routing_key, null: false, default: ''
|
||||
t.string :content_type, null: false, default: 'application/json'
|
||||
|
||||
t.integer :attempts, null: false, default: 0
|
||||
t.datetime :last_attempted_at, null: true
|
||||
|
||||
@ -10,6 +10,7 @@ class Outbox
|
||||
|
||||
field :exchange, type: String, default: ''
|
||||
field :routing_key, type: String, default: ''
|
||||
field :content_type, type: String, default: 'application/json'
|
||||
|
||||
field :attempts, type: Integer, default: 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user