Package me.internalizable.numdrassl.api.messaging
package me.internalizable.numdrassl.api.messaging
Cross-proxy messaging API for distributed Numdrassl deployments.
This package provides a pub/sub messaging system for communication between proxy instances, typically backed by Redis.
Important: This package uses @MessageSubscribe for
cross-proxy messages. Do not confuse with @Subscribe from
api.event which is for local proxy events.
Core Interfaces
MessagingService- Main service for publishing and subscribingSubscription- Represents an active subscriptionMessageHandler- Callback for received messagesPluginMessageHandler- Typed callback for plugin messages
Channels
MessageChannel- Represents a pub/sub channelChannels- Predefined system channelsSystemChannel- Enum of system channel types
Messages
ChannelMessage- Base interface for all messagesme.internalizable.numdrassl.api.messaging.message- Concrete message types package
Annotations
MessageSubscribe- Marks methods as cross-proxy message handlersTypeAdapter- Custom serialization for message payloads
Usage Examples
Programmatic API
MessagingService messaging = proxy.getMessagingService();
// Subscribe to system messages
messaging.subscribe(Channels.HEARTBEAT, HeartbeatMessage.class,
(channel, msg) -> logger.info("Proxy {} alive", msg.sourceProxyId()));
// Subscribe to plugin messages
messaging.subscribePlugin("my-plugin", "events", MyData.class,
(sourceProxyId, data) -> handleData(data));
// Publish plugin messages
messaging.publishPlugin("my-plugin", "events", new MyData(...));
Annotation API
@Plugin(id = "my-plugin", name = "My Plugin", version = "1.0.0")
public class MyPlugin {
@MessageSubscribe(channel = "events")
public void onEvent(MyData data) {
// Plugin ID inferred from @Plugin annotation
}
@MessageSubscribe(SystemChannel.CHAT)
public void onChat(ChatMessage msg) {
// System channel subscription
}
}
// Register
messaging.registerListener(myPlugin);
- See Also:
-
InterfacesClassDescriptionBase interface for all cross-proxy messages.Service for cross-proxy messaging via pub/sub.Represents an active subscription to a messaging channel.