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
| Propiedad | Valor |
|---|---|
| Exchange | imagy.events |
| Tipo | topic |
| Durable | true |
| Auto-delete | false |
Eventos Producidos
lending.application.created
Se publica cuando una solicitud de credito es enviada (estado submitted).
Routing Key: lending.application.created
Payload:
{
"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:
{
"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:
{
"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:
{
"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:
{
"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:
{
"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:
{
"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:
{
"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:
{
"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:
- Buscar
credit_applicationporflow_execution_id = execution_id - Si
result = "approved": actualizar estado de validacion apassed - Si
result = "rejected": actualizar estado de validacion afailed - Registrar en
processed_eventspara 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:
{
"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:
- Buscar
credit_applicationporflow_execution_id - Actualizar estado a
rejectedcon razonvalidation_failed - 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:
{
"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:
- Buscar
credit_applicationporsignature_id - Marcar firma como completada
- Actualizar
signature_status = "completed" - 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:
{
"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:
- Buscar solicitudes pendientes del sujeto (por document_number)
- Rechazar todas las solicitudes en estado
draftosubmitted - Registrar razon:
subject_blacklisted - Registrar en
processed_events
Queues y Bindings
| Queue | Routing Key | Consumidor |
|---|---|---|
imaglend.flow.execution.completed | flow.execution.completed | ApplicationValidationConsumer |
imaglend.flow.execution.failed | flow.execution.failed | ApplicationValidationConsumer |
imaglend.sign.signature.completed | sign.signature.completed | SignatureConsumer |
imaglend.subject.profile.blacklisted | subject.profile.blacklisted | BlacklistConsumer |
Todas las queues son durables con dead-letter exchange configurado:
| Propiedad | Valor |
|---|---|
| Durable | true |
| Dead Letter Exchange | imagy.events.dlx |
| Dead Letter Routing Key | {original_routing_key}.dlq |
| Message TTL | 86400000 ms (24h) |
| Max retries | 3 |
Diagrama de Integracion
Garantias
| Garantia | Implementacion |
|---|---|
| At-least-once delivery | ACK manual despues de procesar |
| Idempotencia | Tabla processed_events con event_id unico |
| Orden | No garantizado - cada evento es independiente |
| Reintentos | 3 intentos con backoff exponencial |
| Dead letter | Eventos fallidos van a DLQ para revision manual |
| Trazabilidad | event_id y X-Request-Id en todos los mensajes |