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

Commit cfb6a42d authored by zhanggb's avatar zhanggb

~consumer:+listener;

parent dc7b1baf
...@@ -120,7 +120,7 @@ public class ConsumerCommonBizRedisStreamConfig extends RedisStreamConfig { ...@@ -120,7 +120,7 @@ public class ConsumerCommonBizRedisStreamConfig extends RedisStreamConfig {
List<Subscription> subscriptionList = new ArrayList<>(); List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GoblinQueue stream = MQConst.GoblinQueue.BIZ_ARTWORK_GEN; MQConst.GoblinQueue stream = MQConst.GoblinQueue.BIZ_ARTWORK_GEN;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup()); this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 1; i++) { for (int i = 0; i < 5; i++) {
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory); StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory);
subscriptionList.add(listenerContainer.receiveAutoAck( subscriptionList.add(listenerContainer.receiveAutoAck(
Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)), Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)),
......
...@@ -86,7 +86,7 @@ public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig { ...@@ -86,7 +86,7 @@ public class ConsumerCommonSqlRedisStreamConfig extends RedisStreamConfig {
List<Subscription> subscriptionList = new ArrayList<>(); List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GoblinQueue stream = MQConst.GoblinQueue.SQL_ARTWORK_GEN; MQConst.GoblinQueue stream = MQConst.GoblinQueue.SQL_ARTWORK_GEN;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup()); this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 1; i++) { for (int i = 0; i < 5; i++) {
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory); StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory);
subscriptionList.add(listenerContainer.receiveAutoAck( subscriptionList.add(listenerContainer.receiveAutoAck(
Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)), Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)),
......
...@@ -12,37 +12,43 @@ import org.springframework.data.redis.connection.stream.Consumer; ...@@ -12,37 +12,43 @@ import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord; import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset; import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset; 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.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription; import org.springframework.data.redis.stream.Subscription;
import java.util.ArrayList;
import java.util.List;
@Configuration @Configuration
public class ConsumerGoblinOrderCRedisStreamConfig extends RedisStreamConfig { public class ConsumerGoblinOrderCRedisStreamConfig extends RedisStreamConfig {
@Autowired
StringRedisTemplate stringRedisTemplate;
@Autowired @Autowired
ConsumerGoblinOrderCloseRdsReceiver consumerGoblinOrderCloseRdsReceiver; ConsumerGoblinOrderCloseRdsReceiver consumerGoblinOrderCloseRdsReceiver;
/** // /**
* 缺票登记 // * 缺票登记
* // *
* @param listenerContainer // * @param listenerContainer
* @param t // * @param t
* @return // * @return
*/ // */
private Subscription receiveGoblinOrderCOrder(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) { // private Subscription receiveGoblinOrderCOrder(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(Consumer.from(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.getGroup(), getConsumerName(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.name() + t)), // return listenerContainer.receiveAutoAck(Consumer.from(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.getGroup(), getConsumerName(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.name() + t)),
StreamOffset.create(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.getKey(), ReadOffset.lastConsumed()), consumerGoblinOrderCloseRdsReceiver); // StreamOffset.create(MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE.getKey(), ReadOffset.lastConsumed()), consumerGoblinOrderCloseRdsReceiver);
} // }
//
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */ // /* —————————————————————————— | —————————————————————————— | —————————————————————————— */
//
/* -------------------------------------------------------- | 缺票登记 */ // /* -------------------------------------------------------- | 缺票登记 */
//
@Bean // @Bean
public Subscription subscriptionGoblinOrderC0(RedisConnectionFactory factory) { // public Subscription subscriptionGoblinOrderC0(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory); // var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveGoblinOrderCOrder(listenerContainer, 0); // var subscription = receiveGoblinOrderCOrder(listenerContainer, 0);
listenerContainer.start(); // listenerContainer.start();
return subscription; // return subscription;
} // }
// @Bean // @Bean
// public Subscription subscriptionGoblinOrderC1(RedisConnectionFactory factory) { // public Subscription subscriptionGoblinOrderC1(RedisConnectionFactory factory) {
...@@ -60,7 +66,21 @@ public class ConsumerGoblinOrderCRedisStreamConfig extends RedisStreamConfig { ...@@ -60,7 +66,21 @@ public class ConsumerGoblinOrderCRedisStreamConfig extends RedisStreamConfig {
// return subscription; // return subscription;
// } // }
/* -------------------------------------------------------- | */ /* -------------------------------------------------------- | */
@Bean//
public List<Subscription> subscriptionSqlArtworkGen(RedisConnectionFactory factory) {
List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GoblinQueue stream = MQConst.GoblinQueue.GOBLIN_ORDER_CLOSE;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 5; 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()), consumerGoblinOrderCloseRdsReceiver
));
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