Back to EIP

PatternMessage Endpoint is a client of the messaging channel. It abstracts the details of communication to the application.
How Ballerina helps

Ballerina supports a rich set of libraries that abstract various messaging protocols (such as HTTP, gRPC, and Kafka) and provides a Client interface that acts as a message endpoint.

Message EndpointMessage Channel
Copy
import ballerina/http;

type Currency "AUD"|"INR"|"BGP";

final readonly & map<decimal> rates = {
    "AUD": 1.59,
    "INR": 83.24,
    "GBP": 0.83
};

service /api/v1/rates on new http:Listener(8080) {
    isolated resource function get covert(Currency base, Currency target, decimal amount = 1.00) returns decimal {
        decimal baseUsdValue = rates.get(base);
        decimal targetUsdValue = rates.get(target);
        return (targetUsdValue / baseUsdValue) * amount;
    }
}