Files
policy-service/lib/policy_service/message_bus.ex
HaimKortovich 0a3d63317b
All checks were successful
Build and Publish / build-release (push) Successful in 1m27s
fix messaging bus
2026-04-16 16:35:43 -05:00

21 lines
495 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