【发布时间】:2016-04-19 18:31:15
【问题描述】:
我正在尝试使用 RabbitMQ 将 JSON 发送给消费者?有可能吗?怎么做?我使用 Elixir 作为我的编程语言。
【问题讨论】:
-
Stackoverflow 更适合获取特定问题的答案。请自己尝试一些事情,如果您在此过程中有任何问题,请回来。
我正在尝试使用 RabbitMQ 将 JSON 发送给消费者?有可能吗?怎么做?我使用 Elixir 作为我的编程语言。
【问题讨论】:
点击此链接到: 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
【讨论】: