Skip to content

ImagLend — Eventos

Proposito

ImagLend utiliza RabbitMQ para comunicacion asincrona con otros dominios. Publica eventos cuando ocurren cambios significativos en el ciclo de vida de creditos y consume eventos de dominios externos para reaccionar a validaciones y firmas.

Configuracion de Exchange

PropiedadValor
Exchangeimagy.events
Tipotopic
Durabletrue
Auto-deletefalse

Eventos Producidos

lending.application.created

Se publica cuando una solicitud de credito es enviada (estado submitted).

Routing Key: lending.application.created

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440001",
  "event_type": "lending.application.created",
  "timestamp": "2026-05-18T10:30:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "application_id": "app-uuid-001",
    "product_id": "prod-uuid-001",
    "product_code": "microcredito-30d",
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890",
      "first_name": "Juan",
      "last_name": "Perez",
      "email": "juan@example.com"
    },
    "amount": 300000,
    "currency": "COP",
    "term_days": 30,
    "origin": {
      "type": "flow",
      "channel": "digital"
    },
    "status": "submitted"
  }
}

Consumidores: ImagID (actualiza historial del sujeto)


lending.application.decided

Se publica cuando una solicitud es aprobada o rechazada.

Routing Key: lending.application.decided

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440002",
  "event_type": "lending.application.decided",
  "timestamp": "2026-05-18T11:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "application_id": "app-uuid-001",
    "product_id": "prod-uuid-001",
    "decision": "approved",
    "decided_by": "operator-uuid-001",
    "decided_at": "2026-05-18T11:00:00Z",
    "conditions": {
      "approved_amount": 300000,
      "approved_term_days": 30
    },
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890"
    }
  }
}

Consumidores: ImagID, Notificaciones


lending.credit.disbursed

Se publica cuando un credito es desembolsado exitosamente.

Routing Key: lending.credit.disbursed

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440003",
  "event_type": "lending.credit.disbursed",
  "timestamp": "2026-05-18T12:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "credit_id": "credit-uuid-001",
    "application_id": "app-uuid-001",
    "product_id": "prod-uuid-001",
    "amount": 300000,
    "currency": "COP",
    "term_days": 30,
    "interest_rate": 0.076,
    "total_to_pay": 348500,
    "disbursement": {
      "id": "disb-uuid-001",
      "method": "bank_transfer",
      "reference": "TXN-2026051812345",
      "disbursed_at": "2026-05-18T12:00:00Z"
    },
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890"
    },
    "first_due_date": "2026-06-17"
  }
}

Consumidores: ImagID (registra credito activo en perfil del sujeto)


lending.payment.received

Se publica cuando se registra un pago confirmado.

Routing Key: lending.payment.received

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440004",
  "event_type": "lending.payment.received",
  "timestamp": "2026-06-17T10:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "payment_id": "pay-uuid-001",
    "credit_id": "credit-uuid-001",
    "amount": 348500,
    "currency": "COP",
    "payment_type": "installment",
    "installment_number": 1,
    "reference": "PAY-2026061700001",
    "payment_date": "2026-06-17T10:00:00Z",
    "credit_status_after": "paid_off",
    "remaining_balance": 0,
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890"
    }
  }
}

Consumidores: ImagID (actualiza historial de pagos del sujeto)


lending.credit.defaulted

Se publica cuando un credito entra en estado de mora.

Routing Key: lending.credit.defaulted

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440005",
  "event_type": "lending.credit.defaulted",
  "timestamp": "2026-07-20T00:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "credit_id": "credit-uuid-001",
    "product_id": "prod-uuid-001",
    "days_past_due": 33,
    "overdue_amount": 348500,
    "currency": "COP",
    "overdue_installments": [1],
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890"
    },
    "defaulted_at": "2026-07-20T00:00:00Z"
  }
}

Consumidores: ImagID (marca mora en perfil), ImagGuard (alertas)


lending.credit.paid_off

Se publica cuando un credito se paga completamente.

Routing Key: lending.credit.paid_off

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440006",
  "event_type": "lending.credit.paid_off",
  "timestamp": "2026-06-17T10:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "credit_id": "credit-uuid-001",
    "application_id": "app-uuid-001",
    "product_id": "prod-uuid-001",
    "original_amount": 300000,
    "total_paid": 348500,
    "currency": "COP",
    "paid_off_at": "2026-06-17T10:00:00Z",
    "subject": {
      "document_type": "cc",
      "document_number": "1234567890"
    }
  }
}

Consumidores: ImagID (actualiza perfil crediticio)


lending.product.created

Se publica cuando un producto de credito es creado y activado.

Routing Key: lending.product.created

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440007",
  "event_type": "lending.product.created",
  "timestamp": "2026-05-18T10:30:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "product_id": "prod-uuid-001",
    "code": "microcredito-30d",
    "name": "Microcredito 30 dias",
    "category": "microcredito",
    "currency": "COP",
    "created_by": "admin-uuid-001"
  }
}

Consumidores: Audit


lending.product.updated

Se publica cuando un producto de credito es modificado.

Routing Key: lending.product.updated

