G2P Registry Datashare: RabbitMQ
Module name
g2p_registry_datashare_rabbitmq
Module title
G2P Registry Datashare: RabbitMQ
Technology base
Functionality
This module enables real-time data publishing from the Social Registry (res.partner
model) to external systems via RabbitMQ. It is designed to:
Push Data on Change: Automatically sends registrant data to RabbitMQ upon creation or update.
JQ-Based Transformation: Applies a configurable JQ expression to format data before publishing.
Multiple Configurations: Supports multiple RabbitMQ configurations to publish data to different exchanges and routing keys.
Design notes
The core purpose of this module is to facilitate flexible data exchange from the Social Registry to external systems through RabbitMQ. This is achieved via the g2p.datashare.config.rabbitmq
model, which defines:
Connection parameters to RabbitMQ.
Routing settings (exchange, routing key).
Optional JQ expressions for data transformation.
The use of JQ expressions enables dynamic construction and filtering of outgoing payloads, tailored to downstream consumer requirements. Configurations can be toggled as active/inactive, allowing runtime control over which pipelines are enabled.
Model: g2p.datashare.config.rabbitmq
g2p.datashare.config.rabbitmq
Stores connection details, routing settings, and transformation logic.
JQ transformation is applied via the
jq
Python library, using a default of{}
._connect_to_rabbitmq()
establishes apika
-based connection to RabbitMQ.publish(data)
serializes and sends the transformed data as a JSON message to the configured exchange/routing key.
Model Extension: res.partner
res.partner
_push_to_rabbitmq()
is invoked on creation and write operations.It filters to only publish data for registrants (
is_registrant=True
).It loops through all active configs with
data_source = "registry"
, transforms data using the configured JQ expression, and publishes it.
Configuration
Create a rabbitMQ configuration record under
Settings
>RabbitMQ Datashare
page.General config properties:
Name
name
Name of the config.
Data Source
data_source
Source from which data will be shared
Active
active
Toggle to enable/disable the config
Host
host
RabbitMQ server address
Port
port
The TCP port number RabbitMQ is listening on (default is 5672).
Username
username
RabbitMQ credentials
Password
password
RabbitMQ credentials
VHost
vhost
Virtual host
Exchange Name
exchange
Name of the exchange to publish to
Routing Key
routing_key
Routing key used for message delivery
ID type
id_type
Select the ID Type that should be used in the data payload
Transform Data JQ
transform_data_jq
Jq filter to apply to the outgoing data.
If you want to reference the ID configured in the id_type
field, use the reg_id_value
variable in your JQ expression.
example:
{"nationalID": .reg_id_value}
Source code
Last updated
Was this helpful?