Skip to content
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

Operation with both send and receive action #1083

Open
rzorzorzo opened this issue Jan 12, 2025 · 3 comments
Open

Operation with both send and receive action #1083

rzorzorzo opened this issue Jan 12, 2025 · 3 comments
Labels
❔ Question A question about the spec or processes

Comments

@rzorzorzo
Copy link

There are operations which may be both in- and outbound.

example: websocket. operationid: "lock". client sends a message to lock a resource. the server forwards this message to all clients.
the same operation "lock" is therfore sent and received.

How is this specified with asyncapi ?

action can only take the value send or receive. it does not allow a list, nor is send-receive available.
on the other hand in the operations list the operationid is unique, so there is no way to define 2 operations with the same operationid but different action values.

@rzorzorzo rzorzorzo added the ❔ Question A question about the spec or processes label Jan 12, 2025
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link
Member

derberg commented Jan 13, 2025

Hey there, there are not too many details in your question so lemme do some followups.

the same operation "lock" is therfore sent and received.

AsyncAPI document of your client should have a send operation (it sends lock) and reply object (as in reply it gets a message, in this case lock as well). This is the simplest answer I can give. You would have to provide example document, with channel structure, so I can tell you more.

it does not allow a list, nor is send-receive available.

I don't know what you mean really, sorry.

so there is no way to define 2 operations with the same operationid

Can you elaborate more on why would you like to have 2 operations with the same operationId? maybe you have come code you can share already?

Also linking this document that shows different examples on how to use reply object: https://www.asyncapi.com/docs/concepts/asyncapi-document/reply-info

@rzorzorzo
Copy link
Author

thanks for the fast reply

AsyncAPI document of your client should have a send operation (it sends lock) and reply object (as in reply it gets a message, in this case lock as well). This is the simplest answer I can give. You would have to provide example document, with channel structure, so I can tell you more.

a reply is the following flow:

client1 -> channel -> client1

what I mean is the following use case: (-> stands for transmitting the lock operation)

client1 -> channel -> client2
at some later time:
client2 -> channel -> client1

a possible specification of this use case would be:

"operations": {
"lock": {
"action": "send",
"channel": {
"$ref": "#/channels/root"
}
},
"lock": {
"action": "receive",
"channel": {
"$ref": "#/channels/root"
}
},
}

which is not possible.
or:

"operations": {
"lock": {
"action": "send-receive",
"channel": {
"$ref": "#/channels/root"
}
},
}

or:

"operations": {
"lock": {
"action":["send", "receive"],
"channel": {
"$ref": "#/channels/root"
}
},
}

hope this helps clarify the requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❔ Question A question about the spec or processes
Projects
None yet
Development

No branches or pull requests

2 participants