C2C
Component-2-Component Communication
This feature enable you to set a direct communication channels between components. This save you from the hassle of configure the I/S just to transfer data between components. There are two types of data transports the library support 'message queue' and 'node express'.
The classes involving the C2C:
TxQueuePoint - an object able to connect, send and receive data from other end-point components. It has internally an object implement TxConnector interface. the TxConnector define three methods connect, nextand subscribe. The TxConnector implement the underline detail of your transport details. The class implement TxConnector, whether it is default TxConnectorRabbitMQ or your implementation, is injected into TxQueuePoint during creation.
To use your implementation of TxConnector you need to register it on the TxQueuePointRegistry using setDriver method.
TxRoutePoint - work the same as TxQueuePoint but iot use node express as the underline communication I/S.
To use your implementation of TxConnector you need to register it on the TxRoutePointRegistry using setDriver method.
TxQueuePointRegistry - an object able to create, store and retrieve TxQueuePoint objects. Use the method TxQueuePointRegistry.setDriver to register your driver (class that implement TxConnector).
TxRoutePointRegistry - an object able to create, store and retrieve TxRoutePoint objects. Use the method TxQueuePointRegistry.setDriver to register your driver (class that implement TxConnector).
How It Work
set you driver - first you need to define a connector driver. a driver is an object implement
TxConnector
interface.
NOTE: if you are using RabbitMQ message queue then you can use the builtin support for RabbitMQ, so safly you can skip the driver stuff.
See the builtin TxConnectorRabbitMQ for an example.
The driver is one for all components. API is as follow:
subscribe - a registration callback method where you will get the data.
next - sending data to other service on a service/route.
connect - set the connection. In the case RabbitMQ is set the exchange/queue/binding. This way other components may recognaize you.
Once your driver is working you need to register it into TxQeuePointRegistry as:
use subscribe / next - now you can define your connector (or use the builtin RabbitMQ connector) to define subscribe and next methods to receive and send data.
See the following example:
Last updated