Update rabbitmq topic config and CLI template
This commit is contained in:
parent
3d0dbd694b
commit
d5484b074b
|
|
@ -6,6 +6,8 @@ export const getRabbitMQOptions = (queueName: string, url?: string): Microservic
|
||||||
options: {
|
options: {
|
||||||
urls: [url || process.env.RABBITMQ_URL || 'amqp://localhost:5672'],
|
urls: [url || process.env.RABBITMQ_URL || 'amqp://localhost:5672'],
|
||||||
queue: queueName,
|
queue: queueName,
|
||||||
|
exchange: 'system_events',
|
||||||
|
exchangeType: 'topic',
|
||||||
queueOptions: {
|
queueOptions: {
|
||||||
durable: true, // Черга не зникає при перезавантаженні RabbitMQ
|
durable: true, // Черга не зникає при перезавантаженні RabbitMQ
|
||||||
},
|
},
|
||||||
|
|
@ -13,3 +15,18 @@ export const getRabbitMQOptions = (queueName: string, url?: string): Microservic
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRabbitMQClientOptions = (url?: string) => {
|
||||||
|
return {
|
||||||
|
transport: Transport.RMQ as const,
|
||||||
|
options: {
|
||||||
|
urls: [url || process.env.RABBITMQ_URL || 'amqp://localhost:5672'],
|
||||||
|
queue: 'core_queue',
|
||||||
|
exchange: 'system_events',
|
||||||
|
exchangeType: 'topic',
|
||||||
|
queueOptions: {
|
||||||
|
durable: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -232,9 +232,9 @@ bootstrap();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
relativePath: 'backend/src/app.module.ts',
|
relativePath: 'backend/src/app.module.ts',
|
||||||
content: `import { CoreService } from 'erp-plugin-sdk';
|
content: `import { CoreService, getRabbitMQClientOptions } from 'erp-plugin-sdk';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ClientsModule, Transport } from '@nestjs/microservices';
|
import { ClientsModule } from '@nestjs/microservices';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { PingController } from './ping.controller';
|
import { PingController } from './ping.controller';
|
||||||
|
|
||||||
|
|
@ -243,14 +243,7 @@ import { PingController } from './ping.controller';
|
||||||
ClientsModule.register([
|
ClientsModule.register([
|
||||||
{
|
{
|
||||||
name: 'RABBITMQ_CLIENT',
|
name: 'RABBITMQ_CLIENT',
|
||||||
transport: Transport.RMQ,
|
...getRabbitMQClientOptions(),
|
||||||
options: {
|
|
||||||
urls: [process.env.RABBITMQ_URL || 'amqp://localhost:5672'],
|
|
||||||
queue: 'core_queue',
|
|
||||||
queueOptions: {
|
|
||||||
durable: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue