use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class ProducerUsage method producerSubEntryBatchingCompression.
void producerSubEntryBatchingCompression() {
Environment environment = Environment.builder().build();
// tag::producer-sub-entry-batching-and-compression[]
Producer producer = environment.producerBuilder().stream("my-stream").batchSize(// <1>
100).subEntrySize(// <2>
10).compression(// <3>
Compression.ZSTD).build();
// end::producer-sub-entry-batching-and-compression[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class ProducerUsage method producerSubEntryBatching.
void producerSubEntryBatching() {
Environment environment = Environment.builder().build();
// tag::producer-sub-entry-batching[]
Producer producer = environment.producerBuilder().stream("my-stream").batchSize(// <1>
100).subEntrySize(// <2>
10).build();
// end::producer-sub-entry-batching[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class ProducerUsage method producerPublish.
void producerPublish() {
Environment environment = Environment.builder().build();
Producer producer = environment.producerBuilder().stream("my-stream").build();
// tag::producer-publish[]
// <1>
byte[] messagePayload = "hello".getBytes(StandardCharsets.UTF_8);
producer.send(// <2>
producer.messageBuilder().addData(messagePayload).build(), confirmationStatus -> {
// <3>
if (confirmationStatus.isConfirmed()) {
// the message made it to the broker
} else {
// the message did not make it to the broker
}
});
// end::producer-publish[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class SuperStreamUsage method producerSimple.
void producerSimple() {
Environment environment = Environment.builder().build();
// tag::producer-simple[]
Producer producer = environment.producerBuilder().stream(// <1>
"invoices").routing(// <2>
message -> message.getProperties().getMessageIdAsString()).producerBuilder().build();
// ...
// <4>
producer.close();
// end::producer-simple[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class SuperStreamUsage method producerKeyRoutingStrategy.
void producerKeyRoutingStrategy() {
Environment environment = Environment.builder().build();
// tag::producer-key-routing-strategy[]
Producer producer = environment.producerBuilder().stream("invoices").routing(// <1>
msg -> msg.getApplicationProperties().get("region").toString()).key().producerBuilder().build();
// end::producer-key-routing-strategy[]
}
Aggregations