@@ -24,6 +24,8 @@ import {
2424 ConsumerGroupJoinEvent
2525} from '../external/kafka.interface' ;
2626import { KafkaHeaders } from '../enums' ;
27+ import { InvalidKafkaClientTopicException } from '../errors/invalid-kafka-client-topic.exception' ;
28+ import { InvalidKafkaClientTopicPartitionException } from '../errors/invalid-kafka-client-topic-partition.exception' ;
2729
2830let kafkaPackage : any = { } ;
2931
@@ -201,39 +203,17 @@ export class ClientKafka extends ClientProxy {
201203 }
202204
203205 private getReplyPartition ( topic : string ) : string {
204- // this.consumer.describeGroup().then((description) => {
205- // // this.logger.error(util.format('getReplyTopicPartition(): groupDescription: %o', description));
206-
207- // description.members.forEach((member) => {
208- // const memberMetadata = kafkaPackage.AssignerProtocol.MemberMetadata.decode(member.memberMetadata);
209- // const memberAssignment = kafkaPackage.AssignerProtocol.MemberAssignment.decode(member.memberAssignment);
210-
211- // // this.logger.error(util.format('getReplyTopicPartition(): groupDescription.member[i]: %o', member));
212- // this.logger.error(util.format('getReplyTopicPartition(): memberId: %s metadata: %o', member.memberId, {
213- // topics: memberMetadata.topics,
214- // userData: memberMetadata.userData.toString()
215- // }));
216-
217- // this.logger.error(util.format('getReplyTopicPartition(): memberId: %s assignment: %o', member.memberId, {
218- // assignment: memberAssignment.assignment,
219- // userData: memberAssignment.userData.toString()
220- // }));
221- // });
222- // });
223-
224- // return 0;
225-
226206 // get topic assignment
227207 const topicAssignments = this . consumerAssignments [ topic ] ;
228208
229209 // throw error
230210 if ( isUndefined ( topicAssignments ) ) {
231- throw new Error ( `Unable to send the message request because the client consumer is not subscribed to the topic ( ${ topic } ).` ) ;
211+ throw new InvalidKafkaClientTopicException ( topic ) ;
232212 }
233213
234214 // if the current member isn't listening to any partitions on the topic then throw an error.
235215 if ( isUndefined ( topicAssignments [ 0 ] ) ) {
236- throw new Error ( `Unable to send the message request because the client consumer subscribed to the topic ( ${ topic } ) is not assigned any partitions.` ) ;
216+ throw new InvalidKafkaClientTopicPartitionException ( topic ) ;
237217 }
238218
239219 return topicAssignments [ 0 ] . toString ( ) ;
@@ -272,7 +252,7 @@ export class ClientKafka extends ClientProxy {
272252 this . routingMap . delete ( packet . id ) ;
273253 } ;
274254 } catch ( err ) {
275- this . logger . error ( err ) ;
255+ callback ( { err } ) ;
276256 }
277257 }
278258}
0 commit comments