Back to Examples
- Binding patterns
- Typed binding pattern
- Wildcard binding pattern
- List binding patterns
- Rest binding pattern in list binding pattern
- Mapping binding pattern
- Rest binding pattern in mapping binding pattern
- Error binding pattern
- Rest binding pattern in error binding pattern
- Single use of typed binding patterns
- Single use of typed binding patterns with on fail clause
- Iterative use of typed binding patterns
- List binding pattern in match statement
- Mapping binding pattern in match statement
- Error binding pattern in match statement
- Query expressions
- Sort iterable objects
- Let clause
- Limit clause
- Join iterable objects
- Outer Join clause
- Query tables
- Create tables with a query
- Create maps with a query
- Create streams with a query
- On conflict clause
- Advanced conflict handling
- Iterate over XML with a query
- Nested query expressions
- Destructure records using a query
- Querying streams
- Aggregation
- JSON type
- Access JSON elements
- Access optional JSON elements
- Match statement with maps
- Convert from user-defined type to JSON
- Convert from table and XML to JSON
- Convert from JSON to user-defined type
- Cast JSON to user-defined type
- Resource method typing
- JSON numbers
- JSON to record
- JSON to record with projection
- JSONPath expressions
- Asynchronous function calls
- Named workers
- Sequence diagrams
- Wait for workers
- Strands
- Named worker return values
- Alternate wait
- Multiple wait
- Named workers and futures
- Inter-worker message passing
- Alternate receive
- Multiple receive
- Conditional send
- Inter-worker failure propagation
- Named worker with on fail clause
- Synchronize message passing
- Asynchronize message passing
- Flush
- Fork
RabbitMQ service - SSL/TLS
The rabbitmq:Listener
can be configured to connect to the server via SSL/TLS by providing a certificate file. The certificate can be provided through the secureSocket
field of the connection configuration. Use this to secure the communication between the client and the server.
import ballerina/log;
import ballerinax/rabbitmq;
public type Order record {
int orderId;
string productName;
decimal price;
boolean isValid;
};
listener rabbitmq:Listener orderListener = new (rabbitmq:DEFAULT_HOST, 5671,
// To secure the client connection using TLS/SSL, the client needs to be configured with
// a certificate file of the server.
secureSocket = {
cert: "../resource/path/to/public.crt"
}
);
// The consumer service listens to the `OrderQueue` queue.
service "OrderQueue" on orderListener {
remote function onMessage(Order 'order) returns error? {
if 'order.isValid {
log:printInfo(string `Received valid order for ${'order.productName}`);
}
}
}
Prerequisites
- • Start an instance of the RabbitMQ server.
Run the service by executing the following command.
$ bal run rabbitmq_service_secure_connection.baltime = 2021-05-20T14:49:11.011+05:30 level = INFO module = "" message = "Received message: Hello from Ballerina"
Tip: You can invoke the above service via the RabbitMQ client - SSL/TLS.
Related links
PreviousConstraint validation
NextBasic authentication