wamp2spring is a Java implementation of the WAMP specification built on top of the WebSocket support of Spring 7.
WAMP is a WebSocket subprotocol that provides two application messaging patterns: Remote Procedure Calls and Publish / Subscribe.
wamp2spring implements the Basic Profile with a single shared routing scope. Connections, registrations, subscriptions, and meta APIs are handled without realm-based partitioning during session establishment or routing.
Additionally wamp2spring implements a few features from the Advanced Profile:
| Feature | Remark |
|---|---|
| call_canceling | Dealer-side CANCEL / INTERRUPT with skip, kill, and killnowait. Advanced cancel modes require caller negotiation; unsupported callees fall back to dealer-managed behavior. |
| call_timeout | Dealer-enforced CALL.Options.timeout. Timeout intent is forwarded to callees that advertise support, but timeout semantics remain enforced by the dealer. |
| progressive_call_results | Dealer-side negotiation and forwarding of CALL.Options.receive_progress, INVOCATION.Details.receive_progress, progressive YIELD, and progressive RESULT, while keeping the invocation open until the final YIELD or ERROR. |
| caller_identification | disclose_me option in the CALL message. Specification |
| registration_revocation | Dealer-side administrative revocation of registrations, with extended UNREGISTERED delivery to callees that advertised support. |
| subscriber_blackwhite_listing | Exclude and include receivers with their WAMP session id. Only eligible and exclude options are implemented. Specification. |
| publisher_exclusion | exclude_me option in the PUBLISH message. By default the publisher is excluded from receiving the EVENT message. Specification |
| publisher_identification | disclose_me option in the PUBLISH message. Specification |
| pattern_based_subscription | Prefix- and wildcard matching policies for subscriptions. Specification |
| event_retention | Specification |
| testament_meta_api | wamp.session.add_testament and wamp.session.flush_testaments with detached/destroyed scopes and disconnect-triggered publication order. |
For Advanced RPC timeout handling, the dealer is the source of truth once a caller and the router negotiated call_timeout.
If a callee also advertises timeout support, the dealer forwards the timeout value in INVOCATION.Details.timeout.
If the callee does not advertise timeout support, the dealer still enforces the timeout and returns the appropriate timeout error to the caller.
WAMP-level authorization can be extended with one or more Spring beans implementing WampAuthorizer.
The dealer and broker consult these authorizers for REGISTER, CALL, SUBSCRIBE, and PUBLISH before routing,
and authorizers can deny an operation with wamp.error.not_authorized or wamp.error.authorization_failed.
Dataformats
wamp2spring supports JSON (wamp.2.json) and MessagePack (wamp.2.msgpack) required by the Basic Profile. In addition it
supports CBOR (wamp.2.cbor) and SMILE (wamp.2.smile).
Fallback
The servlet module also provides an HTTP long-poll transport. Enable it on a Spring configuration class with
@EnableServletWampLongpoll (ch.rasc.wamp2spring.servlet.longpoll). This registers these POST endpoints:
| Endpoint | Request / response |
|---|---|
/wamp/open |
Send {"protocols":["wamp.2.json"]} as JSON. The response contains the selected protocol and a transport ID. The original singular protocol request field is also accepted. |
/wamp/{transport}/send |
Send one serialized WAMP message. Successful requests return HTTP 204; malformed messages return HTTP 400. |
/wamp/{transport}/receive |
Receive one serialized WAMP message, or HTTP 204 when the receive timeout expires. Only one receive may be pending per transport; overlapping receives return HTTP 409. |
/wamp/{transport}/close |
Close the transport and release its WAMP session, subscriptions, and registrations. Successful requests return HTTP 204. |
After opening a transport, send HELLO and receive WELCOME (or complete WAMP authentication) before sending
application messages. JSON, MessagePack, CBOR, and SMILE are supported; batched protocols are not supported.
The opening handshake accepts the protocols list described in the
WAMP HTTP Longpoll Transport specification.
Implement WampServletLongpollConfigurer to change getReceiveTimeout() (default 30 seconds),
getTransportIdleTimeout() (default 60 seconds), or getMaxQueueSize() (default 100 messages).
Idle transports are checked automatically at the idle-timeout interval. Active receives are preserved;
outbound traffic alone does not keep an abandoned transport alive. Queue overflow closes the transport.
See Wiki
See Wiki
You find a collection of example applications in the wamp2spring-demo GitHub repository.
See Wiki
See Wiki
Code released under the Apache license.