Interface MessageTransport
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
LoopbackTransport, RedisMessageTransport
A transport knows nothing about payload types or channels beyond routing:
it accepts an already-encoded MessageEnvelope on publish(MessageEnvelope),
and pushes decoded envelopes it receives to the MessageTransport.EnvelopeSink supplied
at start(MessageTransport.EnvelopeSink). The two shipped implementations are the default
plugin-messaging transport (per platform) and the Redis pub/sub transport;
both are interchangeable behind this SPI, so a network can run with or without
Redis.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceReceives envelopes arriving from the network. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops the transport and releases resources.default booleanReturns whether the transport is currently connected/operational.name()Human-readable transport name for diagnostics/logging (for example "plugin-messaging", "redis").voidpublish(MessageEnvelope envelope) Publishes an encoded envelope to the network.voidStarts the transport and begins delivering received envelopes to the sink.
-
Method Details
-
name
String name()Human-readable transport name for diagnostics/logging (for example "plugin-messaging", "redis").- Returns:
- transport name
-
start
Starts the transport and begins delivering received envelopes to the sink.Called once before any
publish(MessageEnvelope). Implementations that need a background subscriber thread or channel registration set it up here.- Parameters:
sink- destination for received envelopes
-
publish
Publishes an encoded envelope to the network.The envelope's
Targetis advisory; transports that cannot route precisely broadcast and rely on receiver-side filtering.- Parameters:
envelope- envelope to send
-
isConnected
default boolean isConnected()Returns whether the transport is currently connected/operational.The default plugin-messaging transport reports connectivity based on whether the platform channel is registered; Redis reports pool health.
- Returns:
- true when the transport can currently deliver messages
-
close
void close()Stops the transport and releases resources.- Specified by:
closein interfaceAutoCloseable
-