Repository navigation
Description
TL;DR: What's new?
- Remote vs Local Servers: Servers got a new
kindproperty. By default, all servers areremoteservers (e.g., brokers). However, if thekindproperty is set tolocal, that means the application is the one actually exposing the server (e.g., WebSocket or HTTP Server-Sent Events server). - Channel Identifiers: Channels are not identified by their "address" anymore. Instead, we define an ID that represents the channel and the "address" is specified separately. This encourages the reuse of channels and eases the process of referencing them and changing their address without breaking the referencing documents.
- Operations: There's a new top-level object called "operations". It defines the operations (as in actions) this application is performing or going to perform, and in which channel.
- Send/Receive: We get rid of "publish" and "subscribe" and instead replace them with "send" and "receive". They're both actions an application performs instead of actions an application expects the client to perform. Aside from the confusion "publish" and "subscribe" are creating, some people are incorrectly assuming that AsyncAPI is only meant to describe pub/sub event-driven architectures.
- Optional channels: from now on, the
channelsobject is optional. The only two fields that are required areasyncapiandinfo. - More reusability: now
serversandchannelscan be defined insidecomponentsfor reusability purposes. This way, an AsyncAPI document may only contain acomponentsobject that can serve as an organization-wide menu of servers, channels, messages, etc.
Abstract
For some years now, we've been discussing how to solve the publish/subscribe perspective problem. Some were arguing we should be giving priority to broker-based architectures because "they are the most common type of architecture AsyncAPI is used for". Although they're not wrong, by simply changing the meaning of publish and subscribe keywords, we'd be leaving many people and use cases out. We have to come up with a way to fix this problem without losing the ability to define client/server interactions too, which are especially useful for public WebSockets and HTTP Server-Sent Events APIs. And more importantly, we need a structure that will allow us to grow well and meet our vision.
The latest Thinking Out Loud episodes with @lornajane, @dalelane, @damaru-inc, and @jmenning-solace have been key to better understand the problem. The intent of this proposal is to be a mix of the ideas and feedback I got from the community. I hope I managed to capture them well 😊
Foundational concepts
We gotta start from the beginning: an AsyncAPI file represents an application. This doesn't change. However, if no channels or operations are provided, the file becomes a "menu", a "library", a collection of reusable items we can later use from other AsyncAPI files.
We have been very focused on the meaning of publish and subscribe but there is another key aspect of the spec that is confusing to many people: servers. As it is right now, the servers keyword holds an object with definitions of the servers (brokers) we may have to connect to. However, it also holds information about the server our application is exposing (HTTP server, WebSocket server, etc.) In some tools, we have been incorrectly assuming that if someone specifies ws as the protocol, it means they want to create a WebSocket server instead of a WebSocket client. But what if someone wants to connect to a broker using the WebSocket protocol? This whole thing about the role of our application has been confusing all of us. As @lornajane pointed out on multiple occasions, an application can be both a server and a client, or just a server, or just a client. Therefore, servers can't be made up of that mix. Exposed server interfaces and remote servers (usually brokers) have to be separated because —even though they look the same— they're semantically different.
Remotes vs Local Servers
This proposal introduces the concept of a remote or local server. Remote servers are those our application has to connect to. They're usually brokers but can also be other kinds of servers.
On the other hand, local servers are server interfaces our application exposes. Their URL defines where clients can reach them.
Example
asyncapi: 3.0.0
servers:
test:
url: ws://test.mycompany.com/ws
protocol: was
kind: local
description: The application creates a WebSocket server and listens for messages. Clients can connect on the given URL.
mosquitto:
url: mqtt://test.mosquitto.org
protocol: mqtt
kind: remote # This is the default value
description: The application is connecting to the Mosquitto Test broker.New channels and operations objects
Another common concern related to the current state of publish and subscribe is the channel reusability problem we encounter because these verbs are part of the channel definition. To avoid this problem, we remove the operation verbs from the channel definitions and move them to their own root object operations. Let's have a look at an example:
asyncapi: 3.0.0
channels:
userSignedUp:
address: user/signedup
message:
payload:
type: object
properties:
email:
type: string
format: email
operations:
sendUserSignedUpEvent:
channel: userSignedUp
action: sendThere are a few new things here:
- Channel
address: it's the logical address where you can find this channel. Usually, this is the topic name, the routing key, the URL path, etc.- So what's this
userSignedUpthen? This is the channel identifier. It's an identifier that serves to reference the channel from another part of the document or another document. - Why not using the address directly? We use JSON Pointer in the $ref construct. Referencing
user/signedupusing JSON Pointer would beuser~1signedupas opposed touser/signeduplike many people would think. That's highly unreadable and error-prone, therefore I'm introducing channel identifiers. - Channel identifiers also facilitate the task of changing the address in a single place. For instance, if a topic name changes, it has to be changed in only one place and all the other files referencing this channel definition will be automatically updated.
- So what's this
- Operations object: it's the place where all the operations of this application are defined.
channelhints against which channel is this operation performed andactionis the type of operation, i.e., we're "sending" or "receiving".- What's this
sendUserSignedUpEvent? It's the operation identifier. Yes, the oldoperationIdis now mandatory and it's implicit, i.e., theoperationIdfield doesn't exist anymore. - Why isn't
channela$refor JSON Pointer? To keep things simple. If you're referring to a channel here, it must be defined in thechannelsobject. If we allow$refhere, it means it can be dereferenced and therefore the channel ID would be lost. To make things easier and more consistent, this field is simply a string with the name of the channel ID. - Why
sendandreceive? No, it's not that I'm hatingpublishandsubscribealready 😅 I'm usingsendandreceivehere to avoid confusion for those thinking that AsyncAPI is only meant to describe pub/sub architectures. I think "send" and "receive" are pretty common verbs that shouldn't be linked to any super-very-special meaning.
- What's this
Organization and reusability at its best
I'm adding two new objects to the components object: servers and channels. Some may be already wondering "why? don't we have servers and channels already in the root of the document?". To understand this decision, I think it's better if I just describe the reusability model I have in mind.
Reusability
Some people expressed their interest in having a "menu" of channels, messages, servers, etc. They're not really interested in a specific application. In other words, they want an organization-wide "library". This is the components object. It's now possible to do something like the following:
asyncapi: 3.0.0
info:
title: Organization-wide definitions
version: 3.4.22
components:
servers:
...
channels:
...
messages:
...This is now a valid AsyncAPI file and it can be referenced from other AsyncAPI files:
asyncapi: 3.0.0
info:
title: My MQTT client
version: 3.1.9
servers:
mosquitto:
$ref: 'common.asyncapi.yaml#/components/servers/mosquitto'
channels:
userSignedUp:
$ref: 'common.asyncapi.yaml#/components/channels/userSignedUp'
operations:
sendUserSignedUpEvent:
channel: userSignedUp
action: sendAs you can see, I'm not defining any channel or server in this file but instead, I'm pointing to their definitions in the org-wide document (common.asyncapi.yaml). And this leads me to the other part of this section: "organization".
Organization
The example above shows how we explicitly reference the resources (servers and channels) that our application is using. Having them inside components doesn't mean they are making any use of it. And that's key. The file is split into two "sections": application-specific and reusable items. Let's see an example:
asyncapi: 3.0.0
##### Application-specific #####
info: ...
servers: ...
channels: ...
operations: ...
##### Reusable items ######
components:
servers: ...
channels: ...
schemas: ...
messages: ...
securitySchemes: ...
parameters: ...
correlationIds: ...
operationTraits: ...
messageTraits: ...
serverBindings: ...
channelBindings: ...
operationBindings: ...
messageBindings: ...
###########So for those of you who were wondering before "why? don't we have servers and channels already in the root of the document?": This is the reason, it's no different than it's right now in v2.x but I thought I'd make it more clear this time. Just because we put something in components doesn't mean the application is making any use of it.
Life is better with examples
Microservices
Say we have a social network, a very basic one. We want to have a website, a backend WebSocket server that sends and receives events for the UI to update in real-time, a message broker, and some other services subscribed to some topics in the broker.
We'll define everything that's common to some or all the applications in a file called common.asyncapi.yaml. Then, each application is going to be defined in its own AsyncAPI file, following the template {app-name}.asyncapi.yaml.
The common.asyncapi.yaml file
asyncapi: 3.0.0
info:
title: Organization-wide stuff
version: 0.1.0
components:
servers:
websiteWebSocketServer:
url: ws://mycompany.com/ws
protocol: ws
mosquitto:
url: mqtt://test.mosquitto.org
protocol: mqtt
channels:
commentLiked:
address: comment/liked
message:
...
likeComment:
address: likeComment
message:
...
commentLikesCountChanged:
address: comment/{commentId}/changed
message:
...
updateCommentLikes:
address: updateCommentLikes
message:
...The backend.asyncapi.yaml file
asyncapi: 3.0.0
info:
title: Website Backend
version: 1.0.0
servers:
websiteWebSocketServer:
$ref: 'common.asyncapi.yaml#/components/servers/websiteWebSocketServer'
mosquitto:
$ref: 'common.asyncapi.yaml#/components/servers/mosquitto'
channels:
commentLiked:
$ref: 'common.asyncapi.yaml#/components/channels/commentLiked'
likeComment:
$ref: 'common.asyncapi.yaml#/components/channels/likeComment'
commentLikesCountChanged:
$ref: 'common.asyncapi.yaml#/components/channels/commentLikesCountChanged'
updateCommentLikes:
$ref: 'common.asyncapi.yaml#/components/channels/updateCommentLikes'
operations:
onCommentLike:
action: receive
channel: likeComment
description: When a comment like is received from the frontend.
onCommentLikesCountChange:
action: receive
channel: commentLikesCountChanged
description: When an event from the broker arrives telling us to update the comment likes count on the frontend.
sendCommentLikesUpdate:
action: send
channel: updateCommentLikes
description: Update comment likes count in the frontend.
sendCommentLiked:
action: send
channel: commentLiked
description: Notify all the services that a comment has been liked.The frontend.asyncapi.yaml file
asyncapi: 3.0.0
info:
title: Website WebSocket Client
version: 1.0.0
servers:
websiteWebSocketServer:
$ref: 'common.asyncapi.yaml#/components/servers/websiteWebSocketServer'
channels:
likeComment:
$ref: 'common.asyncapi.yaml#/components/channels/likeComment'
updateCommentLikes:
$ref: 'common.asyncapi.yaml#/components/channels/updateCommentLikes'
operations:
sendCommentLike:
action: send
channel: likeComment
description: Notify the backend that a comment has been liked.
onCommentLikesUpdate:
action: receive
channel: updateCommentLikes
description: Update the UI when the comment likes count is updated.The notifications-service.asyncapi.yaml file
asyncapi: 3.0.0
info:
title: Notifications Service
version: 1.0.0
servers:
mosquitto:
$ref: 'common.asyncapi.yaml#/components/servers/mosquitto'
channels:
commentLiked:
$ref: 'common.asyncapi.yaml#/components/channels/commentLiked'
operations:
onCommentLiked:
action: receive
channel: commentLiked
description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author.The comments-service.asyncapi.yaml file
asyncapi: 3.0.0
info:
title: Comments Service
version: 1.0.0
description: This service is in charge of processing all the events related to comments.
servers:
mosquitto:
$ref: 'common.asyncapi.yaml#/components/servers/mosquitto'
channels:
commentLiked:
$ref: 'common.asyncapi.yaml#/components/channels/commentLiked'
commentLikesCountChanged:
$ref: 'common.asyncapi.yaml#/components/channels/updateCommentLikes'
operations:
onCommentLiked:
action: receive
channel: commentLiked
description: Updates the likes count in the database and sends the new count to the broker.
sendCommentLikesUpdate:
action: send
channel: commentLikesCountChanged
description: Sends the new count to the broker after it has been updated in the database.Public-facing API
Another common use case for AsyncAPI is to provide a definition of a public-facing API. Examples of this are Slack, Gitter, and Gemini.
This would work differently than it is now. Instead of defining the server as we do with OpenAPI (and AsyncAPI v2), we'd have to define how a client would look like. For instance:
asyncapi: 3.0.0
servers:
production:
url: wss://api.gemini.com
protocol: wss
channels:
v1MarketDataSymbol:
address: /v1/marketdata/{symbol}
parameters:
...
operations:
onMarketSymbolUpdate:
action: receive
channel: v1MarketDataSymbol
description: Receive market updates on a given symbol.Currently, in v2, the spec lets you describe the server and infer the client from this description (as with OpenAPI). However, this causes a discrepancy with servers, especially in production systems. For instance, my server may be listening on port 5000 because it's behind a proxy. The client should be sending requests/messages to port 80 and they'll be forwarded by the proxy. If we define our port as 80 in the AsyncAPI file and generate a client, everything is ok but if we generate a server, our code will try to listen in port 80, which is not what we want. This means we can't infer clients from server definitions.
The drawback is that we'd have to define 2 files, one for the server and one for the client but the benefit is that we can be 100% accurate with our intents. Tooling can help auto-generating a client definition from a server definition.
Further expansion
Override channel messages with operation-specific messages
The new operations object would help us define additional use cases, like those where we define what message is sent or received to/from a channel at the operation level. Let's see an example:
channels:
commentLikesCountChanged:
message:
oneOf:
- $ref: 'common.asyncapi.yaml#/components/messages/updateCommentLikes'
- $ref: 'common.asyncapi.yaml#/components/messages/updateCommentLikesV2'
operations:
sendCommentLikesUpdate:
action: send
channel: commentLikesCountChanged
description: Sends the new count to the broker after it has been updated in the database.
sendCommentLikesUpdateV2:
action: send
channel: commentLikesCountChanged
message:
$ref: 'common.asyncapi.yaml#/components/messages/updateCommentLikesV2'
description: Does the same as above but uses version 2 of the message.Adding request/reply support
Adding support for the so-demanded request/reply pattern, would be as easy as adding a new verb and a reply keyword. See example:
channels:
users:
message:
oneOf:
- $ref: 'common.asyncapi.yaml#/components/messages/createUser'
- $ref: 'common.asyncapi.yaml#/components/messages/userCreated'
operations:
createUser:
action: request
channel: users
message:
$ref: 'common.asyncapi.yaml#/components/messages/createUser'
description: Creates a user and expects a response in the same channel.
reply:
message:
$ref: 'common.asyncapi.yaml#/components/messages/userCreated'This is just an example. We should also consider dynamic channel names created at runtime and probably other stuff.
FAQ
Does it serve as a base ground to meet our vision without a future major version?
I think so. Whenever we're ready to support REST, GraphQL, and RPC APIs, this structure should perfectly serve as a base ground.
Does it enable for better reusability of channels and other elements?
Yes. It completely decouples channels from operations and even clarifies the reusability model of the specification.
Does it allow users to define their whole architecture in a single file?
No, but it allows users to have a "common resources" AsyncAPI file where most of the information can reside.
Is it backward-compatible?
Absolutely not.
Does it remove the publish/subscribe confusion without introducing a new confusing term?
Yes. We keep the basic terms as before with just a bit of reorganization.
Is it easy to define a broker-based microservices architecture?
Yes. I provided an example.
Is it easy to define a public asynchronous API?
Yes. I provided an example.
Does it set the base ground to define an RPC (Remote Procedure Call) system over a message broker?
Yes. I provided a basic non-normative example.
Does it set the base ground to define a point-to-point RPC (Remote Procedure Call) API?
Yes. I provided a basic non-normative example.
Activity
magicmatatjahu commentedon Sep 6, 2021
@fmvilas Awesome proposal! I love it ❤️ However, I have some problems with some parts of this proposal, maybe some things are obvious for you and for other people, but some things surprise me and I think their assumptions are wrong.
The main problem - message(s) in the channel
Why do you want to define the message(s) in the channel, not as currently in the operation level? Consider the first example you gave:
sendUserSignedUpEventoperation? This problem is more pronounced in the case ofOverride channel messages with operation-specific messagescase.servers(andremotesfield) with names of the existing servers. I guess that given channel is only available for particular server/remote. Ok... but what in case when someone want to define multiple operations (withreceivekind) for the different servers?sendandreceiveoperation (we have still possibility in the2.X.XAsyncAPI). If you define the message asoneOf, then how to guess which message is forsendand which forreceive?I think that in this case, message(s) should be only defined on the operation, not on the channel. Channels should be then treated only as "interface", which you must "implement" by the operations (also if you need by multiple operations). For me, in the current proposal, the operation is "hardcoded" to the given channel by the message. If I'm not right, please clarify the
messagefield on the channel, because it really doesn't fit for me.Splitting servers to the two groups
I like idea to clarify that given server is remote and application is connecting to it and another server "runs" the app, but... did you consider having
kindin the Server object? Then we don't need theremotesObject. Also as I see, the remotes have this same shape as servers, sokind: remote(orremote: true) is enough for me.Servers and remotes in the channel
I mentioned about it the first section:
but I think that you should clarify this thing in the proposal, because I know that you copied this from existing PR, but people can be surprised 😄
Adding request/reply support
Here I'm just going to think out loud because I'm not an expert in this topic. Maybe instead of an extra action type like
requestand thereplayfield we should reusereceiveaction and add the wordoperationsorthen, that would determine what should happen when a given operation is processed and whether it "produces" subsequent operations? Something like, if the payment in the e-shop was successful, send (reply to the broker) an operation that saves record in the database - otherwise create another operation that does rollback etc. This way we could support many more techniques than just request/reply.Example:
In the example above, I use HTTP statuses to describe the state of the operation: success or failure. Probably something better can be invented.
It seems more generic to me. The idea itself is taken from CQRS.
👏🏼 for the proposal. If we go along with this (and I think we will after a dozen or so revisions), then every tool will have to be re-written from scratch 😂
fmvilas commentedon Sep 7, 2021
Thanks for the quick feedback, Maciej! 🙌
At least 2 reasons come to my mind:
Precisely. Interfaces let you define the "shape" of the implementation and that's what we're doing here.
How is that hardcoded? We're just standardizing what messages can go through a channel and I think this is actually one of the biggest values. It's exactly how it is today. In v2, the message is tied to an operation and a channel at the same time in the same place.
Mind clarifying this? I'm not sure I understand your question/concern.
Sorry, that was just an experiment I was doing and forgot to delete it before publishing. Thanks for the heads up.
You can define as many operations as you want in a given channel :)
I did, and instantly discarded it 😄 When you're referencing a server or a remote, you can clearly know by the URL if it's either a server o a remote. E.g.:
In general, just because two things have the same shape, it doesn't mean they have to be merged. Structurally they look the same but semantically they're completely different and subject to evolve in different directions in the future.
Not a concern of this proposal (my example was just to showcase that something can be done) but I'll bear with you. It seems what you're trying to define there is workflow language. And that's a totally different thing altogether 😄
Thanks a lot, Maciej! I hope this clarifies things a bit more :)
iancooper commentedon Sep 7, 2021
I think this is a very positive proposal and helps with a lot of the issues around re-use of channels in typical microservice documentation etc.
A quick initial question. My understanding is server is something we have and remote is something we use. With that assumption, should there be an explicit connection between server/remote and channel? If i a channel becomes a reusable asset that I can define in a central file, where it is shared by producer and consumer, where is that channel hosted? Do I want to define the remote that hosts my channel in every file, even if I don't re-declare the channel there to somehow indicate they are hosted there?
On Identifiers, I think there may be a generally useful concept here. Having been working with $ref whilst I try and put together an SNS/SQS binding, it struggles where you want to imply resource uses resource b - defined elsewhere - instead of pull in definition of resource b.
magicmatatjahu commentedon Sep 7, 2021
@fmvilas Thanks for explanation. Some things are clear but
messageat the channel level doesn't fit me 😄Yes, I agree but currently you define given message(s) for particular action/operation (publish/subscribe), even if you have defined explicit operation in the channel level. I can understand the reason for having messages in the channel level, but that's the biggest problem to understand: whether a given message(s) by default is/are associated with
sendorreceiveoperation?Also you wrote:
Yep, but you may end up with a message defined at the channel level that fits only one operation, and for the rest you have to define the message at the operation level. So what it value for the message in the channel level? This can only cause problems in understanding what message an operation takes.
If an operation will have the ability to define messages which will override those on the channel level then I can accept this, but I opt for having messages only on the operation level. Can you give me an episode of
ThinkingOutLoudor a discussion in which a channel-level message was proposed? Thanks!fmvilas commentedon Sep 7, 2021
There's an ongoing proposal for that. I didn't want to include it here on purpose to avoid bloating this issue so much: #531
That's the whole point. Not everyone is interested in operations. Many just want a menu of channels and messages and they don't care who sends or receives them.
The value is the one I described above. Those who want a menu of channels and their associated messages. Many people don't want to describe applications but their sources of data (topics aka channels).
Yes. An operation has the ability to override a channel's
messagedefinition. Now the question is, should we allow to completely override it? Or should the operation'smessagebe a subset of the channel'smessage? 🤔 The first gives you more freedom but potentially overcomplicates things. The second is more restrictive but gives you consistency.It wasn't proposed like this explicitly but here's a conversation with @dalelane about it: https://youtu.be/Qsu_yC-5YYM?t=535. I recommend you watch the whole episode.
jonaslagoni commentedon Sep 7, 2021
Is there a reason we have a
channelsfield in the root AsyncAPI object, would it not be enough to define it inside the operation object and components? 🤔The reason behind this is that I hate you have to manually match channel id's, if it can be avoided.
Gonna go with your examples to show the changes, remember in this case
$refcan be switched out completely with the channel object itself if you don't want to use that feature.This will help us in tooling, as:
And it still enables all the same things, but without complexity.
The
common.asyncapi.yamlfileThe
backend.asyncapi.yamlfileThe
frontend.asyncapi.yamlfileThe
notifications-service.asyncapi.yamlfileThe
comments-service.asyncapi.yamlfileDo you see any reason we would not do this? 🤔
fmvilas commentedon Sep 7, 2021
Because many people don't want to use AsyncAPI to define applications but a menu of channels, messages, servers, etc. Systems like event gateways are not interested in operations at all but in which channels and messages are available.
jonaslagoni commentedon Sep 7, 2021
@fmvilas forgot to add
componentsas well. Components still give you the menu? Of course, the channels now become secondary, instead of one of the primary attributes of the AsyncAPI file but it still enables the menu.We can of course just keep the
channelsfield, to enable the primary behavior. But I see no reason why operations must manually define the matching of channel id's. I just really want to remove this (manual) runtime matching ofchannelsif possible 😬magicmatatjahu commentedon Sep 7, 2021
@jonaslagoni You can read my comment about matching channels to the servers and why operating on the id (names) of the server/channel is better option rather than refs (and plain Server/Channel Object) -> #531 (comment)
@fmvilas Thanks, I'm starting to see that. With the proposal, we have an options:
Additionally, if messages were not defined at the channel level, but only at the operation level, we would have to have a tool that would retrieve these messages from operations - most likely we will have to have such a tool due to the fact that operations will be able to override messages from the channel.
The second option is better and more consistency. I don't know how to handle situation when you have defined on the channel level the 5 messages (by
oneOf) and in operation you wanna say that only second operation is handled, or all other without this second...fmvilas commentedon Sep 7, 2021
@jonaslagoni you're right. Actually, the
channelsfield in the root object is not for "menu" purposes but to define which channels this application is making use of, so forget my previous comment. I see not blocking reason for what you're saying. One reason I can think of is that, to know which channels are being used in an application, we'd have to scan all the operations first. Also, by having this matching we make it mandatory to reuse channel definitions, making it more difficult for people to duplicate stuff. An idea that comes to my mind is that we can disallow dereferencing there and instead you can only use$refbut that complicates things on the tooling side. And another reason is that we'd lose the channel id after dereferencing. Not sure if it's a problem though.In general, I'd not worry about tooling so much. Let's put the focus on the user experience. If it's better for the user, cool let's do it, if it's not, let's change it. Our decisions should be driven by users and not tooling difficulty/complexity. That said, there may be some good for UX in what you're proposing, especially that it would work with existing JSON Schema tools in editors.
fmvilas commentedon Sep 7, 2021
@magicmatatjahu Yes, we'd need such a tool but some people might not need it. E.g., those who don't use the
operationskeyword.Maybe we should make the channel's
messagework with message ids? This way we enforce messages having ids, which is another feature request: #458. It could look something like this:This would make it possible to check if
myMessage2is part of the channel'smessagesdefinition.magicmatatjahu commentedon Sep 7, 2021
@fmvilas Yes, it's a solution. However I see in this solution and with referencing the channels by
$ref(not by id/names) some problems (@jonaslagoni).If I have a situation when a given broker has in "menu" some channel and then I connect this channel in operation (in some app connected to broker), how do I know if a channel is unique in the system? To describe this in more detail, I will use an example. I have one broker and one application that is connected to the broker:
The
broker.yamlfileThe
app1.yamlfileHow can I tell that a particular channel is unique in the system and that is what it describes operations to? Even if we use channel identifiers, we still have a problem, because the identifier itself in
application 1may be different than the identifiers in the broker, where it is defined:The
broker.yamlfileThe
app1.yamlfileIt seems to me that the operation and the channel in its object should have something like
operationIDandchannelIDand these values should be unique in the whole system - then we have an easy way to refer to channels.The
broker.yamlfileThe
app1.yamlfileThe same problem occurs with the messages, how do I know if a message is unique in the system?
I deliberately did not use the channel's
addressbecause it can change (as was mentioned by Fran) and the channelID itself should not.Maybe I'm talking crap and it's not necessary 😆
EDIT: Ok 😄 on second thought, address can be treated as a
channelIDand references make sense here.fmvilas commentedon Sep 7, 2021
@magicmatatjahu I think you're getting a few things wrong here. Let me recap:
This definition is not semantically valid. This is not a menu, it's an application definition. Menus can only use
components. That's the reason we now havecomponents.channels. This is how you'd define a menu:Also, your broker is not a server of your applications but a remote so it should be like this:
Now we got a broker menu. Let's define app1.yaml:
This is how you know that App1 is using
channel1andchannel2, because they're being used in thechannelsobject. You don't need unique ids in the whole system because their ids are local to the file and that's ok.channel1andchannel2are the same assomeChannel1andsomeChannel2respectively. I just chose to use a different id to illustrate that ids are local. Does it make sense?magicmatatjahu commentedon Sep 7, 2021
@fmvilas Thanks for explanation, it makes sense 😅 Even if you are using the local id of the channels, you should have information (especially in tooling like our cupid) that the given channel is unique and for this you can use the channel's
addressand then we have connections:channel1 -> broker.yaml#/components/channels/someChannel1 -> channel's address
I edited my previous comment, maybe you read it too late.
77 remaining items
jonaslagoni commentedon Oct 24, 2022
@ivangsa It's not that they are by default not owned by the application. It is that they can* and it all depends on your use case and how you wish to integrate them. It's a pros and cons game as everything else 🙂 You can decide to take that approach and have all messages and channels defined as a menu all applications reference from, or you can have the information owned by the applications (as in version 2, that does not change, only how you define it).
If you go with a menu, It definitely can! In a larger organization, you would need to have processes in place for how global definitions change, but that's governance, right? 🤔 To me this is something you would need in any regard especially if you start to consider versioning, organization-wide design rules, etc.
When it's just the application that defines it, individuals get more control than having to change something in a global repository. But then you might lose reusability.
@magicmatatjahu the request/reply example (ignore the
replykeyword 😄) is a pretty nice representation of how messages, channels, and operations work together where channels are always/: https://github.com/asyncapi/spec/blob/edfce73dd90edaa0b720c47f1105039349e3ef9d/examples/kraken-websocket.ymlDo you find this confusing? And if yes, which parts?
From my perspective I quite like this setup, it's clean and clear what messages are in use for which operations. It is quite a change from v2, as you no longer have this all-in-one channel.
ivangsa commentedon Oct 24, 2022
@jonaslagoni ahh ok, the reference to the channel menu is just a normal reference, you can split into "channel menu" and "application" or use just one file... (or even $ref from the "channel menu" the channel defined on the "application")
thanks for the aclaration... I was thinking that the split as part of the specification.. is just a normal $ref
magicmatatjahu commentedon Oct 24, 2022
@jonaslagoni I perfectly understand the current status of v3 spea, but as I specified, these revert channels with the same address but with a different messages list (or a single message) causes, in my opinion, a worse of the UX of spec. Take an example where the
operation.messagesfield exists with a definition:then that spec example you gave could look like (I think that
operation.channel: nullmeans that the operation sends a response to the asker/sender? Please correct me if I am wrong):The
operation.messageswould have the advantage that it would be an optional field, that is, depending on what use case you have or how you want to do it, you can either base the logic on the channels themselves, or addoperation.messagesas a "filter" for the operation.I have a huge problem with the examples we have because we only use
channel.address,channel.messagesand sometimeschannel.description. The problem for me is that we forget that the channel itself can also have information likeservers,bindings,externalDocs,parametersetc and in the current situation when the channels differ only in the set of messages and the rest is the same (it means that you apply "filter" on which messages given operations can operate, but it's the same channel) we have to copy this data, e.g. (by editing the above mentioned spec):Of course, nothing prevents you from defining all these things in components and making refs everywhere, but in this case with the use of
operation.messagesyou would not have as much problem with the "reusability" of the channel and its parts. I see two solutions to the above problem:operation.messagesI like both options very much and they solve the above problem which I described in 2 different ways, but I would prefer to be able to use two solutions than just
channel.traits.There are, of course, use cases when defining
operation.messageswill not solve the problem and defining a separate channel with the same address is only a way.WDYT?
buehlefs commentedon Oct 24, 2022
Please also keep in mind that, regardless of what the spec will say a channel or an operation is, people will have their own understandings of these words (especially if they have not read the spec in detail yet). Going against these common understandings will only result in frequent misunderstandings.
An
operationis a thing you can do. The documentation for an operation should describe what is the expected result and what needs to be done to call/start the operation (and this information should be contained directly in the operation documentation if possible). In the AsyncAPI context this would be what message needs to be sent to / received from which channel (and what reply can be expected). This would align well with aoperation.messagekeyword.My intuitive understanding of a message list defined on a channel is that if I wiretap into the channel then I can observe these messages. This does not work if I have to define x channels with the same address as then I no longer have a single source of truth for the complete message list (which also goes against the original channel menu idea to some degree). Also defining these chnnels only because I need to do so to document my operations seems like a very cumbersome workaround at best.
I already wrote a comment outlining a detailed semantic for how a
operation.messagefield could work with channel message lists defined. This comment also describes a way to define the channel message list as "open" as in "open for extension" by operations or applications. This could be a middle ground between requiring all messages to be defined in the channel up front and definign all messages when needed in operations.fmvilas commentedon Oct 24, 2022
@magicmatatjahu you just gave me an idea and I proposed we apply it (slightly different): #847 (comment).
leandrorebelo commentedon Dec 14, 2022
It's an exciting proposal. I'm looking for something like this because We have this situation:
In this perspective, I have one Queue (Channel) to many Operations (Commands) and believe that the proposal fits the pattern because I can specify many Operations to a single Channel.
Thanks @fmvilas
jonaslagoni commentedon Mar 2, 2023
Just an update based on the issue TLDR. If there are additional changes that have been done for this issue that I have missed feel free to add them 🙂
Is currently not being championed for version 3: #689
Completed
Completed
Completed
Completed
Completed
That means overall this issue is done and has been implemented both in the parser, JSON Schema documents, and the spec itself 🎉
github-actions commentedon Jul 1, 2023
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience ❤️
fmvilas commentedon Jul 6, 2023
It's almost there, dear bot. Don't close it.
github-actions commentedon Nov 5, 2023
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience ❤️