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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews