2016-07-05 42 views
4

我想通過amqp從elixir phoenix應用程序中使用rabbitMQ。我也跟着教程official website但仍然在mix.deps compile,我得到一個錯誤:如何設置Elixir項目通過amqp使用RabbitMQ?

include/amqp_gen_consumer_spec.hrl:30: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:31: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:32: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:34: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:35: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:36: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:37: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:38: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:39: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:42: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:30: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:31: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:32: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:34: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:35: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:36: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:37: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:38: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:39: syntax error before: '/' 
include/amqp_gen_consumer_spec.hrl:42: syntax error before: '/' 
Compiling src/amqp_selective_consumer.erl failed: 
ERROR: compile failed while processing /home/bmarkons/soc2016-marko/telegram/deps/amqp_client: rebar_abort 
** (Mix) Could not compile dependency :amqp_client, "/usr/bin/rebar compile skip_deps=true deps_dir="/home/bmarkons/soc2016-marko/telegram/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile amqp_client", update it with "mix deps.update amqp_client" or clean it with "mix deps.clean amqp_client" 

Terminal screenshot

我只加:AMQP和{:AMQP, 「〜> 0.1.4」},在mix.exs文件:

def application do 
    [mod: {App, []}, 
    applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext, 
        :phoenix_ecto, :postgrex, :amqp]] 
end 

defp deps do 
    [{:phoenix, "~> 1.2.0"}, 
    {:phoenix_pubsub, "~> 1.0"}, 
    {:phoenix_ecto, "~> 3.0"}, 
    {:postgrex, ">= 0.0.0"}, 
    {:phoenix_html, "~> 2.6"}, 
    {:phoenix_live_reload, "~> 1.0", only: :dev}, 
    {:gettext, "~> 0.11"}, 
    {:cowboy, "~> 1.0"}, 
    {:amqp, "~> 0.1.4"}] 
end 

我需要做些什麼改變,讓我的elixir應用程序與rabbitMQ一起工作?

謝謝

+0

嗯,這很奇怪。你有沒有試圖清理你的依賴關係? 'mix deps.clean --all'然後'mix deps.get'和'mix deps.compile'。另外,您使用的是哪種版本的Elixir? –

+0

我正在使用Elixir 1.3.1。我也嘗試過,但仍然出現錯誤。 –

+0

什麼是Erlang版本? –

回答

7

它在:amqp項目(https://github.com/pma/amqp/issues/28)未使用Erlang 19編寫問題在於:amqp_client報告的問題。存儲庫中的最後一個版本是固定的,但它不是作爲十六進制包存在的。

更新2016年8月16日:

如果你想使用AMQP使用Erlang 19在你的項目只是添加當前:amqp_client依賴覆蓋附帶AMQP之一:

def deps do 
    [{:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true}, 
    {:amqp, "~> 0.1.4"}] 
end 

對於這個具體的例子,你應該有這樣的東西:

defp deps do 
    [{:phoenix, "~> 1.2.0"}, 
    {:phoenix_pubsub, "~> 1.0"}, 
    {:phoenix_ecto, "~> 3.0"}, 
    {:postgrex, ">= 0.0.0"}, 
    {:phoenix_html, "~> 2.6"}, 
    {:phoenix_live_reload, "~> 1.0", only: :dev}, 
    {:gettext, "~> 0.11"}, 
    {:cowboy, "~> 1.0"}, 
    {:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true}, 
    {:amqp, "~> 0.1.4"] 
end 

Important: You should override the :amqp_client dependency in projects that use AMQP event if their mix file is already overriding the dependency.

我希望這會有所幫助。

+0

是的,謝謝:))) –

+0

編輯答案添加一個可能的解決方法。 –

+0

我最近更新了erlang並得到這個錯誤。我遵循你的步驟並編譯。但是,我必須做一些小改動 - 我必須將{:amqp,github:「/amqp」}更改爲{:amqp_client,github:「<您的github用戶名>/amqp」}和:應用程序中的amqp:amqp_clients。 但現在它給這個錯誤:模塊AMQP沒有加載,無法找到[在這一行 - 使用AMQP] 你能告訴我可能是什麼原因,以及如何解決這個問題? –

7

我不得不定義如下(分支信息),以得到它的運行依賴:

defp deps do 
[ 
    {:amqp_client, git: "https://github.com/dsrosario/amqp_client.git", branch: "erlang_otp_19", override: true}, 
    {:amqp, "~> 0.1.4"} 
] 

相關問題