Files
HaimKortovich 67837ff3ea
All checks were successful
Build and Publish / build-release (push) Successful in 1m26s
publish aggregate when task is complete
2026-04-17 13:32:46 -05:00

21 lines
499 B
Elixir

defmodule WorkloadService.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!(:workload_service, :amqp_url)
end