MDB 事务不会在超时时回滚电子邮件
我有一个监听队列的 MDB。每当它收到一条消息时,它都会将执行转发到一个无状态会话 bean,该 bean 具有大量逻辑、更新等。这是逻辑/调用链的流程。
队列->mdb->会话 bean->会话 bean->电子邮件->日志记录
最终结果是电子邮件和后续日志记录。
默认情况下,MDB 事务由容器管理,超时时间为 30 秒。
但是,每当达到超时时,它都会抛出超时异常并重试消息,但嵌套事务及其进程不会回滚(从会话 bean)。因此,由于重试,会发出多封电子邮件,但所有日志记录都会回滚(从会话 bean),除了从 MDB 本身记录的内容之外,
不应该从 MDB 回滚调用所有事务,包括 mdb 日志记录,尤其是电子邮件?
会话 Bean 的默认事务类型均为“必需”。
我还明确将 TransactionManagement 类型设置为 CONTAINER,并将 TransactionType 设置为 REQUIRED。电子邮件仍然发出。从会话 bean 记录回滚但会发生重试。
然后我将 TransactionType 设置为 REQUIRES_NEW。电子邮件仍然发出。从会话 bean 记录回滚但不会发生重试。
我应该进行什么设置来确保由 MDB 启动的整个事务以及从中调用的任何事务回滚并重试?
我不想使用 bean 管理的事务,因为我希望在失败时重试。
我的应用程序服务器是带有 ejb 3 规范的 weblogic 10.3。
I have an MDB that listens on a queue. Whenever it recieves a message, it will forward execution to a stateless session bean which has a lot of logic, updates etc. Here is the flow of logic/call chain.
queue->mdb->session bean->session bean->email->logging
The end result is an email and subsequent logging.
By default, the MDB transaction is managed by container and its time out is 30 seconds.
However, whenever timeout is reached, it throws timeout exception and retries the message, but the nested transaction and its processes are not rolled back(from session bean). As a result, multiple emails go out because of the retry but all the logging is rolled back (from session beans) EXCEPT for what is logged from the MDB itself
Shouldnt all the transactions being called from the MDB rollback including the mdb logging and especially the emails?
The session beans all have default transaction type as 'required'.
I also explicitly set the TransactionManagement type as CONTAINER with the TransactionType as REQUIRED. Emails still go out. Logging from session beans rollback but retry occurs.
I then set the TransactionType as REQUIRES_NEW. Emails still go out. Logging from session beans rollback but retry DOESNT occur.
what setting do I put to make sure the ENTIRE transaction started by the MDB and any transactions called from it, get rolled back AND retry occurs?
I do not want to use bean managed transactions because I want the retry on failure to occur.
My application server is weblogic 10.3 with ejb 3 spec.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的电子邮件资源不是事务性的,因此放弃 mdb 超时并让您的电子邮件发件人依赖电子邮件传输超时,此时,仅调用 TX setrollback。 tx 将回滚,消息将重新传送,并且您的电子邮件可能只有在重试成功后才会发送。电子邮件传输超时的结果可能不确定。
Your email resource is not transactional, so ditch the mdb timeout and have your email sender rely on the email transport timeout, at which point, call TX setrollback only. The tx will rollback, the message will be redelivered and your email may only be sent on a successful retry. The outcome of email transport timeout may not be deterministic.