Adapter Implementation
1. Overview
A new adapter can be created using this link. Once the adapter is created we can incorporate this apater in inbound and outbound service for receiving and sending message to user respectively.
Below is the process on how to implement a adapter in inbound & outbound.
2. Inbound Implementation
Inbound receives the messages from a channel, and uses the channel adapter to convert it to XMessage format. Once the messages is converted it will get processed.
When a new adapter is created we will have to add a class that will receive the messages from channel and use the adapter to convert this message to XMessage.
In the next section of the document, we will see the sample code for the same.
2.1 Setup inbound
Follow the steps below to setup the inbound repository to start working on it.
Fork the below repository & clone it.
https://github.com/samagra-comms/inbound/
Checkout to the recent stable
master
branch.Open the project in any IDE spring/intellij.
Follow the next steps.
2.2 Sample Code
Create a class for the channel & provider for the adapter created. Eg. NetcoreWhatsappController.
Once the class is create, we can use the link http://host:port/provider/channel to receive messages from user. A user will receive a message in below format.
A sample api to receive messages from user is given below.
2.3 Existing Implementations
Below are some of the existing implementation code of currently available adapters.
3. Outbound Implementation
Outbound converts the xMessage to the one that will be sent to the channel(sms/whatsapp). It will then be sent to the network provider who will send it to the channel using the implementation done in adapter.
Outbound uses this OutboundKafkaController class to send messages to user. There is class called ProviderFactory which uses the channel & provider set in the XMessage and return the adapter object which will be used to call the processOutBoundMessageF method.
3.1 Sample code
Add code to return adapter object based on the channel & provider set in XMessage.
Once the code is added, we should be able to use the new adapter to sent messages to user.
Last updated