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

Commit 7b6cc0ae authored by anjiabin's avatar anjiabin

nft-sql队列迁移

parent 35a8f441
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;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.util.ArrayList;
import java.util.List;
/**
* 公共的SQL队列消息消费器初始化配置
......@@ -19,6 +32,30 @@ public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
@Autowired
ConsumerCommonSQL0Receiver consumerCommonSQL0Receiver;
@Autowired
ConsumerGoblinNftOrderRdsReceiver consumerGoblinNftOrderRdsReceiver;
/**
* goblinNFT订单
* @param factory
* @return
*/
@Bean// 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;
}
// @Bean
// public List<Subscription> subscriptionSQL0(RedisConnectionFactory factory) {
// List<Subscription> subscriptionList = new ArrayList<>();
......
package com.liquidnet.service.consumer.nft.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.nft.receiver.ConsumerGoblinNftOrderRdsReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
@Autowired
StringRedisTemplate stringRedisTemplate;
@Autowired
ConsumerGoblinNftOrderRdsReceiver consumerGoblinNftOrderRdsReceiver;
@Bean// 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.nft.config;
//
//import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
//import com.liquidnet.service.base.constant.MQConst;
//import com.liquidnet.service.consumer.nft.receiver.ConsumerGoblinNftOrderRdsReceiver;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.stream.Consumer;
//import org.springframework.data.redis.connection.stream.MapRecord;
//import org.springframework.data.redis.connection.stream.ReadOffset;
//import org.springframework.data.redis.connection.stream.StreamOffset;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.stream.StreamMessageListenerContainer;
//import org.springframework.data.redis.stream.Subscription;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@Configuration
//public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
// @Autowired
// StringRedisTemplate stringRedisTemplate;
// @Autowired
// ConsumerGoblinNftOrderRdsReceiver consumerGoblinNftOrderRdsReceiver;
//
// @Bean// 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;
// }
//}
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