...
 
Commits (3)
......@@ -12,6 +12,10 @@ defmodule SnugglesApp.Application do
supervisor(SnugglesApp.Repo, []),
# Start the endpoint when the application starts
supervisor(SnugglesAppWeb.Endpoint, []),
# Start the AccountCOnsumer supervisor
supervisor(SnugglesApp.RabbitService.AccountConsumer, []),
# Start the Redix supervisor
{Redix, [[], [name: :redix]]}
]
......@@ -23,9 +27,6 @@ defmodule SnugglesApp.Application do
# Start the seperate Discord.Post supervisor
SnugglesApp.Discord.start_post_supervisor
# Start the sepearete AccountConsumer supervisor
SnugglesApp.RabbitService.start_account_consumer
end
# Tell Phoenix to update the endpoint configuration
......
......@@ -94,19 +94,19 @@ defmodule SnugglesApp.RabbitService.AccountConsumer do
{:ok, _} ->
:ok = Basic.reject channel, tag, requeue: false
Logger.info "AccountConsumer received invalid #{payload} from exchange"
{:error, reason} -> Logger.error "AccountConsumer: #{IO.inspect(reason)}, payload: #{payload}"
{:error, reason} -> Logger.error "AccountConsumer payload: #{payload}"
end
# rescue
# # Requeue unless it's a redelivered message.
# # This means we will retry consuming a message once in case of exception
# # before we give up and have it moved to the error queue
# #
# # You might also want to catch :exit signal in production code.
# # Make sure you call ack, nack or reject otherwise comsumer will stop
# # receiving messages.
# exception ->
# :ok = Basic.reject channel, tag, requeue: not redelivered
# Logger.error "AccountConsumer error: payload: #{(payload)}"
rescue
# Requeue unless it's a redelivered message.
# This means we will retry consuming a message once in case of exception
# before we give up and have it moved to the error queue
#
# You might also want to catch :exit signal in production code.
# Make sure you call ack, nack or reject otherwise comsumer will stop
# receiving messages.
exception ->
:ok = Basic.reject channel, tag, requeue: not redelivered
Logger.error "AccountConsumer error: payload: #{(payload)}"
end
end
......@@ -17,18 +17,4 @@ defmodule SnugglesApp.RabbitService do
def publish_json(queue, payload) do
Publish.queue_to_json(queue, payload)
end
@doc """
Opens a new Rabbit consumer taking messags from the accounts queue
and sending them off
## Examples
iex> accounts_consumer()
{:ok, #PID<0.346.0>}
"""
def start_account_consumer do
AccountConsumer.start_link
end
end