You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
|
2 years ago
|
package com.bx.imclient.task;
|
||
|
|
|
||
|
|
import cn.hutool.core.util.StrUtil;
|
||
|
|
import com.alibaba.fastjson.JSONObject;
|
||
|
|
import com.bx.imclient.listener.MessageListenerMulticaster;
|
||
|
|
import com.bx.imcommon.contant.IMRedisKey;
|
||
|
|
import com.bx.imcommon.enums.IMListenerType;
|
||
|
|
import com.bx.imcommon.model.IMSendResult;
|
||
|
|
import com.bx.imcommon.mq.RedisMQConsumer;
|
||
|
|
import com.bx.imcommon.mq.RedisMQListener;
|
||
|
|
import com.bx.imcommon.mq.RedisMQTemplate;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.util.LinkedList;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Objects;
|
||
|
|
|
||
|
|
@Slf4j
|
||
|
|
@Component
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@RedisMQListener(queue = IMRedisKey.IM_RESULT_SYSTEM_QUEUE, batchSize = 100, period = 100)
|
||
|
|
public class SystemMessageResultResultTask extends RedisMQConsumer<IMSendResult> {
|
||
|
|
|
||
|
|
@Value("${spring.application.name}")
|
||
|
|
private String appName;
|
||
|
|
|
||
|
|
private final MessageListenerMulticaster listenerMulticaster;
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onMessage(List<IMSendResult> results) {
|
||
|
|
listenerMulticaster.multicast(IMListenerType.SYSTEM_MESSAGE, results);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String generateKey() {
|
||
|
|
return StrUtil.join(":", IMRedisKey.IM_RESULT_SYSTEM_QUEUE, appName);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|