Skip to content

Commit

Permalink
Merge pull request #1988 from hashgraph/feature/fix-duplicate-transac…
Browse files Browse the repository at this point in the history
…tion-logs

fix transaction logs
  • Loading branch information
artembuslaev authored Apr 6, 2023
2 parents 93c1022 + 6df254d commit a66fef8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions common/src/mq/message-broker-channel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import assert from 'assert';
import { Subscription, NatsConnection, StringCodec, connect, JSONCodec, headers } from 'nats';
import { Subscription, NatsConnection, StringCodec, connect, headers } from 'nats';
import { IMessageResponse, MessageError } from '../models/message-response';
import { GenerateUUIDv4 } from '@guardian/interfaces';
import { ZipCodec } from './zip-codec';

const MQ_TIMEOUT = 300000;
/**
Expand Down Expand Up @@ -258,15 +259,15 @@ export class MessageBrokerChannel {
* @param data
* @param allowError
*/
public publish<T>(eventType: string, data: T, allowError = true) {
public async publish<T>(eventType: string, data: T, allowError = true) {
try {
console.log('MQ publish: %s', eventType);
const messageId = GenerateUUIDv4();
const head = headers();
head.append('messageId', messageId);

const sc = JSONCodec();
this.channel.publish(eventType, sc.encode(data), { headers: head });
const zc = ZipCodec();
this.channel.publish(eventType, await zc.encode(data), { headers: head });
} catch (e) {

console.error(e.message, e.stack, e);
Expand Down
2 changes: 1 addition & 1 deletion guardian-service/src/hedera-modules/transaction-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class TransactionLogger extends NatsService {
})

return new MessageResponse({});
});
}, true);
}

/**
Expand Down

0 comments on commit a66fef8

Please sign in to comment.