[异步][jms][activeMq]怎样做到重试机制不会导致一条消息被多次运行.
Receiver http://camel.apache.org/idempotent-consumer.html 内含一个概念 Idempotent
Receiver 大致看了下,有 jpa. 老实说没看懂怎样实现 , 邮件组中也有人问,见以下附件),
①消息不丢失 ,②消息不反复运行 是一个问题的两个方面. 不能顾此失彼.
由于接受 timeout 重发,导致多个业务机器收到消息.也不会导致反复处理.
,②消息不反复运行 依赖消息反复发送.
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVpMzM0MjM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
当返回acknowledge时,进行推断是否已经运行,假设否,那么运行次数+1, 告知用户commit事务. 假设是就告知用户端,进行事务回滚.
没做到①消息不丢失 .某些情况下有可能消息丢失.
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVpMzM0MjM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
后者的数据无法恢复并非通过业务端的编程能够控制的.须要Op通过某些机制尽可能的保证.
See the background here...
http://activemq.apache.org/should-i-use-xa.html
Typically you either need to implement your own duplicate message
detector, use an idempotent consumer... 幂等消费者. 核心关键
http://activemq.apache.org/camel/idempotent-consumer.html
or use XA.
Another approach 方法 I've used with customers is that for JPA stuff that
might fail (由于jpa可能失败), use a JPA endpoint in Camel as part of your JMS send (so
it really just does a JPA insert under the covers using your
JpaTemplate object and using the same transaction), then in the
ActiveMQ broker bridge from your entity to a queue.
e.g. in your code send to destination
new CamelDestination("jpa:com.acme.MyEntity");
then in your activemq.xml have a rule...
<route>
<from "jpa:com.acme.MyEntity"/>
<to "activemq:MyQueue"/>
</route>
This then means rather than having the XA issue; you can stick to
simple JDBC operations and transactions; then get the broker to poll
the database and bridge it to a message queue in a separate
transaction (which typically will have less risk of creating
duplicates).
If you're not using XA you really should have some kinda duplicate
detection in there just in case though.
On 05/11/2007, dmd <dmd17@cornell.edu> wrote:
>
> Hi all,
>
> I am using JPA (currently with OpenJPA) to persist the execution state of a
> process. I sometimes need to use the same transaction to consume a message,
> update the state of the process and persist it to disk, and generate some
> message.
>
> Essentially I have two services which communicate via JMS and both need to
> recover from failures and not lose their state or messages in transit.
>
> Now, I can't yet figure out how to configure the system in order to share
> the transactional context... Furthermore, I don't know if that requires
> that both the ActiveMQ broker and the JPA must use the same DB. (Obviously
> there is a requirement that the DB itself be highly available. We are using
> MS SQL Server with a shared storage configuration.)
>
> Any help would be appreciated, including someone telling me that I'm on
> totally the wrong track and I should use some other technologies.
>
> Cheers,
> Dan
>
> --
> View this message in context: http://www.nabble.com/ActiveMQ-and-JPA-with-global-transactions-tf4752732s2354.html#a13590338
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
|
[异步][jms][activeMq]怎样做到重试机制不会导致一条消息被多次运行.的更多相关文章
- ActiveMQ基于JMS的pub/sub传播机制
原文地址:[ActiveMQ实战]基于JMS的pub/sub传播机制 发布订阅模型 就像订阅报纸,我们可以选择一份或者多份报纸.比如:北京日报.人民日报.这些报纸就相当于发布订阅模型中的topic.如 ...
- JMS ActiveMQ研究文档
1. 背景 当前,CORBA.DCOM.RMI等RPC中间件技术已广泛应用于各个领域.但是面对规模和复杂度都越来越高的分布式系统,这些技术也显示出其局限性:(1)同步通信:客户发出调用后,必须等待服务 ...
- jms - activeMQ入门案例
activeMQ入门案例 叨叨一波,很久没写博客了,最近比较慢,时间抽不出来,这个借口说的很尴尬...我知道作为一名合格的码农就必须养成每天一博客的习惯.希望友友们别像我这样懒,闲话不多时进入今天的主 ...
- Rocket重试机制,消息模式,刷盘方式
一.Consumer 批量消费(推模式) 可以通过 consumer.setConsumeMessageBatchMaxSize(10);//每次拉取10条 这里需要分为2种情况 Consumer端先 ...
- RocketMQ(5)---RocketMQ重试机制
RocketMQ重试机制 消息重试分为两种:Producer发送消息的重试 和 Consumer消息消费的重试. 一.Producer端重试 Producer端重试是指: Producer往MQ上发消 ...
- Java重试机制
重试作用: 对于重试是有场景限制的,不是什么场景都适合重试,比如参数校验不合法.写操作等(要考虑写是否幂等)都不适合重试. 远程调用超时.网络突然中断可以重试.在微服务治理框架中,通常都有自己的重试与 ...
- springboot系列——重试机制原理和应用,还有比这个讲的更好的吗(附完整源码)
1. 理解重试机制 2. 总结重试机制使用场景 3. spring-retry重试组件 4. 手写一个基于注解的重试组件 5. 重试机制下会出现的问题 6. 模板方法设计模式实现异步重试机制 如果有, ...
- ENode 1.0 - 消息的重试机制的设计思路
项目开源地址:https://github.com/tangxuehua/enode 上一篇文章,简单介绍了enode框架中消息队列的设计思路,本文介绍一下enode框架中关系消息的重试机制的设计思路 ...
- ActiveMQ之 TCP通讯机制
ActiveMQ支持多种通讯协议TCP/UDP等,我们选取最常用的TCP来分析ActiveMQ的通讯机制.首先我们来明确一个概念: 客户(Client):消息的生产者.消费者对ActiveMQ来说都 ...
随机推荐
- opentracing学习入门
http://blog.csdn.net/akfly/article/details/53975388
- PHP利用lua实现Redis Sorted set的zPop操作
function zPop($key) { $script = <<<EOD local v = redis.call('zrange', KEYS[1], 0, 0); if v[ ...
- 开始docker
安装 docker 目前只支持64位系统 1.下载并安装,简直太方便了 $ curl -fsSL https://get.docker.com/ | sh 用例 .docker run hel ...
- vim学习记录(转)
基本功 Vim有三种模式: 导航(navigation)模式. 这时候,字母就是上下左右键. 输入模式.这时候,你按字母键,才会输入字母. 命令模式.需要先输入":" 冒号,才会进 ...
- hdu 3392(滚动数组优化dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3392 Pie Time Limit: 6000/3000 MS (Java/Others) Me ...
- AutoCAD如何移动零件和缩放零件图
如下图所示,我想要把这个零件放大并移动到图纸的中央,先全部选中这个零件,方法是在左上角点一下,然后拖出一个矩形包围整个零件 然后点击右侧的缩放命令,底部的命令栏变成指定基点的时候,在这个图纸的右上 ...
- java编译命令工具javac
Reads Java class and interface definitions and compiles them into bytecode and class files. Synopsis ...
- 新安装的金蝶K3软件,初始化后,在基础资料中对于币别,科目,部门,客户等资料均无法新增,无法引出,等操作,K3CASysSet.dll
新装K3,新建的帐套.导入科目点菜单或新增button均无反应,币别.客户等辅助核算项目也新增也无法保存. 在电脑上新安装的金蝶K3软件.初始化后.在基础资料中对于币别,科目,部门,客户等资料均无法新 ...
- nodejs 简单的备份github代码初版
传送门:http://www.jianshu.com/p/002efed0d3af 我的代码: const https = require('https'); const fs = require(& ...
- jQuery Validate(二)
刚刚试了所谓的新版的用法.千万别问我是多新,因为我也不知道... <!DOCTYPE html> <html> <head> <script src=&quo ...