itk_queue v0.2.4 ITKQueue

Provides convenience functions for subscribing to queues and publishing messages.

Summary

Functions

Publish a message. Expects the message to be something that can be encoded as JSON

Functions

publish(routing_key, message)

Publish a message. Expects the message to be something that can be encoded as JSON.

Examples

iex> ITKQueue.publish("data.sync", %{type: "user", data: %{name: "Test User"}})
subscribe(queue_name, routing_key, handler)

Subscribes to a queue.

The handler is expected to be a function that handles the message. If the function raises an exception the message will be moved to a temporary queue and retried after a delay.

Examples

iex> ITKQueue.subscribe("students-data-sync", "data.sync", fn(message) -> IO.puts(inspect(message)) end)