Skip to content

Commit 6231f8a

Browse files
feat(*): Updates messaging to support request-reply
This makes several updates to the messaging interface. Initially the README said that this wasn't going to support request/reply, but based on my reading of the Kafka, NATS, MQTT, and SQS APIs, this is a fairly common pattern. Another piece of evidence here is what I've seen as a wasmCloud maintainer from our users. Request/reply is one of the more common things we see with a messaging service. Please note that this doesn't _require_ the use of a reply-to topic, just exposes it for use. I also did a few other changes here. First is that I added the topic to the message. This was common across all systems and is often used by code to select the appropriate logic to perform. I also removed the format field as this didn't seem to be a common parameter across various services. We could definitely add a content-type member to this record in the future if needed, but I think much of that can be passed via the metadata field. There are other things I might suggest some changes to, but I want to think on them some more and open some issues to discuss them first Signed-off-by: Taylor Thomas <[email protected]>
1 parent c2a7421 commit 6231f8a

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Overall, the messaging interfaces aim to make it easier to build complex and sca
4545
### Non-goals
4646

4747
- The messaging service interfaces do not aim to provide advanced features of message brokers, such as broker clustering, message persistence, or guaranteed message delivery. These are implementation-specific details that are not addressed by the interfaces.
48-
- The messaging service interfaces do not aim to provide support for every possible messaging pattern or use case. Instead, they focus on the common use cases of pub-sub and push-based message delivery. Other messaging patterns, such as request-reply or publish-confirm-subscribe, are outside the scope of the interfaces.
48+
- The messaging service interfaces do not aim to provide support for every possible messaging pattern or use case. Instead, they focus on the common use cases of pub-sub, push-based message delivery, and request-reply. Other messaging patterns, such as publish-confirm-subscribe, are outside the scope of the interfaces.
4949
- The messaging service interfaces do not aim to provide a specific implementation of a message broker. Instead, they provide a standard way to interact with any message broker that supports the interfaces.
5050

5151
### API walk-through

wit/producer.wit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
interface producer {
22
use messaging-types.{client, channel, message, error};
33

4+
/// Sends a message to the given channel/topic. This topic can be overridden if a message has a
5+
/// non-empty topic field
46
send: func(c: client, ch: channel, m: list<message>) -> result<_, error>;
57
}

wit/types.wit

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,15 @@ interface messaging-types {
2323
extensions: option<list<tuple<string, string>>>
2424
}
2525

26-
/// Format specification for messages
27-
/// - more info: https://github.com/clemensv/spec/blob/registry-extensions/registry/spec.md#message-formats
28-
/// - message metadata can further decorate w/ things like format version, and so on.
29-
enum format-spec {
30-
cloudevents,
31-
http,
32-
amqp,
33-
mqtt,
34-
kafka,
35-
raw
36-
}
37-
38-
/// A message with a binary payload, a format specification, and decorative metadata.
26+
/// A message with a binary payload and additional information
3927
record message {
28+
/// The topic or subject this message was received or should be sent on
29+
topic: string,
30+
/// An optional topic for use in request/response scenarios
31+
reply-to: option<string>,
32+
/// An opaque blob of data
4033
data: list<u8>,
41-
format: format-spec,
34+
/// Optional metadata (also called headers or attributes in some systems) attached to the message
4235
metadata: option<list<tuple<string, string>>>
4336
}
4437
}

0 commit comments

Comments
 (0)