CodexBloom - Programming Q&A Platform

OCI Streaming: how to to Consume Messages with Java SDK Version 2.15.0 in a High-Throughput Scenario

👀 Views: 80 💬 Answers: 1 📅 Created: 2025-06-11
oci streaming java sdk performance Java

I'm trying to configure I'm working with an scenario while trying to consume messages from an OCI Stream using the Java SDK version 2.15.0... My application is supposed to handle a high throughput of messages (around 10,000 messages per second), but I've noticed important message loss and delays in processing. I've implemented a simple consumer as follows: ```java import com.oracle.bmc.streaming.StreamClient; import com.oracle.bmc.streaming.model.Message; import java.util.List; public class StreamConsumer { public static void main(String[] args) { StreamClient client = StreamClient.builder().build(); String streamId = "<your_stream_id>"; while (true) { List<Message> messages = client.getMessages(streamId, 100); for (Message message : messages) { processMessage(message); client.acknowledge(message.getMessageId()); } } } private static void processMessage(Message message) { // Simulate processing System.out.println(new String(message.getValue())); } } ``` I’ve tuned the parameters for the `getMessages` method to fetch up to 100 messages at a time, but there are times when it seems to miss messages completely. Additionally, I see log entries indicating a `RateLimitExceeded` behavior intermittently, which I suspect could be related to the high throughput. To diagnose the scenario, I've added logging to track how many messages are being processed against how many are retrieved. I’m also using a dedicated consumer group to ensure that messages are not duplicated. As a workaround, I tried increasing the acknowledgement timeout, but it didn’t seem to help. I also enabled detailed logging for the SDK, which shows that many messages are being processed, but I need to pinpoint where the loss occurs. Is there a best practice for consuming messages efficiently at high throughput in OCI Streaming? Are there any known issues with the Java SDK at this version that could cause this behavior? Any insights or code improvements would be greatly appreciated. Has anyone else encountered this? For reference, this is a production microservice. I'd be grateful for any help.