Skip to content

Commit 6deefa9

Browse files
feat(events): Added the exlusive connection rule
1 parent 71af745 commit 6deefa9

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
import amqp, { AmqpConnectionManager, Channel, ChannelWrapper } from 'amqp-connection-manager';
22
import logger from '@/core/utils/logger';
33

4-
type ConnectionType = 'publisher' | 'listener' | 'default';
5-
64
export { Channel, ChannelWrapper };
75

86
export class Connection {
9-
private static connections: Record<ConnectionType, AmqpConnectionManager | null> = {
10-
default: null,
11-
listener: null,
12-
publisher: null
13-
};
7+
private static connections: Record<string, AmqpConnectionManager | null> = {};
148

159
private constructor() {
1610
//
1711
}
1812

19-
private static createConnection(connectionType: ConnectionType = 'default'): AmqpConnectionManager {
13+
private static createConnection(connectionType: string = 'default'): AmqpConnectionManager {
2014
const connection = amqp.connect([process.env.APP_MQ!]);
2115

2216
connection.on('connect', () => {
@@ -32,7 +26,7 @@ export class Connection {
3226
return connection;
3327
}
3428

35-
static getConnection(connectionType: ConnectionType = 'default'): AmqpConnectionManager {
29+
static getConnection(connectionType: string = 'default'): AmqpConnectionManager {
3630
return this.connections[connectionType] ?? this.createConnection(connectionType);
3731
}
3832
}

src/core/infrastructure/events/Listener.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export abstract class Listener<T> implements ListenerContract {
1414
abstract topic: string;
1515
protected exclusiveConnection: boolean = false;
1616

17-
// FIXME: support exclusive connection per listener
1817
constructor() {
1918
this.connection = Connection.getConnection(this.connectionName);
2019
}

0 commit comments

Comments
 (0)