How to build erlang AMQP client in Mongooseim

前端 未结 2 1030
南方客
南方客 2021-01-17 02:46

I am new in erlang. I am trying to build RabitMQ Erlang AMQP client library with my mongoose source so that I can use the library within my mongooseim modules. I downloaded

2条回答
  •  一生所求
    2021-01-17 03:23

    The way you suggest will work, but a cleaner approach is possible. You could tweak the Makefile to simply copy the library into the just built MongooseIM release directory, but there's a better way:

    1. Download and unpack amqp_client-3.5.1.ez inside mongooseim/apps/.
    2. Optionally check in mongooseim/apps/amqp_client-3.5.1/ into your git repo, so you won't have to download it again each time you clone the repository.
    3. Make reltool bundle the application just as it bundles MongooseIM dependencies and components, that is apply the following patch:

      diff --git a/rel/reltool.config.script b/rel/reltool.config.script
      index 731d58c..395a73f 100644
      --- a/rel/reltool.config.script
      +++ b/rel/reltool.config.script
      @@ -20,7 +20,9 @@ BaseAppsToRun = [compiler,
                        cowboy,
                        fusco,
                        folsom,
      -                 exometer],
      +                 exometer,
      +                 xmerl,
      +                 amqp_client],
      
       AppsToRunIn = BaseAppsToRun ++ proplists:get_value(apps_to_run, Conf, []),
      
      @@ -44,7 +46,9 @@ BaseAppsToInclude = AppsToRun ++
                            alarms,
                            idna,
                            recon,
      -                     setup
      +                     setup,
      +                     xmerl,
      +                     amqp_client
                            ],
      

      Please note that xmerl is a dependency of amqp_client, so also has to be added to the release.

    4. make rel to rebuild the release with amqp_client bundled with MongooseIM.
    5. Run the server (e.g. with bin/mongooseimctl live in mongooseim/rel/mongooseim directory) and verify that amqp_client is available and running:

      (mongooseim@localhost)1> application:which_applications().
      ... snipped ...
       {amqp_client,"RabbitMQ AMQP Client","3.5.1"},
       {xmerl,"XML parser","1.3.7"},
      ... snipped ...
      (mongooseim@localhost)2> amqp_client:start().             
      {error,{already_started,amqp_client}}
      

      (Don't mind the error, of course we want it to be started already.)

提交回复
热议问题