An open API service indexing awesome lists of open source software.

https://github.com/jsbxyyx/rmq-transaction

Sending message consistency based on RocketMQ
https://github.com/jsbxyyx/rmq-transaction

rocketmq spring spring-boot transaction

Last synced: about 2 months ago
JSON representation

Sending message consistency based on RocketMQ

Awesome Lists containing this project

README

          

# rmq transaction
Sending message consistency based on RocketMQ

[![rmq-transaction](https://img.shields.io/maven-central/v/io.github.jsbxyyx/rmq-transaction?label=rmq-transaction)](https://central.sonatype.com/artifact/io.github.jsbxyyx/rmq-transaction)

# how to use
```

io.github.jsbxyyx
rmq-transaction
${rmq-transaction.version}

CREATE TABLE `tb_mq_msg` (
`id` VARCHAR(36) NOT NULL,
`status` VARCHAR(20) NOT NULL COMMENT '事件状态(待发布NEW)',
`mq_template_name` VARCHAR(1000) NOT NULL,
`mq_destination` VARCHAR(1000) NOT NULL,
`mq_timeout` BIGINT NOT NULL,
`mq_delay` VARCHAR(255) NOT NULL,
`payload` TEXT NOT NULL,
`retry_times` INT NOT NULL,
`gmt_create` DATETIME NOT NULL,
`gmt_modified` DATETIME NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_status` (`status`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

迁移执行:
1.0.0 迁移到最新 ALTER TABLE tb_mq_msg MODIFY COLUMN id VARCHAR(36) NOT NULL;
```

# samples
```
@Transactional(rollbackFor = Exception.class)
public int addOrder(Order order) {
// ...
RMQHelper.syncSend(rocketMQTemplate, "order:add", new GenericMessage<>(payload, headers));
return order.getId();
}
```