Skip to content
Snippets Groups Projects
Verified Commit 064a7af7 authored by Dennis Collaris's avatar Dennis Collaris
Browse files

fix: create new querypublisher for each message

Every user was using the same global queryPublisher, with the risk of one users message setting headers
that were then used for another users response.
parent 5dacd895
Branches test/insightsPopulateTemplate
No related tags found
1 merge request!32fix: create new querypublisher for each message
Pipeline #146019 passed
......@@ -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) {
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment