use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class StreamEnvironmentTest method locatorShouldReconnectIfConnectionIsLost.
@Test
@TestUtils.DisabledIfRabbitMqCtlNotSet
void locatorShouldReconnectIfConnectionIsLost(TestInfo info) throws Exception {
try (Environment environment = environmentBuilder.recoveryBackOffDelayPolicy(BackOffDelayPolicy.fixed(Duration.ofSeconds(1))).build()) {
String s = streamName(info);
environment.streamCreator().stream(s).create();
environment.deleteStream(s);
Host.killConnection("rabbitmq-stream-locator-0");
environment.streamCreator().stream(s).create();
try {
Producer producer = environment.producerBuilder().stream(s).build();
Consumer consumer = environment.consumerBuilder().stream(s).build();
producer.close();
consumer.close();
} finally {
environment.deleteStream(s);
}
}
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class StreamEnvironmentTest method createDelete.
@Test
void createDelete(TestInfo info) {
try (Environment environment = environmentBuilder.build();
Client client = new Client()) {
String s = streamName(info);
environment.streamCreator().stream(s).create();
Client.StreamMetadata metadata = client.metadata(s).get(s);
assertThat(metadata.isResponseOk()).isTrue();
environment.deleteStream(s);
metadata = client.metadata(s).get(s);
assertThat(metadata.isResponseOk()).isFalse();
assertThat(metadata.getResponseCode()).isEqualTo(Constants.RESPONSE_CODE_STREAM_DOES_NOT_EXIST);
}
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class EnvironmentUsage method environmentCreation.
void environmentCreation() throws Exception {
// tag::environment-creation[]
// <1>
Environment environment = Environment.builder().build();
// ...
// <2>
environment.close();
// end::environment-creation[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class EnvironmentUsage method createStreamWithTimeBasedRetention.
void createStreamWithTimeBasedRetention() {
Environment environment = Environment.builder().build();
// tag::stream-creation-time-based-retention[]
environment.streamCreator().stream("my-stream").maxAge(// <1>
Duration.ofHours(6)).maxSegmentSizeBytes(// <2>
ByteCapacity.MB(500)).create();
// end::stream-creation-time-based-retention[]
}
use of com.rabbitmq.stream.Environment in project rabbitmq-stream-java-client by rabbitmq.
the class EnvironmentUsage method createStream.
void createStream() {
Environment environment = Environment.builder().build();
// tag::stream-creation[]
// <1>
environment.streamCreator().stream("my-stream").create();
// end::stream-creation[]
}
Aggregations