Install events-into-rabbitmq
plugin into headless wallet
Goal
This article will guide you to install the events-into-rabbitmq
plugin into Hathor headless wallet.
The events-into-rabbitmq
plugin is part of the external notification feature. To know more about this feature, see Hathor external notifications.
Requirement
Hathor headless wallet v0.19.0
Step-by-step
- Install dependency.
- Configure and enable the plugin.
Step 1: install dependency
- Source code
- Docker container
- Docker compose
- Open the command line from the directory where you installed Hathor headless wallet.
- Run the command to install the dependencies:
npm install amqplib@^0.10.3
If you installed Hathor headless wallet as a Docker container, you must build a new Docker image, with the installed dependencies. The image that Hathor Labs provides at Docker Hub does not come with the installed dependencies for this plugin:
- Open the command line from the directory where you installed Hathor headless wallet.
- Create a new empty
Dockerfile
file and write in it just the following lines:
FROM hathornetwork/hathor-wallet-headless
RUN npm install amqplib@^0.10.3
- Build a new Docker image, based in the
Dockerfile
you created in the previous substep:
docker build --file Dockerfile .
At the end of this step, you will have built a new Docker image.
If you installed Hathor headless wallet along Hathor full node with Docker compose, you must build a new Docker image, with the installed dependencies. The image that Hathor Labs provides at Docker Hub does not come with the installed dependencies for this plugin:
- Open the command line from the directory where you installed Hathor headless wallet.
- Create a new empty
Dockerfile
file and write in it just the following lines:
FROM hathornetwork/hathor-wallet-headless
RUN npm install amqplib@^0.10.3
- Build a new Docker image, based in the
Dockerfile
you created in the previous substep:
docker build --file Dockerfile .
At the end of this step, you will have built a new Docker image.
Step 2: configure and enable the plugin
- Source code
- Docker container
- Docker compose
If you installed Hathor headless wallet from source code, you must modify both the src/config.js
file and the command to start the application, to respectively enable and configure the plugin:
- Open the command line from the directory where you installed Hathor headless wallet.
- Open the
src/config.js
file. - Add
'rabbitmq'
to the array of values of theenabled_plugins
property to enable the plugin.
If you are enabling multiple plugins, value shall be an array of plugin ids: enabled_plugins: ['PluginId1', 'PluginId2', ...]
.
At the end of this substep, the config.js
file will be as follows:
module.exports = {
...
enabled_plugins: ['rabbitmq'],
plugin_config: {},
...
};
-
Append the
--plugin_rabbitmq_queue <queue_name>
parameter into the command to start the wallet application, replacing the<queue_name>
placeholder with the RabbitMQ queue name. -
Append the
--plugin_rabbitmq_url <queue_url>
parameter into the command to start the wallet application, replacing the<queue_url>
placeholder with the RabbitMQ queue URL.
At the end of this substep, the command to start the wallet application will be as follows:
At the end of this step, the config.js
file will be as follows:
npm start -- --plugin_rabbitmq_queue <queue_name> --plugin_rabbitmq_url <queue_url>
If you installed Hathor headless wallet as a Docker container, you must add parameters to the docker run
command to enable and configure the plugin:
- Append
--enabled_plugins='rabbitmq'
to thedocker run
command.
If you are enabling multiple plugins, parameter value shall be an array of plugin ids: --enabled_plugins='PluginId1 PluginId2 ...'
.
-
Append
--plugin_rabbitmq_queue=<queue_name>
, replacing the<queue_name>
placeholder with the RabbitMQ queue name. -
Append
--plugin_rabbitmq_url=<queue_url>
, replacing the<queue_url>
placeholder with the URL of the RabbitMQ queue URL. -
Use the Docker image you built in the previous step, replacing the
<docker_image_id>
placeholder with its image id.
At the end of this step, the command to start the wallet application will be as follows:
docker run \
-it -p 8000:8000 \
<docker_image_id> \
--seed_default '<24_words_seed_phrase_string>' \
--network mainnet \
--server https://node2.mainnet.hathor.network/v1a/ \
--enabled_plugins='rabbitmq' \
--plugin_rabbitmq_queue=<queue_name> \
--plugin_rabbitmq_url=<queue_url>
If you installed Hathor headless wallet along Hathor full node with Docker compose, you must add new lines to the docker-compose.yml
file to enable and configure the plugin:
- Open the command line from the directory where you installed Hathor headless wallet.
- Open the
docker-compose.yml
file. - At the end of the list of items within
environment
, fromhathor-wallet-headless
, add the key/value pairHEADLESS_ENABLED_PLUGINS=rabbitmq
.
If you are enabling multiple plugins, value shall be an array of plugin ids: HEADLESS_ENABLED_PLUGINS=PluginId1 PluginId2
.
-
At the end of the list of items within
environment
, fromhathor-wallet-headless
, add the key/value pairHEADLESS_PLUGIN_RABBITMQ_QUEUE=<queue_name>
, replacing the<queue_name>
placeholder with the RabbitMQ queue name. -
At the end of the list of items within
environment
, fromhathor-wallet-headless
, add the key/value pairHEADLESS_PLUGIN_RABBITMQ_URL=<queue_url>
, replacing the<queue_url>
placeholder with the URL of the RabbitMQ queue URL. -
Use the Docker image you built in the previous step, replacing the
<docker_image_id>
placeholder with its image id, as the value of the image key withinhathor-wallet-headless
.
At the end of this step, the docker-compose.yml
file will be as follows:
hathor-core:
...
hathor-wallet-headless:
image: <docker_image_id>
...
environment:
- HEADLESS_SEED_DEFAULT=<24_words_seed_phrase_string>
- HEADLESS_NETWORK=testnet
- HEADLESS_SERVER=http://hathor-core:8080/v1a/
- HEADLESS_ENABLED_PLUGINS=rabbitmq
- HEADLESS_PLUGIN_RABBITMQ_QUEUE=<queue_name>
- HEADLESS_PLUGIN_RABBITMQ_URL=<queue_url>
Task completed
You have installed the events-into-rabbitmq
plugin in your instance of Hathor headless wallet.
The events-into-rabbitmq
plugin is part of the external notification feature. To know how to use this plugin or install other plugins of this feature, see Hathor external notifications.