(This project is deprecated and not maintained.)
Java client library for publishing/consuming messages to/from Cherami.
The cherami-client-java library supports publishing/consuming from Cherami in synchronous and asynchronous modes. The usage below uses the synchronous blocking API.
// Create the client object with the server ip and port
CheramiClient client = new CheramiClient.Builder(serverIP, serverPort).build();
// Create a destination for publishing messages to
CreateDestinationRequest dstRequest = new CreateDestinationRequest();
dstRequest.setPath(destinationPath);
client.createDestination(dstRequest);
// Create a consumer group for consuming messages from the destination
CreateConsumerGroupRequest cgRequest = new CreateConsumerGroupRequest();
cgRequest.setDestinationPath(destinationPath);
cgRequest.setConsumerGroupName(consumerGroupName);
client.createConsumerGroup(cgRequest);
// Publish a message
CreatePublisherRequest pRequest = new CreatePublisherRequest.Builder(destinationPath).build()
CheramiPublisher publisher = client.createPublisher(pRequest);
publisher.open();
publisher.write(new PublisherMessage("hello".getBytes("UTF8")));
publisher.close();
// Consume a message
CreateConsumerRequest cRequest = new CreateConsumerRequest.Builder(destinationPath, consumerGroupName).build()
CheramiConsumer consumer = client.createConsumer(cRequest);
consumer.open();
CheramiDelivery delivery = consumer.read();
System.out.println(new String(delivery.getMessage().getPayload().getData(), "UTF8"));
consumer.close();
client.close();
For details on how to use the library in an application, see the examples directory.
Build with mvn clean package
If you are interested in contributing to cherami the best place to start would be this blog post eng.uber.com/cherami
Note: All contributors also need to fill out the Uber Contributor License Agreement before we can merge in any of your changes.
MIT License, please see LICENSE for details.