com.r3corda.node.services.api / MessagingServiceInternal

MessagingServiceInternal

interface MessagingServiceInternal : MessagingService


Inherited Properties

myAddress abstract val myAddress: SingleMessageRecipient

Returns an address that refers to this node.

Functions

stop abstract fun stop(): Unit

Initiates shutdown: if called from a thread that isnt controlled by the executor passed to the constructor then this will block until all in-flight messages have finished being handled and acknowledged. If called from a thread thats a part of the AffinityExecutor given to the constructor, it returns immediately and shutdown is asynchronous.

Inherited Functions

addMessageHandler abstract fun addMessageHandler(topic: String = "", sessionID: Long = DEFAULT_SESSION_ID, executor: Executor? = null, 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.

abstract fun addMessageHandler(topicSession: TopicSession, executor: Executor? = null, 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 abstract fun createMessage(topic: String, sessionID: Long = DEFAULT_SESSION_ID, data: ByteArray): Message
abstract fun createMessage(topicSession: TopicSession, data: ByteArray): Message

Returns an initialised Message with the current time, etc, already filled in.

removeMessageHandler abstract 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 abstract 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.

Extension Functions

runOnNextMessage fun MessagingService.runOnNextMessage(topic: String, sessionID: Long, executor: Executor? = null, callback: (Message) -> Unit): Unit

Registers a handler for the given topic and session ID that runs the given callback with the message and then removes itself. This is useful for one-shot handlers that arent supposed to stick around permanently. Note that this callback doesnt take the registration object, unlike the callback to MessagingService.addMessageHandler, as the handler is automatically deregistered before the callback runs.

fun MessagingService.runOnNextMessage(topicSession: TopicSession, executor: Executor? = null, callback: (Message) -> Unit): Unit

Registers a handler for the given topic and session that runs the given callback with the message and then removes itself. This is useful for one-shot handlers that arent supposed to stick around permanently. Note that this callback doesnt take the registration object, unlike the callback to MessagingService.addMessageHandler.

send fun MessagingService.send(topic: String, sessionID: Long, payload: Any, to: MessageRecipients): Unit
fun MessagingService.send(topicSession: TopicSession, payload: Any, to: MessageRecipients): Unit

Inheritors

ArtemisMessagingClient class ArtemisMessagingClient : ArtemisMessagingComponent, MessagingServiceInternal

This class implements the MessagingService API using Apache Artemis, the successor to their ActiveMQ product. Artemis is a message queue broker and here we run a client connecting to the specified broker instance ArtemisMessagingServer.

InMemoryMessaging 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.