com.r3corda.node.services.messaging / ArtemisMessagingClient

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

Parameters

serverHostPort - The address of the broker instance to connect to (might be running in the same process)

myHostPort - What host and port to use as an address for incoming messages

defaultExecutor - This will be used as the default executor to run message handlers on, if no other is specified.


Types

Handler data class Handler : MessageHandlerRegistration

A registration to handle messages of different types

Constructors

<init> ArtemisMessagingClient(directory: Path, config: NodeConfiguration, serverHostPort: <ERROR CLASS>, myHostPort: <ERROR CLASS>, defaultExecutor: Executor = RunOnCallerThread)

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

Properties

defaultExecutor val defaultExecutor: Executor
myAddress val myAddress: SingleMessageRecipient

Returns an address that refers to this node.

myHostPort val myHostPort: <ERROR CLASS>
serverHostPort val serverHostPort: <ERROR CLASS>

Inherited Properties

config val config: NodeConfiguration
directory val directory: Path

Functions

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(topicSession: TopicSession, data: ByteArray): Message
fun createMessage(topic: String, sessionID: Long, data: ByteArray): Message

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

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.

start fun start(): Unit
stop fun stop(): Unit

Inherited Functions

configureWithDevSSLCertificate fun configureWithDevSSLCertificate(): Unit

Strictly for dev only automatically construct a server certificate/private key signed from the CA certs in Node resources. Then provision KeyStores into certificates folder under node path.

tcpTransport fun tcpTransport(direction: ConnectionDirection, host: String, port: Int): <ERROR CLASS>

Companion Object Properties

SESSION_ID_PROPERTY val SESSION_ID_PROPERTY: String
TOPIC_PROPERTY val TOPIC_PROPERTY: String
log val log: <ERROR CLASS>

Companion Object Functions

makeRecipient fun makeRecipient(hostAndPort: <ERROR CLASS>): SingleMessageRecipient

Temp helper until network map is established.

fun makeRecipient(hostname: String): <ERROR CLASS>
toHostAndPort fun toHostAndPort(hostname: String): <ERROR CLASS>

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