anigkus opened a new issue, #643:
URL: https://github.com/apache/rocketmq-spring/issues/643
* Validated
* Integration success version:
rocketmq-spring-boot-starte:[2.2.2、2.2.1、2.2.0、2.1.1]、spring-boot:3.2.3,
rocketmq server
version:[rocketmq-all-4.9.8-bin-release、rocketmq-all-5.1.4-bin-release].
* Integration fail version:
rocketmq-spring-boot-starte:[2.2.3、2.3.0]、spring-boot:3.2.3, rocketmq server
version:[rocketmq-all-4.9.8-bin-release、rocketmq-all-5.1.4-bin-release].
* Demo code:
```java
rocketmq:
name-server: 127.0.0.1:9876
producer:
group: PRODUCER_GROUP_MANAGER # Default: none
send-message-timeout: 10000 # Default: 3000s
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.stereotype.Component;
@Component
@Slf4j
@RocketMQMessageListener(topic = "TOPIC_MANAGER_SPRING_TEST", consumerGroup =
"SPRING_TOPIC_CONSUMER", messageModel = MessageModel.CLUSTERING)
public class StringConsumer1 implements RocketMQListener<String>,
RocketMQPushConsumerLifecycleListener {
@Override
public void onMessage(String message) {
log.info("------- StringConsumer1 received: {}", message);
}
@Override
public void prepareStart(DefaultMQPushConsumer defaultMQPushConsumer) {
defaultMQPushConsumer.setInstanceName("consumer1");
}
}
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@Slf4j
public class TestController {
@Resource
//@Autowired
private RocketMQTemplate rocketMQTemplate;
@GetMapping("/msg")
public void msg() {
rocketMQTemplate.send("TOPIC_MANAGER_SPRING_TEST", new
GenericMessage<String>(
"Hello async msg!")); //async send string
SendResult sendResult =
rocketMQTemplate.syncSend("TOPIC_MANAGER_SPRING_TEST", "Hello sync msg!");
//sync send
// string
log.info("syncSend to topic {} sendResult={}",
"TOPIC_MANAGER_SPRING_TEST", sendResult);
}
}
```
# fail rocketmq version
```xml
<!--
https://mvnrepository.com/artifact/org.apache.rocketmq/rocketmq-spring-boot-starter
-->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.3.0</version><!-- 2.2.3 -->
</dependency>
```
* Other
* After `2.3.0` the `@Import(RocketMQAutoConfiguration.class)` annotation
must be added to the start application class, otherwise `RocketMQTemplate` will
not be injected.
* In `2.2.2` and `2.2.1` version, If at startup show log warning, need add
`System.setProperty("rocketmq.client.logUseSlf4j", "true")`, but if contains
`2.2.0` and below and contains `2.3.0` and above, then no need.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]