2017-09-19 5 views
1

同じメッセージを読んで、私は機能春カフカ・リスナー|私は、ユーザーIDが削除されますトピック名「ユーザー」を持っている

私は同じトピックを指している2人のリスナーを持って読みたい
1. process user leave data 
2. process user salary data 

以下でこのトピックやプロセスから読みたいです同じユーザーIDを使用して処理を並行して開始します。 processPayRollはすべての時間を呼び出さなっている -

@KafkaListener(topics = "${kafka.topic.user}",group="abc")) 
      public void receive(String message) { 

        userService.processLeave(message); 
       } 

@KafkaListener(topics = "${kafka.topic.user}",group="abc1")) 
      public void receive1(String message) { 

        userService.processPayRoll(message); 
       } 

はなく、すべての時間、私はそれを参照してください。

何が欠けていますか?

答えて

1

古いSpring Kafkaバージョンを使用しているようです。

残念ながら、groupは消費者のgroup.idとは関係ありません。 ライフサイクル管理のためにはcontainerGroupです。

別のコンシューマ設定に基づいて異なるKafkaMessageListenerContainerを設定することを検討する必要があります。そして、あなたはすでに異なったConsumerConfig.GROUP_ID_CONFIGを設定します。

最新バージョンがあり@KafkaListener構造のように:1.3.0.RC1のリリース候補は、春のマイルストーンレポで利用できるようになりました

/** 
* If provided, the listener container for this listener will be added to a bean 
* with this value as its name, of type {@code Collection<MessageListenerContainer>}. 
* This allows, for example, iteration over the collection to start/stop a subset 
* of containers. 
* @return the bean name for the group. 
*/ 
String containerGroup() default ""; 

/** 
* Override the {@code group.id} property for the consumer factory with this value 
* for this listener only. 
* @return the group id. 
* @since 1.3 
*/ 
String groupId() default ""; 

/** 
* When {@link #groupId() groupId} is not provided, use the {@link #id() id} (if 
* provided) as the {@code group.id} property for the consumer. Set to false, to use 
* the {@code group.id} from the consumer factory. 
* @return false to disable. 
* @since 1.3 
*/ 
boolean idIsGroup() default true; 
+0

。このリリースは今月末近くに予定されています。 –

関連する問題