Sidi_Mohammed
Rabbitmq does not receive messages
Hello everybody,
I have an issue concerning rabbitmq, I have just followed entirely this tutorial, Iam using rabbitmq management on ubuntu system, the problem is that messages never reach rabbitmq endpoint, when I check via browser interface in localhost:15672 I can see that everything is good, the connections and channels are all there, but concerning queues there is any message there.
I have checked my code I didn’t any mistake, I have used the default exchange as mentionned in the tutorial so I just can’t debug this issue and maybe I have missed something.
Thank you in advance
Most Liked
Sidi_Mohammed
Of course @dimitarvp ,
I have a docker instance of rabbitmq management
sudo docker run --rm -it --hostname abdelghani -p 15672:15672 -p 5672:5672 rabbitmq:3-management
The elixir code looks like
mix.exs:
....
{:amqp, "~> 3.3"}
...
rabbitmq.ex:
def subscribe(queue) do
{:ok, _connection, channel} = start_connection()
:ok = declare_queue(channel, queue)
:ok = consume(channel, queue)
:ok
end
def publish(queue, payload) do
:ok, connection, channel} = start_connection()
:ok = declare_queue(channel, queue)
:ok = produce(channel, queue, payload)
:ok = close_connection(connection)
:ok
end
def start_connection() do
{:ok, connection} = AMQP.Connection.open()
{:ok, channel} = AMQP.Channel.open(connection)
{:ok, connection, channel}
end
def declare_queue(channel, queue) do
AMQP.Queue.declare(channel, queue)
:ok
end
def consume(channel, queue) do
AMQP.Basic.consume(channel, queue, nil, no_ack: true)
:ok
end
def produce(channel, queue, payload) do
AMQP.Basic.publish(channel, "", queue, payload)
:ok
end
def close_connection(connection) do
AMQP.Connection.close(connection)
:ok
end
end
consumer.ex
:ok = Rabbitmq.subscribe("index")
producer.ex
payload = ....
:ok = Rabbitmq.publish("index", payload)
I can check in web interface that each call for subscribe or publish results in process connection to Rabbitmq server and a new channel created, but the queues are empty and there is no coming data.







