Sidi_Mohammed

Sidi_Mohammed

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

Showing Posts 1 to 5

dimitarvp

dimitarvp

It would help if you mention what version of a RabbitMQ library you are using, and to show some code.

Sidi_Mohammed

Sidi_Mohammed OP

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.

ellispritchard

ellispritchard

I don’t know anything about this, but have you tried the exact code from the documentation, as it looks like you’ve missed a couple of steps: AMQP — amqp v4.1.1

Also, you always return :ok from your e.g. produce function instead of the result from the library module call, so you never know if it errors, despite matching it!

Sidi_Mohammed

Sidi_Mohammed OP

@ellispritchard thank you for your suggestions, I have shared a link to the source tutorial which I followed maybe you can take a look, I think it was official doc too from RabittMQ Foundation, also the returned :ok is for ensuring successful of the call and in case of failure there will be an exception error and the process will exit…
I noticed that the issue is in passing message from elixir program to localhost rabbitmq, because if I have to send it manually to the exchange from rabbit UI then it will be broadcasted, I just wonder what is happening, I had never get this before

Sidi_Mohammed

Sidi_Mohammed OP

Finally, I found the bug, the payload was not a string, I just wonder why AMQP didn’t generate an exception and everything went in silence

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews