AVP42 opened a new issue #2330:
URL: https://github.com/apache/rocketmq/issues/2330
**BUG REPORT**
1. Please describe the issue you observed:
- What did you do (The steps to reproduce)?
Trying to use SendMessageHook to add user-define properties in order to pass
them on to their consumers.
- What did you expect to see?
Consumers should be able to get those user-define properties from each
"MessageExt".
- What did you see instead?
It doesn't work when using **batch message**
the following code is the "sendMessageBefore" implementation of
SendMessageHook
`
public void sendMessageBefore(SendMessageContext context) {
// neither of the following approaches work when message is actually
MessageBatch
// 1. using contextProps
Map<String, String> currentPorps = context.getProps();
if (currentPorps == null) {
currentPorps = new HashMap<>();
}
currentPorps.put("key", "value");
context.setProps(currentPorps);
// 2. using userProperty
context.getMessage().putUserProperty("key", "value");
// 3. using userProperty for each message
if (context.getMessage() instanceof MessageBatch) {
for (Message message : (MessageBatch) context.getMessage()) {
message.putUserProperty("key", "value");
}
}
}
`
2. Please tell us about your environment:
rocketmq-all-4.7.0-release
3. Other information (e.g. detailed explanation, logs, related issues,
suggestions how to fix, etc):
It seems like property in the "MessageExtBatch" will not be handled in
method
"org.apache.rocketmq.store.CommitLog.DefaultAppendMessageCallback#doAppend(long,
java.nio.ByteBuffer, int, org.apache.rocketmq.common.message.MessageExtBatch)"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]