As Rabbit doensn't support content-based routing natively, this service can be used to use content-based routing.
The service connects to a queue and parses the incoming messages.
Based on the root-tag in the message, the message gets published with a new routing key.
The new routing key is <original routing key>.<root tag of the message>
.
Currently only XML messages are supported and only the root tag gets parsed.
The input queue and output exchange are configured in config.yml
.
- Git
- Docker
- Python 3.6+
- Access to the meemoo PyPi
-
Clone this repository with:
$ git clone https://github.com/viaacode/amqp-content-router.git
-
Change into the new directory.
-
Set the needed config:
Included in this repository is a
config.yml.example
file. All values in the config have to be set in order for the application to function correctly. You can use!ENV ${EXAMPLE}
as a config value to make the application get theEXAMPLE
environment variable.
Note: As per the aforementioned requirements, this is a Python3
application. Check your Python version with python --version
. You may want to
substitute the python
command below with python3
and if your Python version
is < 3.
-
Start by creating a virtual environment:
$ python -m venv env
-
Activate the virtual environment:
$ source env/bin/activate
-
Install the external modules:
$ pip install -r requirements.txt \ --extra-index-url http://do-prd-mvn-01.do.viaa.be:8081/repository/pypi-all/simple \ --trusted-host do-prd-mvn-01.do.viaa.be
-
Run the tests with:
$ pytest -v
-
Run the application:
$ python main.py
-
Build the container:
$ docker build -t amqp-content-router .
-
Run the container (with specified
.env
file):$ docker run --env-file .env amqp-content-router:latest