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

Commit b671bff0 authored by 胡佳晨's avatar 胡佳晨

merchant 第三方相关消费

parent 5dcc2df7
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerMerchantLineRdsReceiver;
import lombok.var;
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.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
@Configuration
public class ConsumerMerchantLineRedisStreamConfig {
@Autowired
ConsumerMerchantLineRdsReceiver consumerMerchantLineRdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 验票更新
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveTransferResult(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.MerchantQueue.SQL_MERCHANT_LINE.getGroup(), MQConst.MerchantQueue.SQL_MERCHANT_LINE.name() + t),
StreamOffset.create(MQConst.MerchantQueue.SQL_MERCHANT_LINE.getKey(), ReadOffset.lastConsumed()), consumerMerchantLineRdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 验票更新 */
@Bean
public Subscription subscriptionReceiveLine1(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveLine2(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveLine3(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveLine4(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 4);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveLine5(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 5);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerMerchantPerformaneInsertRdsReceiver;
import lombok.var;
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.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
@Configuration
public class ConsumerMerchantPerformanceInsertRedisStreamConfig {
@Autowired
ConsumerMerchantPerformaneInsertRdsReceiver consumerMerchantPerformaneInsertRdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 验票更新
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveTransferResult(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_INSERT.getGroup(), MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_INSERT.name() + t),
StreamOffset.create(MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_INSERT.getKey(), ReadOffset.lastConsumed()), consumerMerchantPerformaneInsertRdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 验票更新 */
@Bean
public Subscription subscriptionReceivePInsert1(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePInsert2(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePInsert3(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePInsert4(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 4);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePInsert5(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 5);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerMerchantPerformanceRdsReceiver;
import lombok.var;
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.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
import static com.liquidnet.service.base.constant.MQConst.KylinQueue.SQL_TRANSFER_RESULT;
@Configuration
public class ConsumerMerchantPerformanceRedisStreamConfig {
@Autowired
ConsumerMerchantPerformanceRdsReceiver consumerMerchantPerformanceRdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 验票更新
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveTransferResult(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_UPDATE.getGroup(), MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_UPDATE.name() + t),
StreamOffset.create(MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_UPDATE.getKey(), ReadOffset.lastConsumed()), consumerMerchantPerformanceRdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 验票更新 */
@Bean
public Subscription subscriptionReceivePerformance1(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePerformance2(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePerformance3(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePerformance4(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 4);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceivePerformance5(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 5);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerMerchantStep2RdsReceiver;
import lombok.var;
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.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
import static com.liquidnet.service.base.constant.MQConst.KylinQueue.SQL_TRANSFER_RESULT;
@Configuration
public class ConsumerMerchantStep2RedisStreamConfig {
@Autowired
ConsumerMerchantStep2RdsReceiver consumerMerchantStep2RdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 验票更新
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveTransferResult(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.MerchantQueue.SQL_MERCHANT_STEP2.getGroup(), MQConst.MerchantQueue.SQL_MERCHANT_STEP2.name() + t),
StreamOffset.create(MQConst.MerchantQueue.SQL_MERCHANT_STEP2.getKey(), ReadOffset.lastConsumed()), consumerMerchantStep2RdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 验票更新 */
@Bean
public Subscription subscriptionReceiveStep21(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveStep22(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveStep23(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveStep24(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 4);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveStep25(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 5);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerMerchantTicketRdsReceiver;
import lombok.var;
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.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
import static com.liquidnet.service.base.constant.MQConst.KylinQueue.SQL_TRANSFER_RESULT;
@Configuration
public class ConsumerMerchantTicketRedisStreamConfig {
@Autowired
ConsumerMerchantTicketRdsReceiver consumerMerchantTicketRdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 验票更新
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveTransferResult(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.MerchantQueue.SQL_MERCHANT_TICKET_UPDATE.getGroup(), MQConst.MerchantQueue.SQL_MERCHANT_TICKET_UPDATE.name() + t),
StreamOffset.create(MQConst.MerchantQueue.SQL_MERCHANT_TICKET_UPDATE.getKey(), ReadOffset.lastConsumed()), consumerMerchantTicketRdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 验票更新 */
@Bean
public Subscription subscriptionReceiveTicket1(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveTicket2(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveTicket3(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveTicket4(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 4);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionReceiveTicket5(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveTransferResult(listenerContainer, 5);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerMerchantLineRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.MerchantQueue.SQL_MERCHANT_LINE.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.MerchantQueue.SQL_MERCHANT_LINE.getGroup();
}
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerMerchantPerformanceRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_UPDATE.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_UPDATE.getGroup();
}
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerMerchantPerformaneInsertRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_INSERT.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.MerchantQueue.SQL_MERCHANT_PERFORMANCE_INSERT.getGroup();
}
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerMerchantStep2RdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.MerchantQueue.SQL_MERCHANT_STEP2.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.MerchantQueue.SQL_MERCHANT_STEP2.getGroup();
}
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerMerchantTicketRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.MerchantQueue.SQL_MERCHANT_TICKET_UPDATE.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.MerchantQueue.SQL_MERCHANT_TICKET_UPDATE.getGroup();
}
}
XADD merchant:stream:rk.sql.field * 0 0 XADD merchant:stream:rk.sql.field * 0 0
XGROUP CREATE merchant:stream:rk.sql.field group.sql.field 0 XGROUP CREATE merchant:stream:rk.sql.field group.sql.field 0
XADD merchant:stream:rk.ticket XADD merchant:stream:rk.ticket * 0 0
XGROUP CREATE merchant:stream:rk.ticket group.ticket 0 XGROUP CREATE merchant:stream:rk.ticket group.ticket 0
XADD merchant:stream:rk.performance XADD merchant:stream:rk.performance * 0 0
XGROUP CREATE merchant:stream:rk.performance group.performance 0 XGROUP CREATE merchant:stream:rk.performance group.performance 0
XADD merchant:stream:rk.performance.step2 XADD merchant:stream:rk.performance.step2 * 0 0
XGROUP CREATE merchant:stream:rk.performance.step2 group.performance.step2 0 XGROUP CREATE merchant:stream:rk.performance.step2 group.performance.step2 0
XADD merchant:stream:rk.any.line XADD merchant:stream:rk.any.line * 0 0
XGROUP CREATE merchant:stream:rk.any.line group.any.line 0 XGROUP CREATE merchant:stream:rk.any.line group.any.line 0
XADD merchant:stream:rk.performance.insert XADD merchant:stream:rk.performance.insert * 0 0
XGROUP CREATE merchant:stream:rk.performance.insert group.performance.insert 0 XGROUP CREATE merchant:stream:rk.performance.insert group.performance.insert 0
\ No newline at end of file
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