Files
policy-service/lib/policy_service/message_bus.ex
HaimKortovich 2a8f2ffc2d
All checks were successful
Build and Publish / build-release (push) Successful in 1m38s
refactor buyer and insured and add more policy types
2026-04-27 14:06:28 -05:00

22 lines
496 B
Elixir

defmodule PolicyService.MessageBus do
use AMQP
def publish(exchange, routing_key, event) do
payload = Jason.encode!(event)
:ok =
AMQP.Basic.publish(channel(), exchange, routing_key, payload,
content_type: "application/json",
persistent: true
)
end
defp channel do
{:ok, conn} = AMQP.Connection.open(amqp_url())
{:ok, chan} = AMQP.Channel.open(conn)
chan
end
defp amqp_url, do: Application.fetch_env!(:policy_service, :amqp_url)
end