如何以块(每个在新事务中)发送多个JMS消息 [英] How to send multiple JMS messages in blocks (each in a new transaction)

查看:177
本文介绍了如何以块(每个在新事务中)发送多个JMS消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Java EE 6 Web应用程序已达到可在单个事务中发送的最大JMS消息数,我需要在多个事务中执行此操作。当事务由容器管理时,这样做的最佳方法是什么?可以在不同的事务中使用相同的MessageProducer(使用带有 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)注释的EJB方法

My Java EE 6 Web application has reached the maximum number of JMS messages that can be sent in a single transaction and I need to do it in several transactions. What would be the best way of doing this when transactions are managed by the container? Is it OK to use the same MessageProducer across different transactions (using an EJB method annotated with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW))

我正在使用Glassfish v3和OpenMQ。

I'm using Glassfish v3 and OpenMQ.

这个SO问题涵盖了OpenMQ中最大消息数的问题在OpenMQ中发送到队列的最大邮件数量?

The problem with the maximum number of messages in OpenMQ is covered in this SO question Maximum number of messages sent to a Queue in OpenMQ?.

推荐答案

如果您无法在应用程序服务器中找到使用容器管理事务完成此操作的方法,那么您不需要想要使用程序化事务,可以考虑使用Aggregator和/或Splitter企业集成模式。

If you're unable to find a way to accomplish this with container-managed transactions in your application server, and you don't want to use programmatic transactions, you can consider using the Aggregator and/or Splitter enterprise integration patterns.

在生产者中,将单个消息或对象聚合成一个复合消息。在消费者端,拆分复合消息以进行适当的处​​理。

In your producer, aggregate your individual messages or objects into one composite message. On the consumer end, split out the composite message for appropriate processing.

这篇关于如何以块(每个在新事务中)发送多个JMS消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