1 Events
Ralph Schaer edited this page 2026-10-30 16:08:52 +01:00

Spring application events

The router publishes events from ch.rasc.wamp2spring.event. Listen with Spring's @EventListener; these Java events are distinct from WAMP EVENT messages and the public MetaAPIs topics.

Event Meaning
WampSessionEstablishedEvent WAMP session established after HELLO/authentication
WampDisconnectEvent Transport session ended; triggers router cleanup
WampRegistrationCreatedEvent A registration entry was created
WampProcedureRegisteredEvent A callee joined a registration
WampProcedureUnregisteredEvent A callee left a registration
WampRegistrationDeletedEvent The registration entry was deleted
WampSubscriptionCreatedEvent A subscription entry was created
WampSubscriptionSubscribedEvent A remote subscriber joined
WampSubscriptionUnsubscribedEvent A remote subscriber left
WampSubscriptionDeletedEvent The subscription entry was deleted

Registration/subscription creation differs from each callee/subscriber joining: multiple peers can share an entry. Disconnect processing generates removal events as the broker and dealer clean up their registries.

import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import ch.rasc.wamp2spring.event.WampSessionEstablishedEvent;
import ch.rasc.wamp2spring.event.WampDisconnectEvent;

@Component
public class WampLifecycleListener {
  @EventListener
  public void connected(WampSessionEstablishedEvent event) {
    System.out.println("WAMP session established: " + event.getWampSessionId());
  }

  @EventListener
  public void disconnected(WampDisconnectEvent event) {
    System.out.println("Transport closed: " + event.getWebSocketSessionId());
  }
}

The WampEvent base class exposes principal, WAMP session ID, transport session ID, auth ID, auth role, auth method, and auth provider. A disconnect can occur before WAMP establishment, so code should handle an absent WAMP session ID. WampProcedureEvent adds procedure URI and registration ID; WampSubscriptionEvent adds SubscriptionDetail, including topic, match policy, and subscription options.

Event delivery uses the application's Spring event multicaster. Keep synchronous listeners short because they run as part of connection or routing work.

Source: event classes.