inner class InMemoryMessaging : SingletonSerializeAsToken, MessagingServiceInternal
An InMemoryMessaging provides a MessagingService that isnt backed by any kind of network or disk storage system, but just uses regular queues on the heap instead. It is intended for unit testing and developer convenience when all entities on the network are being simulated in-process.
An instance can be obtained by creating a builder and then using the start method.
Handler |
inner class Handler : MessageHandlerRegistration |
<init> |
InMemoryMessaging(manuallyPumped: Boolean, handle: Handle) An InMemoryMessaging provides a MessagingService that isnt backed by any kind of network or disk storage system, but just uses regular queues on the heap instead. It is intended for unit testing and developer convenience when all entities on the network are being simulated in-process. |
myAddress |
val myAddress: SingleMessageRecipient Returns an address that refers to this node. |
addMessageHandler |
fun addMessageHandler(topic: String, sessionID: Long, executor: Executor?, callback: (Message, MessageHandlerRegistration) -> Unit): MessageHandlerRegistration The provided function will be invoked for each received message whose topic matches the given string, on the given executor. fun addMessageHandler(topicSession: TopicSession, executor: Executor?, callback: (Message, MessageHandlerRegistration) -> Unit): MessageHandlerRegistration The provided function will be invoked for each received message whose topic and session matches, on the given executor. |
createMessage |
fun createMessage(topic: String, sessionID: Long, data: ByteArray): Message fun createMessage(topicSession: TopicSession, data: ByteArray): Message Returns the given (topic & session, data) pair as a newly created message object. |
pumpReceive |
fun pumpReceive(block: Boolean): MessageTransfer? Delivers a single message from the internal queue. If there are no messages waiting to be delivered and block is true, waits until one has been provided on a different thread via send. If block is false, the return result indicates whether a message was delivered or not. |
removeMessageHandler |
fun removeMessageHandler(registration: MessageHandlerRegistration): Unit Removes a handler given the object returned from addMessageHandler. The callback will no longer be invoked once this method has returned, although executions that are currently in flight will not be interrupted. |
send |
fun send(message: Message, target: MessageRecipients): Unit Sends a message to the given receiver. The details of how receivers are identified is up to the messaging implementation: the type system provides an opaque high level view, with more fine grained control being available via type casting. Once this function returns the message is queued for delivery but not necessarily delivered: if the recipients are offline then the message could be queued hours or days later. |
stop |
fun stop(): Unit |
toToken |
open fun toToken(context: SerializeAsTokenContext): SerializationToken |