简体   繁体   English

JMS 2.0规范 - JMS提供程序如何通过JMS客户端检测Message对象的更改?

[英]JMS 2.0 specs - how a JMS provider can detect the change in Message object by a JMS client?

I was reading JMS 2.0 specs and it is mentioned that (below relevant excerpt) if client tries modify the Message object then JMS provider may throw an exception. 我正在阅读JMS 2.0规范,并提到(在相关的摘录下)如果客户端尝试修改Message对象,那么JMS提供程序可能会抛出异常。

My question is how a JMS provider would know if client is trying to modify the Message object, because Message object would be transmitted over the wire and at JMS provider end it is not the same heap object so even if client modifies that Message object, JMS provider has no way to detect the change. 我的问题是JMS提供程序如何知道客户端是否正在尝试修改Message对象,因为Message对象将通过线路传输,而在JMS提供者端,它不是同一个堆对象,所以即使客户端修改了Message对象,JMS也是如此提供商无法检测到更改。

Am I missing something? 我错过了什么吗?

7.3.9. 7.3.9。 Restrictions on the use of the Message object 使用Message对象的限制

Applications which perform an asynchronous send must take account of the restriction that a Message object is designed to be accessed by one logical thread of control at a time and does not support concurrent use. 执行异步发送的应用程序必须考虑Message对象被设计为一次由一个逻辑控制线程访问的限制,并且不支持并发使用。 See section 2.14 “Multi-threading”. 请参见第2.14节“多线程”。

After the send method has returned, the application must not attempt to read the headers, properties or body of the Message object until the CompletionListener's onCompletion or onException method has been called. 在返回send方法之后,在调用CompletionListener的onCompletion或onException方法之前,应用程序不得尝试读取Message对象的头,属性或主体。 This is because the JMS provider may be modifying the Message object in another thread during this time. 这是因为在此期间JMS提供程序可能正在修改另一个线程中的Message对象。

A JMS provider may throw a JMSException if the application attempts to access or modify the Message object after the send method has returned and before the CompletionListener has been invoked. 如果应用程序在send方法返回之后和调用CompletionListener之前尝试访问或修改Message对象,则JMS提供程序可能抛出JMSException。 If the JMS provider does not throw an exception then the behaviour is undefined. 如果JMS提供程序未抛出异常,则行为未定义。

This excerpt is referring to the JMS client implementation as the JMS Provider here and it is telling you that once you call send using the asynchronous API you no longer control the Message until such time as the asynchronous completion is notified either with a success or fail event. 这段摘录是指JMS客户端实现作为JMS提供程序,它告诉您一旦使用异步API调用send,就不再控制消息,直到通过成功或失败事件通知异步完成为止。

The client will often times use an internal "read-only" flag on the send call to tag that the message is now not to be touched by the client code and will reset the read-only state back to read / write after the send call completes one way or another. 客户端通常会在发送调用上使用内部“只读”标志来标记客户端代码现在不会触及该消息,并在发送调用后将只读状态重置为读/写状态以某种方式完成。

This text is referrent to your provider's implementation of the JMS Message object. 本文引用了您的提供程序的JMS Message对象的实现。 When received from the JMS consumer, this message usually has a read-only flag turned on, also to make improved performance possible, that will be checked in the implementation of 'Message' when you use methods that would modify the message. 从JMS使用者收到此消息时,此消息通常打开一个只读标志,也可以提高性能,当您使用可修改消息的方法时,将在“消息”的实现中检查该消息。 For example TextMessage.setText() would throw an Unmodifiable exception 例如, TextMessage.setText()将抛出一个Unmodifiable异常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM