G2P Registry Datashare: RabbitMQ
Last updated
Was this helpful?
Last updated
Was this helpful?
g2p_registry_datashare_rabbitmq
G2P Registry Datashare: RabbitMQ
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.
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.
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 a pika
-based connection to RabbitMQ.
publish(data)
serializes and sends the transformed data as a JSON message to the configured exchange/routing key.
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.
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
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}
filter to apply to the outgoing data.