corda / net.corda.core.messaging

Package net.corda.core.messaging

Types

Ack object Ack : DeserializeAsKotlinObjectDef

A general Ack message that conveys no content other than it's presence for use when you want an acknowledgement from a recipient. Using Unit can be ambiguous as it is similar to Void and so could mean no response.

AllPossibleRecipients interface AllPossibleRecipients : MessageRecipients

A special base class for the set of all possible recipients, without having to identify who they all are.

CordaRPCOps interface CordaRPCOps : RPCOps

RPC operations that the node exposes to clients using the Java client library. These can be called from client apps and are implemented by the node in the CordaRPCOpsImpl class.

FlowHandle data class FlowHandle<A>

FlowHandle is a serialisable handle for the started flow, parameterised by the type of the flow's return value.

Message interface Message

A message is defined, at this level, to be a (topic, timestamp, byte arrays) triple, where the topic is a string in Java-style reverse dns form, with "platform." being a prefix reserved by the platform for its own use. Vendor specific messages can be defined, but use your domain name as the prefix e.g. "uk.co.bigbank.messages.SomeMessage".

MessageHandlerRegistration interface MessageHandlerRegistration
MessageRecipientGroup interface MessageRecipientGroup : MessageRecipients

A base class for a set of recipients specifically identified by the sender.

MessageRecipients interface MessageRecipients

The interface for a group of message recipients (which may contain only one recipient)

MessagingService interface MessagingService

A MessagingService sits at the boundary between a message routing / networking layer and the core platform code.

RPCOps interface RPCOps

Base interface that all RPC servers must implement. Note: in Corda there's only one RPC interface. This base interface is here in case we split the RPC system out into a separate library one day.

ReceivedMessage interface ReceivedMessage : Message
SingleMessageRecipient interface SingleMessageRecipient : MessageRecipients

A base class for the case of point-to-point messages

StateMachineInfo data class StateMachineInfo
StateMachineUpdate sealed class StateMachineUpdate
TopicSession data class TopicSession

An identifier for the endpoint MessagingService message handlers listen at.

TopicStringValidator object TopicStringValidator

A singleton that's useful for validating topic strings

Annotations

RPCReturnsObservables annotation class RPCReturnsObservables

If an RPC is tagged with this annotation it may return one or more observables anywhere in its response graph. Calling such a method comes with consequences: it's slower, and consumes server side resources as observations will buffer up on the server until they're consumed by the client.

Functions

createMessage fun MessagingService.createMessage(topic: String, sessionID: Long = DEFAULT_SESSION_ID, data: ByteArray): Message

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

onNext fun <M : Any> MessagingService.onNext(topic: String, sessionId: Long): ListenableFuture<M>

Returns a ListenableFuture of the next message payload (Message.data) which is received on the given topic and sessionId. The payload is deserialized to an object of type M. Any exceptions thrown will be captured by the future.

runOnNextMessage fun MessagingService.runOnNextMessage(topic: String, sessionID: Long, callback: (ReceivedMessage) -> 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 aren't supposed to stick around permanently. Note that this callback doesn't 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, callback: (ReceivedMessage) -> 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 aren't supposed to stick around permanently. Note that this callback doesn't take the registration object, unlike the callback to MessagingService.addMessageHandler.

send fun MessagingService.send(topic: String, sessionID: Long, payload: Any, to: MessageRecipients, uuid: UUID = UUID.randomUUID()): Unit
fun MessagingService.send(topicSession: TopicSession, payload: Any, to: MessageRecipients, uuid: UUID = UUID.randomUUID()): Unit
startFlow fun <T : Any, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: () -> R): FlowHandle<T>

These allow type safe invocations of flows from Kotlin, e.g.:

fun <T : Any, A, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A) -> R, arg0: A): FlowHandle<T>
fun <T : Any, A, B, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B) -> R, arg0: A, arg1: B): FlowHandle<T>
fun <T : Any, A, B, C, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C) -> R, arg0: A, arg1: B, arg2: C): FlowHandle<T>
fun <T : Any, A, B, C, D, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C, D) -> R, arg0: A, arg1: B, arg2: C, arg3: D): FlowHandle<T>