记得上下班打卡 | git大法好,push需谨慎

Commit 2a711542 authored by zhanggb's avatar zhanggb

~queue:consumer-base.+biz_nft_mongo;

parent 0b5650b8
......@@ -3,6 +3,7 @@ package com.liquidnet.service.consumer.base.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.base.receiver.ConsumerCommonMDB0Receiver;
import com.liquidnet.service.consumer.base.receiver.ConsumerGoblinBizNftMongoReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -30,6 +31,8 @@ public class ConsumerCommonMdbRedisStreamConfig extends RedisStreamConfig {
StringRedisTemplate stringRedisTemplate;
@Autowired
ConsumerCommonMDB0Receiver consumerCommonMDB0Receiver;
@Autowired
ConsumerGoblinBizNftMongoReceiver consumerGoblinBizNftMongoReceiver;
// @Bean
// public List<Subscription> subscriptionMDB0(RedisConnectionFactory factory) {
......@@ -46,4 +49,21 @@ public class ConsumerCommonMdbRedisStreamConfig extends RedisStreamConfig {
// }
// return subscriptionList;
// }
@Bean// NFT:Mongo操作
public List<Subscription> subscriptionGoblinBizNftMongo(RedisConnectionFactory factory) {
List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GoblinQueue stream = MQConst.GoblinQueue.BIZ_NFT_MONGO;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 3; i++) {
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory);
subscriptionList.add(listenerContainer.receiveAutoAck(
Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)),
StreamOffset.create(stream.getKey(), ReadOffset.lastConsumed()), consumerGoblinBizNftMongoReceiver
));
listenerContainer.start();
}
return subscriptionList;
}
}
package com.liquidnet.service.consumer.base.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerGoblinBizNftMongoReceiver extends AbstractMdbRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.GoblinQueue.BIZ_NFT_MONGO.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GoblinQueue.BIZ_NFT_MONGO.getGroup();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment