Quick Start

Erlang Quick Start

It is recommended to first define the interface jar using Java, and use the erlanalysis tool to parse Java interfaces into Erlang lib.

Import Dependency Libraries

Using the Rebar Build Tool.

Add dubblerl to your project’s rebar.config

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

Using the erlang.mk Build Tool

To be added

Import Interface Libraries

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 uploaded to your git repository, you can import it 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 repo URL
  4. ]}.

Consumer Configuration

Please reference Reference Config

Init dubbolib in Your Project

It is need you to

  1. dubboerl:init().

How to Call?

Synchronous Call

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

If an error occurs, the response is {error,Reason}.

Asynchronous Call

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).

Example

Refer to the project dubboerl_demo

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)