File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ export class KafkaProducerManager {
10
10
timeout
11
11
)
12
12
if ( ! kafkaInstance . isConnected ) await kafkaInstance . connect ( )
13
- if ( ! kafkaInstance . isConnected )
14
- throw new Error ( 'Kafka Producer failed to connect.' )
15
13
16
14
return kafkaInstance . producer
17
15
}
@@ -20,7 +18,7 @@ export class KafkaProducerManager {
20
18
let kafkaInstance = this . getKafkaInstance ( channelName , clientId , timeout )
21
19
if ( ! kafkaInstance ) {
22
20
kafkaInstance = new KafkaProducer ( clientId , timeout )
23
- this . kafkaSet [ `${ channelName } ${ clientId } ${ timeout } ` ] = kafkaInstance
21
+ this . kafkaSet [ `urn: ${ channelName } : ${ clientId } : ${ timeout } ` ] = kafkaInstance
24
22
}
25
23
26
24
return kafkaInstance
@@ -31,11 +29,11 @@ export class KafkaProducerManager {
31
29
32
30
if ( kafkaInstance ) {
33
31
if ( kafkaInstance . isConnected ) await kafkaInstance . disconnect ( )
34
- delete this . kafkaSet [ `${ channelName } ${ clientId } ${ timeout } ` ]
32
+ delete this . kafkaSet [ `urn: ${ channelName } : ${ clientId } : ${ timeout } ` ]
35
33
}
36
34
}
37
35
38
36
static getKafkaInstance ( channelName , clientId , timeout ) {
39
- return this . kafkaSet [ `${ channelName } ${ clientId } ${ timeout } ` ]
37
+ return this . kafkaSet [ `urn: ${ channelName } : ${ clientId } : ${ timeout } ` ]
40
38
}
41
39
}
Original file line number Diff line number Diff line change @@ -244,13 +244,14 @@ ChannelSchema.pre('save', async function (next) {
244
244
}
245
245
] )
246
246
247
+ let originalKafkaItem
247
248
// We need to cross reference the original, not-yet modified, routes
248
249
// against the incoming dirty routes to see if any were removed and if so remove them from the manager
249
250
if ( Array . isArray ( originalKafkaDetails ) )
250
- originalKafkaDetails = originalKafkaDetails [ 0 ]
251
- if ( originalKafkaDetails && originalKafkaDetails . routes . length > 0 ) {
252
- for ( let route of originalKafkaDetails . routes ) {
253
- const isTimeoutUpdated = originalKafkaDetails . timeout !== this . timeout
251
+ originalKafkaItem = originalKafkaDetails [ 0 ]
252
+ if ( originalKafkaItem && originalKafkaItem . routes . length > 0 ) {
253
+ for ( let route of originalKafkaItem . routes ) {
254
+ const isTimeoutUpdated = originalKafkaItem . timeout !== this . timeout
254
255
const matchingRoute = kafkaRoutes . find (
255
256
e => e . kafkaClientId === route . kafkaClientId && e . name === route . name
256
257
)
@@ -263,7 +264,7 @@ ChannelSchema.pre('save', async function (next) {
263
264
// if timeout is null on the original document, it was set to the default
264
265
// so pull that out from the config before trying to remove connections
265
266
const originalTimeout =
266
- originalKafkaDetails . timeout ?? + config . router . timeout
267
+ originalKafkaItem . timeout ?? + config . router . timeout
267
268
await KafkaProducerManager . removeConnection (
268
269
this . name ,
269
270
route . kafkaClientId ,
You can’t perform that action at this time.
0 commit comments