diff --git a/src/readers/queryService.ts b/src/readers/queryService.ts index 1f5fe970dfd3fc5fe1a479a4e3db5b1f9853b267..984bbc37294088849261beb29750441af76d6bd1 100644 --- a/src/readers/queryService.ts +++ b/src/readers/queryService.ts @@ -78,8 +78,6 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu } log.info('Starting query reader for', type); - const publisher = new QueryPublisher(frontendPublisher, mlPublisher); - const queryServiceConsumer = await new RabbitMqBroker( rabbitMq, 'requests-exchange', @@ -90,6 +88,8 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu log.info('Connected to RabbitMQ ST!'); await queryServiceConsumer.startConsuming<QueryRequest>('query-service', async (message, headers) => { + const publisher = new QueryPublisher(frontendPublisher, mlPublisher, headers); + const startTime = Date.now(); const ss = await ums.getUserSaveState(headers.message.sessionData.userID, message.saveStateID); @@ -107,7 +107,6 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu return; } - publisher.withHeaders(headers).withRoutingKey(headers.routingKey).withQueryID(headers.callID); publisher.publishStatusToFrontend('Received'); if (ss == null || ss.dbConnections == null || ss.dbConnections[0] == null || ss.dbConnections.length === 0) { diff --git a/src/utils/queryPublisher.ts b/src/utils/queryPublisher.ts index ca17e2f169c136a5f7f73df401a68fe086749eb0..03e0737a668fc05a1df2aaa80406de63ad573084 100644 --- a/src/utils/queryPublisher.ts +++ b/src/utils/queryPublisher.ts @@ -10,24 +10,12 @@ export class QueryPublisher { private headers?: BackendMessageHeader; private queryID?: string; - constructor(frontendPublisher: RabbitMqBroker, mlPublisher: RabbitMqBroker) { + constructor(frontendPublisher: RabbitMqBroker, mlPublisher: RabbitMqBroker, headers: BackendMessageHeader) { this.frontendPublisher = frontendPublisher; this.mlPublisher = mlPublisher; - } - - withHeaders(headers?: BackendMessageHeader) { this.headers = headers; - return this; - } - - withRoutingKey(routingKey?: string) { - this.routingKey = routingKey; - return this; - } - - withQueryID(queryID?: string) { - this.queryID = queryID; - return this; + this.routingKey = headers.routingKey; + this.queryID = headers.callID; // FIXME: WTF? } publishStatusToFrontend(status: string) {