Skip to content

Commit c36096a

Browse files
committed
[ISSUE #583]: 新增 RocketMQMessageHandler 和 RocketMQMessagePostProcessor
- 新增 RocketMQMessageHandler 用户处理消息前预处理,可用于处理链路追踪 - 新增 RocketMQMessagePostProcessor 类,用于处理消息发送前预处理消息,用来传递链路ID
1 parent a7092e1 commit c36096a

File tree

5 files changed

+65
-32
lines changed

5 files changed

+65
-32
lines changed
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.apache.rocketmq.spring.support;
218

319
import org.apache.rocketmq.common.message.MessageExt;
420

5-
/**
6-
* 云路供应链科技有限公司 版权所有 © Copyright 2020
7-
*
8-
* @Description:
9-
* @Author: 梁建军
10-
* @Date: 2025-06-27 18:02
11-
*/
1221
public interface RocketMQMessageHandlerChain {
1322
void doHandler(MessageExt message) throws Exception;
1423
}

rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQMessageHandlerTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.apache.rocketmq.spring.support;
218

319
import org.apache.rocketmq.common.message.MessageExt;
@@ -11,13 +27,6 @@
1127

1228
import static org.junit.jupiter.api.Assertions.assertEquals;
1329

14-
/**
15-
* 云路供应链科技有限公司 版权所有 © Copyright 2020
16-
*
17-
* @Description:
18-
* @Author: 梁建军
19-
* @Date: 2025-06-27 20:02
20-
*/
2130
public class RocketMQMessageHandlerTest {
2231

2332
@Test

rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/RocketMQMessagePostProcessorTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.apache.rocketmq.spring.support;
218

319
import org.apache.rocketmq.client.exception.MQBrokerException;
@@ -18,13 +34,6 @@
1834
import static org.assertj.core.api.Assertions.assertThat;
1935
import static org.junit.jupiter.api.Assertions.assertEquals;
2036

21-
/**
22-
* 云路供应链科技有限公司 版权所有 © Copyright 2020
23-
*
24-
* @Description:
25-
* @Author: 梁建军
26-
* @Date: 2025-06-27 19:48
27-
*/
2837
public class RocketMQMessagePostProcessorTest {
2938

3039
@Test

rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/support/RocketMQMessageHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
import org.apache.rocketmq.client.apis.consumer.ConsumeResult;
2121
import org.apache.rocketmq.client.apis.message.MessageView;
2222

23-
/**
24-
* 消息处理
25-
*/
2623
public interface RocketMQMessageHandler {
2724

28-
ConsumeResult doHandler(MessageView message, RocketMQMessageHandlerChain chain);
25+
ConsumeResult doHandler(MessageView message, RocketMQMessageHandlerChain consumer);
2926

3027
}
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.apache.rocketmq.client.support;
218

319
import org.apache.rocketmq.client.apis.consumer.ConsumeResult;
420
import org.apache.rocketmq.client.apis.message.MessageView;
521

6-
/**
7-
* 云路供应链科技有限公司 版权所有 © Copyright 2020
8-
*
9-
* @Description:
10-
* @Author: 梁建军
11-
* @Date: 2025-06-27 18:02
12-
*/
1322
public interface RocketMQMessageHandlerChain {
1423
ConsumeResult doHandler(MessageView message);
1524
}

0 commit comments

Comments
 (0)