[异步][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来说都 ...
随机推荐
- windows 下使用github客户端报错:Failed to publish this branch
在windows系统下使用github客户端同步的时候报错“Failed to publish this branch”,查找原因,发现结果是安装vscode的时候没有检查到git,然后安装git后库 ...
- 英语词组instead of的用法
nstead of 是个短语介词.Instead of 的意思是“代替……”.“而不……”, 在语言的实际运用中,instead o功能与连词十分相似,现归纳如下: 1.跟名词:I give him ...
- 2017.2.7 开涛shiro教程-第六章-Realm及相关对象(三)
原博客地址:http://jinnianshilongnian.iteye.com/blog/2018398 根据下载的pdf学习. 第六章 Realm及相关对象(三) 1.准备3个Realm MyR ...
- java web邮件收发
1.网上方法要导入两个包 mail.jar&activation.jar package com.zjh.shopping.util; import java.util.Date; impor ...
- 使用聚合数据的接口进行的RxAndroid学习
Demo数据源是聚合数据的免费Api,地址:https://www.juhe.cn/ 配合Retrofit 完成数据请求 例子比较简单,没事使用什么复杂的操作符. 就是简单的网络数据获取. 一些常用的 ...
- npm run watch-poll 监控css、js 文件更新
后台执行npm run watch-poll 你可以在执行命令的后面接一个&命令就会在后台运行了.完整命令:npm run watch-poll & 就是任务号 文章来源:刘俊涛的博客 ...
- 强制重启Linux系统的几种方法
实际生产环境中某些情况下 Linux 服务器系统在出现致命错误需要远程进行重启,通过常规的 reboot.init 6 等方法无法正常重启(例如重启时卡在驱动程序里等情况),这时就需要通过下面介绍的几 ...
- React学习之事件绑定
React事件绑定有主要有三种方式 第一种官方推荐方式: class LoginControl extends React.Component { constructor(props) { ...
- Leetcode Array 11 Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- HTML5 2D平台游戏开发#3冲刺
断断续续地把Demo又写了一阵,终于把角色的冲刺动作完成了.冲刺的作用是使角色能够快速移动,闪避攻击或障碍.其完成效果如下: 首先,仍需要一些变量来表示角色的冲刺状态: //标识角色是否处于冲刺中 v ...