Skip to main content
The Mensageria connects to three systems. Lerian STA carries the files to and from BACEN. The Streaming Hub delivers the execution notices to the executor. The executor calls the Mensageria’s execution API to get each order and report its result. The Mensageria calls no ledger.

Lerian STA


The Mensageria consumes the topic lerian.streaming.br-sta, which Lerian STA produces. It registers six event types:
  • br_sta_transfers.accepted
  • br_sta_transfers.rejected
  • br_sta_transfers.inconsistent
  • br_sta_transfers.canceled
  • br_sta_transfers.download_finished
  • br_sta_transfers.download_not_authorized
The Mensageria keeps the events whose source_product matches its STA_SOURCE_PRODUCT setting. It ignores the events of other products. The direction field of each event selects the pipeline. One direction is a file that Lerian STA downloaded for the Mensageria. The other is the outcome of a response file that the Mensageria submitted. The database also refuses a second remittance file with the same SHA-256 digest for the same institution. With STA_TRANSFERS_ENABLED on, the Mensageria submits each response file to Lerian STA. How Lerian SISBAJUD works describes the submission.

Dead-lettered events

A Lerian STA event that the Mensageria refuses goes to the topic lerian.streaming.br-sisbajud.dlq. The record carries a reason token, for example institution_unresolved or sha256_mismatch. POST /v1/institutions/{institutionId}/sta-dlq/{eventId}/acknowledge records what an operator did with one dead-lettered event: replayed, recorded, or escalated. It writes an audit record. It does not remove the event, and the topic keeps the event for its retention period. To replay an event, move the consumer group back to the source offset that the record headers name.

Streaming Hub and the executor


The Mensageria publishes the execution notices and the probes on lerian.streaming.br-sisbajud. The Streaming Hub delivers them to the executor by webhook. An operator creates one Streaming Hub subscription for the executor. The subscription lists exactly two event types: judicial_order.execution_requested and sisbajud_probe.requested. The Streaming Hub signs each delivery with the secret of the subscription. The executor verifies that signature. It runs each delivery under its own tenant and does not use the tenant header of the delivery. Do not rely on the arrival order of execution notices. The Mensageria keeps the order of releases for a subject in its database.

Execution API


The executor reads orders and reports results through the execution API. These operations are not in the Mensageria API reference. The execution API has its own listener at SISBAJUD_EXECUTION_ADDRESS. The default is :4032. The main API at SERVER_ADDRESS does not serve these paths. The execution listener accepts TLS 1.2 or later and has no plain HTTP mode. SISBAJUD_EXECUTION_TLS_CERT_FILE and SISBAJUD_EXECUTION_TLS_KEY_FILE hold the server certificate and key. SISBAJUD_EXECUTION_MTLS_ENABLED turns on mutual TLS. Then the listener requires a client certificate that SISBAJUD_EXECUTION_CLIENT_CA_FILE verifies. The executor has its own switch, MENSAGERIA_MTLS_ENABLED. Set both switches to the same value. With mutual TLS on the Mensageria and off on the executor, the TLS handshake fails. The executor authenticates with an M2M bearer token. Its client holds the role br-sisbajud-executor-role, which grants the three permissions in the table. The Mensageria takes the identity and the role from the token only. The client certificate does not change authorization.

Canary probe

Every EXECUTION_CANARY_INTERVAL_SEC seconds, the Mensageria publishes one sisbajud_probe.requested event for each enabled institution. The default is 300. The executor answers with POST /v1/sisbajud/execution/probes/{probeId}. Enable an institution on the Mensageria when an executor serves that institution.

Events


The Mensageria publishes three event types on the topic lerian.streaming.br-sisbajud.
  • The operation of an execution notice is REQUISICAO_INFORMACAO, BLOQUEIO, or DESBLOQUEIO.
  • The Mensageria publishes kek.rotated when an operator rotates an institution’s KEK with HashiCorp Vault as the key provider.
  • The ce-type header is studio.lerian.br-sisbajud.<resource>.<event>, for example studio.lerian.br-sisbajud.kek.rotated.
  • The ce-schemaversion header carries the schema version.
  • The dead-letter topic of kek.rotated is lerian.streaming.br-sisbajud.dlq.

Topics

With STREAMING_TOPIC_AUTO_PROVISION at its default, true, the Mensageria creates lerian.streaming.br-sisbajud and lerian.streaming.br-sisbajud.dlq at startup. Its broker identity needs permission to create these topics. If you create the topics before you deploy, set STREAMING_TOPIC_AUTO_PROVISION to false.