Back to EIP

PatternThe document message transfers data from one application to another. The focus is on the data and reliability, not on the timing of the transfer.
How Ballerina helps

Ballerina supports sending and receiving data in multiple formats such as JSON and XML over different protocols such as HTTP, GRPC, Kafka, etc. Depending on the protocol, Ballerina provides different reliability mechanisms. As an example, the Ballerina HTTP client supports retries, load balancing, and circuit breaking.

Document MessageMessage ChannelMessage EndpointPoint-to-Point ChannelRequest-Reply
import ballerina/http;
import ballerina/mime;

type CsvRequest record {|
    string org;
    string filename;

type ZohoResponse record {|
    string status;
    string code;
    string message;
    record {|
        string file_id;
        string created_time;
    |} details;

final http:Client zohoClient = check new ("",
    // Retry 3 times with 1 second interval for error codes 404, 408, and 500.
    retryConfig = {count: 3, interval: 1, statusCodes: [404, 408, 500]}

service /crm on new http:Listener(8080) {
    resource function post bulkUploadLeads(CsvRequest csvRequest) returns ZohoResponse|error {
        http:Request request = new;
        request.addHeader("feature", "bulk-write");
        request.setFileAsPayload("./ftpincoming/" + csvRequest.filename, contentType = mime:MULTIPART_FORM_DATA);
        return zohoClient->/crm/v5/;