Payload:

json
{
  "event_id": "evt-550e8400-e29b-41d4-a716-446655440008",
  "event_type": "lending.product.updated",
  "timestamp": "2026-05-18T14:30:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "product_id": "prod-uuid-001",
    "code": "microcredito-30d",
    "changes": {
      "rate_config.rate": {
        "before": 0.076,
        "after": 0.082
      }
    },
    "change_request_id": "cr-uuid-001",
    "approved_by": "admin-uuid-002"
  }
}

Consumidores: Audit


Eventos Consumidos

flow.execution.completed

Publicado por ImagFlow cuando un flujo de validacion termina exitosamente.

Routing Key: flow.execution.completed

Queue: imaglend.flow.execution.completed

Payload esperado:

json
{
  "event_id": "evt-flow-001",
  "event_type": "flow.execution.completed",
  "timestamp": "2026-05-18T10:35:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "execution_id": "exec-uuid-001",
    "flow_id": "flow-uuid-001",
    "flow_name": "Validacion Identidad Credito",
    "result": "approved",
    "details": {
      "identity_score": 0.95,
      "bureau_score": 720,
      "liveness_passed": true
    },
    "completed_at": "2026-05-18T10:35:00Z"
  }
}

Logica del consumidor:

  1. Buscar credit_application por flow_execution_id = execution_id
  2. Si result = "approved": actualizar estado de validacion a passed
  3. Si result = "rejected": actualizar estado de validacion a failed
  4. Registrar en processed_events para idempotencia

flow.execution.failed

Publicado por ImagFlow cuando un flujo de validacion falla.

Routing Key: flow.execution.failed

Queue: imaglend.flow.execution.failed

Payload esperado:

json
{
  "event_id": "evt-flow-002",
  "event_type": "flow.execution.failed",
  "timestamp": "2026-05-18T10:35:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "execution_id": "exec-uuid-001",
    "flow_id": "flow-uuid-001",
    "reason": "identity_mismatch",
    "details": {
      "identity_score": 0.32,
      "threshold": 0.70
    },
    "failed_at": "2026-05-18T10:35:00Z"
  }
}

Logica del consumidor:

  1. Buscar credit_application por flow_execution_id
  2. Actualizar estado a rejected con razon validation_failed
  3. Registrar en processed_events

sign.signature.completed

Publicado por ImagSign cuando una firma se completa.

Routing Key: sign.signature.completed

Queue: imaglend.sign.signature.completed

Payload esperado:

json
{
  "event_id": "evt-sign-001",
  "event_type": "sign.signature.completed",
  "timestamp": "2026-05-18T10:40:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "signature_id": "sig-uuid-001",
    "document_type": "credit_contract",
    "signer": {
      "document_number": "1234567890",
      "name": "Juan Perez"
    },
    "signed_at": "2026-05-18T10:40:00Z",
    "document_hash": "sha256:abc123def456..."
  }
}

Logica del consumidor:

  1. Buscar credit_application por signature_id
  2. Marcar firma como completada
  3. Actualizar signature_status = "completed"
  4. Registrar en processed_events

subject.profile.blacklisted

Publicado por ImagID cuando un sujeto es agregado a lista negra.

Routing Key: subject.profile.blacklisted

Queue: imaglend.subject.profile.blacklisted

Payload esperado:

json
{
  "event_id": "evt-subj-001",
  "event_type": "subject.profile.blacklisted",
  "timestamp": "2026-05-18T15:00:00Z",
  "tenant_id": "tenant-uuid-001",
  "data": {
    "subject_id": "subj-uuid-001",
    "document_type": "cc",
    "document_number": "1234567890",
    "reason": "fraud_detected",
    "blacklisted_at": "2026-05-18T15:00:00Z"
  }
}

Logica del consumidor:

  1. Buscar solicitudes pendientes del sujeto (por document_number)
  2. Rechazar todas las solicitudes en estado draft o submitted
  3. Registrar razon: subject_blacklisted
  4. Registrar en processed_events

Queues y Bindings

QueueRouting KeyConsumidor
imaglend.flow.execution.completedflow.execution.completedApplicationValidationConsumer
imaglend.flow.execution.failedflow.execution.failedApplicationValidationConsumer
imaglend.sign.signature.completedsign.signature.completedSignatureConsumer
imaglend.subject.profile.blacklistedsubject.profile.blacklistedBlacklistConsumer

Todas las queues son durables con dead-letter exchange configurado:

PropiedadValor
Durabletrue
Dead Letter Exchangeimagy.events.dlx
Dead Letter Routing Key{original_routing_key}.dlq
Message TTL86400000 ms (24h)
Max retries3

Diagrama de Integracion

Garantias

GarantiaImplementacion
At-least-once deliveryACK manual despues de procesar
IdempotenciaTabla processed_events con event_id unico
OrdenNo garantizado - cada evento es independiente
Reintentos3 intentos con backoff exponencial
Dead letterEventos fallidos van a DLQ para revision manual
Trazabilidadevent_id y X-Request-Id en todos los mensajes

Reimagine Tech LLC — Documentacion Interna