Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rocketmq-spring-boot-starter 如何支持广播模式,尝试1天了还是不通;只能使用集群模式?怎么解决? #9046

Open
3 tasks done
jikuanyu opened this issue Dec 11, 2024 · 1 comment

Comments

@jikuanyu
Copy link

Before Creating the Bug Report

  • I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.

Runtime platform environment

Windows10

RocketMQ version

RocketMQ version5.0

JDK Version

jdk1.8

Describe the Bug

rocketmq-spring-boot-starter 调整广播模式无法接收消息。只有集群模式才能接收到消息。
因为是旧的项目我只能使用springboot2.1.x。

Steps to Reproduce

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @author yujikuan
 * @Classname SyncBookMqService
 * @Description 同步培优服务务
 * @Date 2024/12/10 15:59
 */
@Service
@Slf4j
@RocketMQMessageListener(topic = "nrms_qg_normal_topic",
        consumerGroup = "nrms_qg_group",
        accessKey = "${rocketmq.default.username}", secretKey = "${rocketmq.default.password}",
        selectorType = SelectorType.TAG
      //  ,messageModel = MessageModel.BROADCASTING
)
//接收消息
public class SyncBookMqService implements RocketMQListener<String> {
    @Override
    public void onMessage(String s) {
        log.info("接收到同步数据库消息:{}", s);
    }
}

//发送消息
    @GetMapping("send2")
    public ResponseEntity<ResponseWrapper> send2(String message) {

        log.info("message={}",message);
        org.springframework.messaging.Message msg = MessageBuilder.withPayload("rsend2 message " + message).build();
            String topic="nrms_qg_normal_topic";
            String tagId="syncBookDBOutputTag";

        rocketmqTemplate.send(topic +":"+tagId, msg);
        return WrapResponseMapper.ok();
    }

配置

rocketmq:
  name-server: ${rocketmq.default.address}
  producer:
    # 发送消息超时时间,默认3000
    sendMessageTimeout: 10000
    # 发送消息失败重试次数,默认2
    retryTimesWhenSendFailed: 2
    # 异步消息重试此处,默认2
    retryTimesWhenSendAsyncFailed: 2
    # 消息最大长度,默认1024 * 1024 * 4(默认4M)
    maxMessageSize: 40960
    # 压缩消息阈值,默认4k(1024 * 4)
    compressMessageBodyThreshold: 4096
    # 是否在内部发送失败时重试另一个broker,默认false
    retryNextServer: true
    access-key: ${rocketmq.default.username}
    secret-key: ${rocketmq.default.password}
    group: qqrms-res-producer-group
依赖
  <dependency>
        <groupId>org.apache.rocketmq</groupId>
        <artifactId>rocketmq-spring-boot-starter</artifactId>
        <version>2.1.1</version>
       <!--<exclusions>
            <exclusion>
                <artifactId>rocketmq-client</artifactId>
                <groupId>org.apache.rocketmq</groupId>
            </exclusion>
            <exclusion>
                <artifactId>rocketmq-common</artifactId>
                <groupId>org.apache.rocketmq</groupId>
            </exclusion>
            <exclusion>
                <artifactId>rocketmq-logging</artifactId>
                <groupId>org.apache.rocketmq</groupId>
            </exclusion>
            <exclusion>
                <artifactId>rocketmq-remoting</artifactId>
                <groupId>org.apache.rocketmq</groupId>
            </exclusion>
        </exclusions>-->
    </dependency>

What Did You Expect to See?

能够每一个服务实例都收到消息。

What Did You See Instead?

能够每一个服务实例都收到消息。

Additional Context

No response

@humkum
Copy link
Contributor

humkum commented Dec 16, 2024

image
Setting the messageModel as MessageModel.BROADCASTING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants