GitHub user Gonzo-Tan added a comment to the discussion: the expected type is 
FIFO, but actual type is NORMAL BROKER

查看方式:在控制台的 tipic 页面下,选择 FIFO 类型的消息进行过滤,就可以看到对应的 topic 了。
![image](https://github.com/apache/rocketmq-clients/assets/13795914/bdc33daa-4e30-447a-8cba-6b4df2fd98e4)

但在你的第一张截图左上角里面,我看到你选中了普通消息,不确定是否也勾选了 FIFO 类型,这个你自己可以确认一下,如果没有,则说明这个 topic 不是 
FIFO 类型的。


关于你的这个问题,从你的异常日志里面输出的异常堆栈信息,可以看到你使用的是 remoting 协议的 sdk,同时,你的接入点(也就是配置里面的 name 
server 地址)应该是 proxy 地址。

我大概验证了一下,确实跟你出现了相同的错误,排查后发现是 proxy 当中这部分代码:
``` java
protected RemotingCommand sendMessage(ChannelHandlerContext ctx, 
RemotingCommand request,
        ProxyContext context) throws Exception {
        SendMessageRequestHeader requestHeader = 
SendMessageRequestHeader.parseRequestHeader(request);
        String topic = requestHeader.getTopic();
        Map<String, String> property = 
MessageDecoder.string2messageProperties(requestHeader.getProperties());
        // 这里获取到消息的类型
        TopicMessageType messageType = 
TopicMessageType.parseFromMessageProperty(property);
        if 
(ConfigurationManager.getProxyConfig().isEnableTopicMessageTypeCheck()) {
            if (topicMessageTypeValidator != null) {
                // Do not check retry or dlq topic
                if (!NamespaceUtil.isRetryTopic(topic) && 
!NamespaceUtil.isDLQTopic(topic)) {
                    TopicMessageType topicMessageType = 
messagingProcessor.getMetadataService().getTopicMessageType(context, topic);
                    // 这一步校验出错了
                    topicMessageTypeValidator.validate(topicMessageType, 
messageType);
                }
            }
        }

       ......
    }
```

其中获取消息类型的代码:
``` java
public static TopicMessageType parseFromMessageProperty(Map<String, String> 
messageProperty) {
        String isTrans = 
messageProperty.get(MessageConst.PROPERTY_TRANSACTION_PREPARED);
        String isTransValue = "true";
        if (isTransValue.equals(isTrans)) {
            return TopicMessageType.TRANSACTION;
        } else if (messageProperty.get(MessageConst.PROPERTY_DELAY_TIME_LEVEL) 
!= null
            || messageProperty.get(MessageConst.PROPERTY_TIMER_DELIVER_MS) != 
null
            || messageProperty.get(MessageConst.PROPERTY_TIMER_DELAY_SEC) != 
null
            || messageProperty.get(MessageConst.PROPERTY_TIMER_DELAY_MS) != 
null) {
            return TopicMessageType.DELAY;
        } else if (messageProperty.get(MessageConst.PROPERTY_SHARDING_KEY) != 
null) {
            // 通过判断是有这个属性来确定是 FIFO 类型
            return TopicMessageType.FIFO;
        }
        return TopicMessageType.NORMAL;
    }
```

大概整理一下思路:
由于使用的是 remoting sdk 对接 proxy,proxy 内部会做消息和 topic 的强校验,是通过 message properties 
来判断的。
但 remoting sdk 当中未设置该属性,所以校验不通过。

我不确定是不是个 bug,这个需要官方的人来回答了。我这边有临时的解决方案:
1. 消息发送时主动设置 property 来通过这个校验
``` java
msg.putUserProperty("__SHARDINGKEY", 分组 key);
```
2. 使用 grpc sdk 发送顺序消息。


GitHub link: 
https://github.com/apache/rocketmq-clients/discussions/785#discussioncomment-9963836

----
This is an automatically sent email for dev@rocketmq.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@rocketmq.apache.org

Reply via email to