mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
refactor: ( payment ) use rabbitmq for webhooks event
This commit is contained in:
23
apps/edr-payment-api/src/config/rabbitmq.config.ts
Normal file
23
apps/edr-payment-api/src/config/rabbitmq.config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { registerAs } from "@nestjs/config";
|
||||
|
||||
/**
|
||||
* RabbitMQ connection for the outbox event publisher (payment -> apps).
|
||||
* `publisherTransport` selects which PaymentEventPublisher the outbox relay uses:
|
||||
* "rabbitmq" -> RabbitMqPaymentEventPublisher (publish to the payment.events exchange) [DEFAULT]
|
||||
* "http" -> HttpPaymentEventPublisher (POST to each app's mark-paid endpoint) [rollback]
|
||||
* RabbitMQ is the default; set PUBLISHER_TRANSPORT=http explicitly to fall back to HTTP.
|
||||
*/
|
||||
export default registerAs("rabbitmq", () => ({
|
||||
url: process.env.PAYMENT_RABBITMQ_URL ?? "amqp://localhost:5672/payment",
|
||||
publisherTransport: (process.env.PUBLISHER_TRANSPORT ?? "rabbitmq").toLowerCase(),
|
||||
/** Publish is failed (so the relay retries) if the broker does not confirm within this. */
|
||||
publishTimeoutMs: parseInt(process.env.PAYMENT_PUBLISH_TIMEOUT_MS ?? "10000", 10),
|
||||
}));
|
||||
|
||||
/**
|
||||
* True when the outbox relay should publish to RabbitMQ rather than POST over HTTP.
|
||||
* RabbitMQ is the default; only an explicit PUBLISHER_TRANSPORT=http opts out.
|
||||
*/
|
||||
export function isRabbitPublisher(): boolean {
|
||||
return (process.env.PUBLISHER_TRANSPORT ?? "rabbitmq").toLowerCase() !== "http";
|
||||
}
|
||||
Reference in New Issue
Block a user