【问题标题】:How can I send JSON to consumer using RabbitMQ and Elixir? [closed]如何使用 RabbitMQ 和 Elixir 将 JSON 发送给消费者? [关闭]
【发布时间】:2016-04-19 18:31:15
【问题描述】:

我正在尝试使用 RabbitMQ 将 JSON 发送给消费者?有可能吗?怎么做?我使用 Elixir 作为我的编程语言。

【问题讨论】:

标签: rabbitmq elixir


【解决方案1】:

点击此链接到: https://github.com/pma/amqp

关于发送 JSON 的更多信息的未决问题。

iex(1)> {:ok, conn} = AMQP.Connection.open
{:ok, %AMQP.Connection{pid: #PID<0.364.0>}}
iex(2)> {:ok, chan} = AMQP.Channel.open(conn)
{:ok,
 %AMQP.Channel{conn: %AMQP.Connection{pid: #PID<0.364.0>}, pid: #PID<0.376.0>}}
iex(3)> AMQP.Queue.declare chan, "test_queue"
{:ok, %{consumer_count: 0, message_count: 0, queue: "test_queue"}}
iex(4)> AMQP.Exchange.declare chan, "test_exchange"
:ok
iex(5)> AMQP.Queue.bind chan, "test_queue", "test_exchange"
:ok
iex(6)> AMQP.Basic.publish(chan, "test_exchange", "", Poison.encode(%{ name: "S" }), [content_type: "application/json"])
:ok

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-15
    • 2020-09-20
    • 1970-01-01
    • 2018-04-12
    • 2016-04-04
    • 1970-01-01
    相关资源
    最近更新 更多