Skip to content

feat: RocketMQReplyListener Is it possible to allow returning null and not reply if returning null? the user is responsible for the consequences. #474

@no-today

Description

@no-today

The issue tracker is ONLY used for bug report and feature request.

Any question or RocketMQ proposal please use our mailing lists.

FEATURE REQUEST

  1. Please describe the feature you are requesting.

RocketMQReplyListener Is it possible to allow returning null and not reply if returning null? the user is responsible for the consequences.

Just check for null:

DefaultRocketMQListenerContainer.java:452

Object replyContent = rocketMQReplyListener.onMessage(doConvertMessage(messageExt));
// if null, no reply
if (replyContent == null) return;
Message<?> message = MessageBuilder.withPayload(replyContent).build();

  1. Provide any additional detail on your proposed use case for this feature.

I use RocketMQ to decouple the long-connection gateway (access layer) and microservices (business logic layer).

In the gateway cluster scenario, the server calls the client, which I use sendAndReceive + RocketMQReplyListener(broadcast consumption) to achieve;

If the target client has established a connection with the current node, process and return the result, otherwise discard the message and return null.

Broadcast consumption expects at most one non-null response. The solution works fine, but the consumer that returns null will have an error prompt.

java.lang.IllegalArgumentException: Payload must not be null

RocketMQReplyListener 是否可以允许返回 null 并且返回 null 就不应答了?即使报错,也只是由使用者承担后果。
我使用 RocketMQ 解耦长连接网关(接入层)和微服务(业务逻辑层)。
网关集群场景下,服务端调用客户端,我使用 sendAndReceive + RocketMQReplyListener(广播消费) 来实现。
如果目标客户端与当前节点建立了连接,则处理并返回结果,否则丢弃消息返回 null。
广播消费预期最多只会有一条非空应答。该方案可以正常工作,但是返回 null 的消费会出现报错信息。

  1. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue?

should-have

I don't expect to see error messages, too many

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions