-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
WIP: Initial POC for a new declarative WebSocket server API #38783
Conversation
mkouba
commented
Feb 14, 2024
- see also Towards a new websocket model #38473
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
...ns/websockets-next/server/runtime/src/main/java/io/quarkus/websockets/next/MessageCodec.java
Outdated
Show resolved
Hide resolved
...deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketServerProcessor.java
Show resolved
Hide resolved
...s/websockets-next/server/runtime/src/main/java/io/quarkus/websockets/next/runtime/Mutex.java
Outdated
Show resolved
Hide resolved
...s/websockets-next/server/runtime/src/main/java/io/quarkus/websockets/next/runtime/Mutex.java
Outdated
Show resolved
Hide resolved
...next/server/runtime/src/main/java/io/quarkus/websockets/next/runtime/ConcurrencyLimiter.java
Outdated
Show resolved
Hide resolved
Note: the current concurrency model needs to be revisited. First we should decide if we limit the concurrency per connection... |
Concurrency modelThere are 3 different execution models used to execute an endpoint callback:
The actual execution model is derived from the method signature and annotations. The goal is to design and implement a consistent concurrency model that would fit all the execution models listed above. Vert.x duplicated contextA server connection has an associated Vertx duplicated context. The Options
Current stateThere is a concurrency limiter component that implements option 1. Furthermore, there is a global config property to define the default timeout to process a message. We could add a timeout property to the callback annotations as well. UPDATE: I've added |
One important thing to mention is that the concurrency is per connection - not global. That said, I have been rethinking to the dev UI (which uses a web socket). In this case, we can have multiple concurrency messages (on the same connection), and the protocol we use (JSON-RPC) handles the "concurrency" by passing the correlation IDs. If we do not allow concurrent messages, we might limit ourselves, as there are protocols totally fine with that. |
The nice thing about serial execution is that you get pipelining semantics out of the box (since WebSocket guarantees ordering). That is, a client can send multiple messages, and they will receive responses in the same order. This is nice, and dare I say, should be a default. Being able to opt out of it should be possible, I guess. |
@cescoffier Yes, that's a good point. And the concurrency limiter mentioned in the "Current state" is scoped to the endpoint/connection as well.
I'm not sure I'm following here - the correlation ID is part of the payload, right? So you're saying that ordering does not matter here and possible parallel execution would be a gain.
@Ladicek Hm, a config switch to remove the concurrecy limiter...? |
Not necessarily saying a config switch, that would be extremely coarse grained. I'm not exactly sure what a good granularity would be. The endpoint might work well: |
- also rename WebSocket#value() to WebSocket#path() - and rename send() methods in test WSClient to sendAndAwait()
- add a test with a session scoped bean - fire context lifecycle events
- do not associate a new duplicated context with the connection - create a new duplicated context per message processing - activate/terminate CDI request context per message processing - rename DefaultWebSocketEndpoint to WebSocketEndpointBase - remove the current timeout implementation - add test for the CDI request context
I have refactored the contexts (Vert.x, CDI) as follows:
I've kept the default concurrency model ( I've removed the current implementation of timeouts because it was kind of useless. We could address this later (together with error handling). If there are no objections by next Monday I will squash the commits, rebase on main and mark the PR as ready for review. |
This pull request is superseded by #39142. However, I will keep this branch to preserve the history... |