cxRmi library
The cxRmi library is Message Oriented Middleware (MOM) and allows for
Remote Method Invocation (RMI) over TCP/IP.
A stub acts as a local proxy of the remote object, enabling clients to make calls on the remote
object (the receiver) as if it were local.
A skeleton is responsible for translating incoming messages to calls on the receiver object.
The implementation is layered on top of MultiplexedMsgConnection
which supports multiplexed messages over TCP/IP.
A $interface with the 'rmi' qualifier is used to define the
message protocol on some interface.
The cxRmi layer is intentionally a simple, lightweight high performance middleware layer:
- It is point to point (P2P)
- There is no message broker
- Messages are associated with function calls which can have any number of in/out/in-out
parameters of any serialisable data type
- Messages are transient
- It is single producer (only one thread can send messages through the stub at a time)
- It is single consumer (only one thread can process received messages at a time)
- Messages exist in a message queue and are received in the order they are sent
- Data integrity and delivery of messages are guaranteed through TCP/IP
(by retransmitting until the receiver acknowledges the reception of the packet).
- Calls through the stub are always buffered and never block on I/O
(notwithstanding page faults if the entire process runs out of memory)
- Functions with no out parameters are optimised to avoid a response message (they are one-way)
- All functions can be called asynchronously (meaning the sender can make many send requests then wait
for the responses of the two-way functions)
Although the following are not supported they could easily be layered on top:
- Persistent messages
- Message brokers
- Fanout
- Publish/subscribe
- Multiple producers
- Multiple consumers
- Allowing for object graphs
- Supporting the Java Message Service (JMS) API
Sending side
On the stub side the following steps are used to send messages for some interface Ix.
- Obtain a MultiplexedMsgConnection
- Call CreateRmiCaller<Ix>() to create an RmiCaller
which will send messages over the given MultiplexedMsgConnection
- Create an object that implements interface IRmiCallerHandler, that will receive
notifications of when the MultiplexedMsgConnection is ready to receive more messages for the purpose of
throttling the producer. Call SetHandler() on the RmiCaller.
- Call GetStub<Ix>() on the RmiCaller to retrieve the client side stub which implements interface Ix
- Make synchronous or asynchronous calls through the stub as required.
Receiving side
On the skeleton side the following steps are used to receive messages for some interface Ix.
- Obtain a MultiplexedMsgConnection
- Create an object that implements the rmi interface, that will receive incoming messages
- Call CreateRmiCallee<Ix>() to create and bind a skeleton to the
MultiplexedMsgConnection for the given interface, and which
will translate incoming messages to calls on the receiver object
Memory management
The implementation avoids any association with CSpaces and visiting of
IObjects. The stub is
automatically deleted when the RmiCaller is closed. The skeleton is automatically deleted when the
RmiCallee is closed. The client must ensure the receiver object outlives the RmiCallee.
Performance
The implementation is state of the art, as shown by these performance measurements.
Public header files
cxRmi