You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/02/23 11:42:08 UTC
[GitHub] [rocketmq] i757 opened a new issue #2691: application.yml文件中为通道配置的生产者属性没有加载到ExtendedProducerProperties里面
i757 opened a new issue #2691:
URL: https://github.com/apache/rocketmq/issues/2691
前提:使用的是spring-cloud-starter-stream-rocketmq 2.2.3版本
1. 自定义发送消息的通道
```
public interface ProducerChannel {
String OBJECT_TX = "object_tx";
@Output(ProducerChannel.OBJECT_TX)
MessageChannel objectTx();
}
```
使用了注解@EnableBinding({ProducerChannel.class})
2. application.yml配置binding信息
```
spring:
cloud:
stream:
bindings:
#事务消息
object_tx:
destination: object_tx_msg
producer:
transactional: true
group: myTxProducerGroup
```
3. 实现RocketMQLocalTransactionListener
```
@RocketMQTransactionListener(txProducerGroup = "myTxProducerGroup", corePoolSize = 5,maximumPoolSize = 10)
public class TransactionListenerImpl implements RocketMQLocalTransactionListener {
@Override
public RocketMQLocalTransactionState executeLocalTransaction(Message msg, Object arg) {
System.out.println(JSON.toJSONString(msg) + " " + JSON.toJSONString(arg));
return RocketMQLocalTransactionState.UNKNOWN;
}
@Override
public RocketMQLocalTransactionState checkLocalTransaction(Message msg) {
System.out.println(msg.getPayload());
return RocketMQLocalTransactionState.COMMIT;
}
}
```
但是,object_tx通道设置的producer属性没有被加载到ExtendedProducerProperties<RocketMQProducerProperties>里面,导致事务消息没有成功。
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [rocketmq] ShannonDing commented on issue #2691: application.yml文件中为通道配置的生产者属性没有加载到ExtendedProducerProperties里面
Posted by GitBox <gi...@apache.org>.
ShannonDing commented on issue #2691:
URL: https://github.com/apache/rocketmq/issues/2691#issuecomment-784213992
It is recommended to migrate this issue to the rocketmq spring project.
https://github.com/apache/rocketmq-spring
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [rocketmq] fengyiluo commented on issue #2691: application.yml文件中为通道配置的生产者属性没有加载到ExtendedProducerProperties里面
Posted by GitBox <gi...@apache.org>.
fengyiluo commented on issue #2691:
URL: https://github.com/apache/rocketmq/issues/2691#issuecomment-784168443
启动类里应该加上@EnableBinding(ProducerChannel.class),注意这里没有大括号。
@SpringBootApplication
@EnableBinding(ProducerChannel.class)
public class ProducerStarter {
public static void main(String[] args) {
SpringApplication.run(ProducerStarter.class, args);
}
}
//发送消息的方法如下:
@Autowired
private ProducerChannel producerChannel;
//...
public void testSend(){
producerChannel. objectTx().send(msg);
}
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [rocketmq] duhenglucky closed issue #2691: application.yml文件中为通道配置的生产者属性没有加载到ExtendedProducerProperties里面
Posted by GitBox <gi...@apache.org>.
duhenglucky closed issue #2691:
URL: https://github.com/apache/rocketmq/issues/2691
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [rocketmq] i757 commented on issue #2691: application.yml文件中为通道配置的生产者属性没有加载到ExtendedProducerProperties里面
Posted by GitBox <gi...@apache.org>.
i757 commented on issue #2691:
URL: https://github.com/apache/rocketmq/issues/2691#issuecomment-784684410
> 启动类里应该加上@EnableBinding(ProducerChannel.class),注意这里没有大括号。
> @SpringBootApplication
> @EnableBinding(ProducerChannel.class)
> public class ProducerStarter {
>
> ```
> public static void main(String[] args) {
> SpringApplication.run(ProducerStarter.class, args);
> }
> ```
>
> }
> //发送消息的方法如下:
> @Autowired
> private ProducerChannel producerChannel;
> //...
> public void testSend(){
> producerChannel. objectTx().send(msg);
> }
去掉@EnableBinding里面的大括号还是不行,TransactionListenerImpl里面的两个方法根本就没有调用
----------------------------------------------------------------
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:
users@infra.apache.org