快速开始

Erlang 快速开始

建议先使用 java 定义接口 jar,并使用 erlanalysis 工具解析java接口至Erlang lib

导入依赖库

使用 Rebar 编译工具。

Add dubblerl to rebar.config with your project

  1. {deps, [
  2. {dubboerl, {git, "https://github.com/apache/dubbo-erlang.git", {branch, "master"}}}
  3. ]}.

使用 erlang.mk 编译工具

待补充

导入接口库

Suppose the interface lib you exported is called dubbo_service.

  • If you didn’t upload your lib to your git repository, It is recommended that you copy the dubbo_service lib into the project’s apps directory.
  • If it is upload to your git repository, you can import like this:
  1. {deps, [
  2. {dubboerl, {git, "https://github.com/apache/dubbo-erlang.git", {branch, "master"}}},
  3. {dubbo_service,{git,"${INTERFACE_LIB_URL}",{branch,"master"}}} %% replace ${INTERFACE_LIB_URL} with your lib git repos url
  4. ]}.

消费者配置

Please reference Reference Config

Init dubbolib in your project

It is need you

  1. dubboerl:init().

如何调用?

同步调用

  1. Request = #userInfoRequest{requestId = 123, username = "testname"},
  2. {ok,RequestRef,Response,RpcContent} = userOperator:queryUserInfo(Request,#{sync=> true}).

If it occur error, is reponse {error,Reason}.

异步调用

Default is Async call.

  1. Request = #userInfoRequest{requestId = 123, username = "testname"},
  2. {ok,RequestRef} = userOperator:queryUserInfo(Request).
  3. %% you can receive the message after.
  4. handle_cast({msg_back,RequestRef,Response,RpcContent},State).

示例

参考项目 dubboerl_demo

最后修改 September 21, 2021: Bug fix miss mialbox (#953) (57cf51b)