mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 06:22:40 +00:00
fix broker queues and keys
This commit is contained in:
@@ -3,7 +3,10 @@ import { RabbitSubscribe } from '@mobicoop/message-broker-module';
|
||||
import { CommandBus } from '@nestjs/cqrs';
|
||||
import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command';
|
||||
import { Ad } from './ad.types';
|
||||
import { AD_CREATED_MESSAGE_HANDLER } from '@src/app.constants';
|
||||
import {
|
||||
AD_CREATED_MESSAGE_HANDLER,
|
||||
AD_CREATED_ROUTING_KEY,
|
||||
} from '@src/app.constants';
|
||||
|
||||
@Injectable()
|
||||
export class AdCreatedMessageHandler {
|
||||
@@ -11,23 +14,29 @@ export class AdCreatedMessageHandler {
|
||||
|
||||
@RabbitSubscribe({
|
||||
name: AD_CREATED_MESSAGE_HANDLER,
|
||||
routingKey: AD_CREATED_ROUTING_KEY,
|
||||
})
|
||||
public async adCreated(message: string) {
|
||||
const createdAd: Ad = JSON.parse(message);
|
||||
await this.commandBus.execute(
|
||||
new CreateAdCommand({
|
||||
id: createdAd.aggregateId,
|
||||
driver: createdAd.driver,
|
||||
passenger: createdAd.passenger,
|
||||
frequency: createdAd.frequency,
|
||||
fromDate: createdAd.fromDate,
|
||||
toDate: createdAd.toDate,
|
||||
schedule: createdAd.schedule,
|
||||
seatsProposed: createdAd.seatsProposed,
|
||||
seatsRequested: createdAd.seatsRequested,
|
||||
strict: createdAd.strict,
|
||||
waypoints: createdAd.waypoints,
|
||||
}),
|
||||
);
|
||||
try {
|
||||
const createdAd: Ad = JSON.parse(message);
|
||||
await this.commandBus.execute(
|
||||
new CreateAdCommand({
|
||||
id: createdAd.aggregateId,
|
||||
driver: createdAd.driver,
|
||||
passenger: createdAd.passenger,
|
||||
frequency: createdAd.frequency,
|
||||
fromDate: createdAd.fromDate,
|
||||
toDate: createdAd.toDate,
|
||||
schedule: createdAd.schedule,
|
||||
seatsProposed: createdAd.seatsProposed,
|
||||
seatsRequested: createdAd.seatsRequested,
|
||||
strict: createdAd.strict,
|
||||
waypoints: createdAd.waypoints,
|
||||
}),
|
||||
);
|
||||
} catch (error: any) {
|
||||
// do not throw error to acknowledge incoming message
|
||||
// error handling should be done in the command handler, if relevant
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,6 @@ import {
|
||||
AD_CREATED_MESSAGE_HANDLER,
|
||||
AD_CREATED_QUEUE,
|
||||
AD_CREATED_ROUTING_KEY,
|
||||
AD_DELETED_MESSAGE_HANDLER,
|
||||
AD_DELETED_QUEUE,
|
||||
AD_DELETED_ROUTING_KEY,
|
||||
AD_UPDATED_MESSAGE_HANDLER,
|
||||
AD_UPDATED_QUEUE,
|
||||
AD_UPDATED_ROUTING_KEY,
|
||||
SERVICE_NAME,
|
||||
} from '@src/app.constants';
|
||||
|
||||
@@ -39,14 +33,6 @@ const imports = [
|
||||
routingKey: AD_CREATED_ROUTING_KEY,
|
||||
queue: AD_CREATED_QUEUE,
|
||||
},
|
||||
[AD_UPDATED_MESSAGE_HANDLER]: {
|
||||
routingKey: AD_UPDATED_ROUTING_KEY,
|
||||
queue: AD_UPDATED_QUEUE,
|
||||
},
|
||||
[AD_DELETED_MESSAGE_HANDLER]: {
|
||||
routingKey: AD_DELETED_ROUTING_KEY,
|
||||
queue: AD_DELETED_QUEUE,
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user