public class InNetMessagePool extends Object implements Service
Dispatching can operate in different modes configured by transport layer: - Direct dispatch on caller thread (low latency), - Queued dispatch with threaded processing for higher concurrency.
Thread-safe queues from java.util.concurrent provide efficient, lock-free concurrency, minimizing blocking and wake overhead.
| Constructor and Description |
|---|
InNetMessagePool(RouterContext context)
Constructs the message pool with given context.
|
| Modifier and Type | Method and Description |
|---|---|
int |
add(I2NPMessage messageBody,
RouterIdentity fromRouter,
Hash fromRouterHash)
Adds a new inbound message to be processed.
|
int |
add(I2NPMessage messageBody,
RouterIdentity fromRouter,
Hash fromRouterHash,
long msgIDBloomXor)
Adds a new inbound message with optional bloom filter XOR id.
|
int |
handleReplies(I2NPMessage messageBody)
Handles replies for outbound messages that correspond to this inbound message.
|
HandlerJobBuilder |
registerHandlerJobBuilder(int i2npMessageType,
HandlerJobBuilder builder)
Registers or replaces a HandlerJobBuilder for a given message type.
|
void |
renderStatusHTML(Writer out)
Render the status of this message pool as HTML.
|
void |
restart()
Restart the message pool by shutting down and then starting up again.
|
void |
shutdown()
Shutdown the message pool, stopping all dispatchers and clearing queued messages.
|
void |
startup()
Startup the message pool and, if configured, start dispatcher threads.
|
public InNetMessagePool(RouterContext context)
context - router context for environment accesspublic int add(I2NPMessage messageBody, RouterIdentity fromRouter, Hash fromRouterHash)
The message is either dispatched directly or queued for processing, depending on configuration. It supports detection of duplicates, expired messages, and dispatches messages to appropriate handlers or jobs.
messageBody - the inbound message to add, not nullfromRouter - the router identity the message is from, may be nullfromRouterHash - the hash of the router it is from, may be null (will be computed if so)public int add(I2NPMessage messageBody, RouterIdentity fromRouter, Hash fromRouterHash, long msgIDBloomXor)
messageBody - message to add (non-null)fromRouter - source router identity (may be null)fromRouterHash - source router hash (may be null, computed if null)msgIDBloomXor - XOR value for message unique ID in bloom filterpublic int handleReplies(I2NPMessage messageBody)
messageBody - inbound message for which replies are handledpublic HandlerJobBuilder registerHandlerJobBuilder(int i2npMessageType, HandlerJobBuilder builder)
i2npMessageType - I2NP message type (0 to MAX_I2NP_MESSAGE_TYPE)builder - handler job builder for this typeArrayIndexOutOfBoundsException - if message type out of boundspublic void renderStatusHTML(Writer out)
renderStatusHTML in interface Serviceout - the Writer to output HTML topublic void restart()
public void shutdown()