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

Commit 0b5650b8 authored by anjiabin's avatar anjiabin

迁移NFT-sql消费

parent a9e6e471
......@@ -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.ConsumerCommonSQL0Receiver;
import com.liquidnet.service.consumer.base.receiver.ConsumerGoblinNftOrderRdsReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -31,6 +32,9 @@ public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
@Autowired
ConsumerCommonSQL0Receiver consumerCommonSQL0Receiver;
@Autowired
ConsumerGoblinNftOrderRdsReceiver consumerGoblinNftOrderRdsReceiver;
// @Bean
// public List<Subscription> subscriptionSQL0(RedisConnectionFactory factory) {
// List<Subscription> subscriptionList = new ArrayList<>();
......@@ -46,4 +50,20 @@ public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
// }
// return subscriptionList;
// }
@Bean// goblin NFT订单
public List<Subscription> subscriptionSqlNftOrder(RedisConnectionFactory factory) {
List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GoblinQueue stream = MQConst.GoblinQueue.GOBLIN_NFT_ORDER;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 20; 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()), consumerGoblinNftOrderRdsReceiver
));
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 ConsumerGoblinNftOrderRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.GoblinQueue.GOBLIN_NFT_ORDER.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GoblinQueue.GOBLIN_NFT_ORDER.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