-
Notifications
You must be signed in to change notification settings - Fork 3
Question: Does every message need a messageID
?
#35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The use of messageID should be optional but can be essential. Duplicate message can and will happen in situations where the connection is intermittent. If duplicate messages are not allowed it is essential to provide the means to detect them. The use of messageID's are a common method to detect duplicates. In a fleet management solution I've worked on in the past, cell connection from the vehicles was unreliable as you can imagine. When a connection is interrupted while sending a message it is quite possible that the server receives the message but the acknowledgement didn't make it back to the vehicle. After reconnecting the vehicle will retry sending the message. The server will receive it twice. I was suprised how often this happened. |
I hope this isn't too high-level, but I wanted to share my thoughts on this topic. One of my all-time favorite books is Enterprise Integration Patterns. It has been a guiding resource for tackling real-world challenges in my projects. When working with WebSockets, we are essentially building a point-to-point messaging system. This involves implementing Message Endpoints through protocol binding implementations and creating Messaging Gateways using WoT Servients. From a Thing’s perspective, we encounter various message types, including:
WebSocket itself serves as a Point-to-Point Channel, which is a specific instance of the more general Message Channel. Whenever I’ve worked with messaging systems, I’ve faced similar challenges at some point. For example:
When you take an end-to-end view of such a "messaging system," encompassing Messaging Gateways on both the Thing Consumer and Thing Provider sides, you realize the need to implement numerous patterns to ensure the system is robust and resilient. In this context, Messages can be seen as having two core parts:
In my view, we’re designing a WoT-specific messaging protocol for WebSockets. And I really believe that a key element of the message header is a unique message ID, which is a common feature in most messaging protocols. Currently, I use the message ID from a request message as the correlation ID in the corresponding response message. Some messaging systems also allow both a unique message ID and a correlation ID in request messages to group multiple requests (e.g., in a "multiple request, single response" pattern). However, I don’t believe this complexity is necessary for the Web Thing Protocol at this stage. |
Here are some concrete use cases where a messageId is needed:
|
@RobWin Thank you for this detailed list of use cases, this is extremely helpful and there are lots of use cases I hadn't considered. Proposal: What if every message has a
Side Note: Whilst the Use Cases & Requirements document says that a single WebSocket should be shareable between multiple interaction affordances and multiple Things, it doesn't currently say it should be shareable between multiple Consumers. That's not currently a requirement and I don't think it would work well with the assumptions made around authentication and WebSocket re-use (a single set of credentials is provided when opening the WebSocket, using standard HTTP security schemes, so that credentials aren't needed inside every message). This is really a separate topic though so we should file a separate issue if this something people see as an important use case. |
Yes, I agree to both. |
It probably could work but it gets convoluted. correlationID and messageID have two different purposes. Mixing them up like this could cause confusion. The idea of messageID is that it is unique to the message but now the response re-uses it instead. The logic for messageIDs is also unrelated to that of correlation ID. This looks like premature optimization to me. What is the benefit? If payload size is important then there are better ways to address this, by changing encoding for example. I doubt it has a measurable impact. My counter proposal is to keep them separate and make messageID optional. It is only useful for actions that are not idempotent anyways. |
Yes indeed. This will not allow identification of the consumer which is critical for security. I also don't see a practical use-case that needs this. |
I disagree and agree :) The MessageID should be mandatory and unique for every message. This is critical for debugging and auditing purposes, ensuring that each message can be tracked. Beyond that there are other significant use cases I have described above. As already mentioned. In many messaging systems, correlation data is used to link requests to responses. Typically, the request contains optional correlation data, which the responder copies, when available, into the response to allow correlation for the requestor. This is a common pattern and is well-documented in messaging systems and educational materials. And very easy to implement. The nature of correlation data varies across systems:
But I agree. By allowing optional correlation data in request and response messages, we enable flexibility without overloading the purpose of the mandatory MessageID field. Web Thing Protocol Implications: If the Web Thing Protocol wants to avoid optional correlation data in requests, the MessageID would need to be used as a substitute. However, this approach has limitations and may not align with how correlation data is handled in other systems. Proposed Solution: Retain the mandatory MessageID for its primary purpose (unique identification) |
I could provide real live use case, if needed. |
I don't doubt that it is critical for this kind of use. However, these are application/policy requirements that are not neccesarily protocol binding requirements. The binding just has to be able to support these application requirements. I do doubt that all applications require it. Would you force the use of messageID in the messaging for those applications? |
Yep that keeps things clear. If no correlation data is provided then you won't get a response. As simple as that. |
Yes, because let's say a Thing Provider is implemented by a different company directly in a device and the company is implementing the Web Thing Protocol, but without messageIds. |
False, at least in my understanding. |
I think we're trying to say the same thing :) |
Maybe :) |
You're right! Its funny as we have such a different perspective. From a hub/gateway point of view having a Thing send a response to the hub without correlation data is useless as the hub can't determine which consumer connection to forward the response to. Hence my comment on not sending it. |
I mean if the requestor (hub) sends a request with correlation data, the Thing must add the correlation data to the response to comply with the Web Thing protocol specification. This would be documented in the spec. |
Agreed. What behavior is expected though if no correlationID is present in the request. Should the Thing still send a response? I interpret this situation as if no requestID is provided then there is no interest in a response, so no need to send one. But that is based on the (incorrect) assumption that there is no use for such a response. The Thing doesn't care whether its consumer is a hub/gateway or another client. (btw, maybe this is its own separate issue as we are no longer talking about messageID) |
As described above and how it works in other messaging systems with request-response pattern, when no correlation data is needed. If the requestor does not attach correlation data, then it's fine if the response does not contain correlation data. But still a response is returned. |
Okay, makes sense. Thanks for clarifying. This does imply that if a consumer sends a request to the hub/gateway without correlation data, the hub would have to add it when forwarding the request to the Thing, otherwise it won't be able to correlate the response from the Thing to return to the original consumer. The hub must also remove the correlation from the response to the original consumer. |
OK, the consensus so far appears to be that in addition to a mandatory This is definitely more IDs than I had anticipated would be necessary in messages, but I can see the use cases for them. |
Answer: Yes. |
It has been suggested by @RobWin and @hspaay that it would be useful for every message to have a
messageID
which uniquely identifies it. This is separate from therequestID
/correlationID
being discussed in #31.We seem to be accumulating a lot of IDs in every message (!) and this isn't something I've ever found a need for, so I thought I'd ask for use cases for this feature.
Is this essential? Why is it important? What would be the result of not having one?
The text was updated successfully, but these errors were encountered: