use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.
the class TlsTest method verifiedConnectionWithCorrectServerCertificate.
@Test
void verifiedConnectionWithCorrectServerCertificate() throws Exception {
SslContext context = SslContextBuilder.forClient().trustManager(caCertificate()).build();
cf.get(new ClientParameters().sslContext(context));
}
use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.
the class TlsTest method verifiedConnectionWithCorrectClientPrivateKey.
@Test
void verifiedConnectionWithCorrectClientPrivateKey() throws Exception {
SslContext context = SslContextBuilder.forClient().trustManager(caCertificate()).keyManager(clientKey(), clientCertificate()).build();
cf.get(new ClientParameters().sslContext(context));
}
use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.
the class TlsTest method unverifiedConnectionWithSni.
@Test
void unverifiedConnectionWithSni() {
ChannelCustomizer channelCustomizer = ch -> {
SslHandler sslHandler = ch.pipeline().get(SslHandler.class);
if (sslHandler != null) {
SSLParameters sslParameters = sslHandler.engine().getSSLParameters();
sslParameters.setServerNames(Collections.singletonList(new SNIHostName("localhost")));
sslHandler.engine().setSSLParameters(sslParameters);
}
};
cf.get(new ClientParameters().sslContext(alwaysTrustSslContext()).channelCustomizer(channelCustomizer));
}
use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.
the class SubEntryBatchingTest method subEntriesCompressedWithDifferentCompressionsShouldBeReadCorrectly.
@Test
void subEntriesCompressedWithDifferentCompressionsShouldBeReadCorrectly() {
List<CompressionCodecFactory> compressionCodecFactories = compressionCodecFactories().collect(Collectors.toList());
int batchCount = compressionCodecFactories.size() * Compression.values().length;
int messagesInBatch = 30;
int messageCount = batchCount * messagesInBatch;
AtomicInteger messageIndex = new AtomicInteger(0);
CountDownLatch publishLatch = new CountDownLatch(batchCount);
Set<String> publishedBodies = ConcurrentHashMap.newKeySet(messageCount);
compressionCodecFactories.forEach(compressionCodecFactory -> {
Client publisher = cf.get(new ClientParameters().compressionCodecFactory(compressionCodecFactory).publishConfirmListener((publisherId, publishingId) -> publishLatch.countDown()));
Response response = publisher.declarePublisher(b(0), null, stream);
assertThat(response.isOk()).isTrue();
for (Compression compression : Compression.values()) {
MessageBatch messageBatch = new MessageBatch(compression);
IntStream.range(0, messagesInBatch).forEach(i -> {
String body = "compression " + compression.name() + " message " + messageIndex.getAndIncrement();
messageBatch.add(publisher.messageBuilder().addData(body.getBytes(UTF8)).build());
publishedBodies.add(body);
});
publisher.publishBatches(b(0), Collections.singletonList(messageBatch));
}
});
assertThat(latchAssert(publishLatch)).completes();
compressionCodecFactories.forEach(compressionCodecFactory -> {
CountDownLatch consumeLatch = new CountDownLatch(messageCount);
Set<String> consumedBodies = ConcurrentHashMap.newKeySet(messageCount);
Client consumer = cf.get(new ClientParameters().compressionCodecFactory(compressionCodecFactory).chunkListener((client, subscriptionId, offset, messageCount1, dataSize) -> client.credit(subscriptionId, 1)).messageListener((subscriptionId, offset, chunkTimestamp, message) -> {
consumedBodies.add(new String(message.getBodyAsBinary(), UTF8));
consumeLatch.countDown();
}));
Response response = consumer.subscribe(b(1), stream, OffsetSpecification.first(), 2);
assertThat(response.isOk()).isTrue();
assertThat(latchAssert(consumeLatch)).completes();
assertThat(consumedBodies).hasSize(messageCount).hasSameSizeAs(publishedBodies);
publishedBodies.forEach(publishBody -> assertThat(consumedBodies.contains(publishBody)).isTrue());
});
}
use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.
the class SuperStreamConsumerTest method publishToPartitions.
private static void publishToPartitions(TestUtils.ClientFactory cf, List<String> partitions, int messageCount) {
CountDownLatch publishLatch = new CountDownLatch(messageCount);
Client client = cf.get(new ClientParameters().publishConfirmListener((publisherId, publishingId) -> publishLatch.countDown()));
for (int i = 0; i < partitions.size(); i++) {
assertThat(client.declarePublisher(b(i), null, partitions.get(i)).isOk()).isTrue();
}
for (int i = 0; i < messageCount; i++) {
int partitionIndex = i % partitions.size();
String partition = partitions.get(partitionIndex);
client.publish(b(partitionIndex), Collections.singletonList(client.messageBuilder().addData(partition.getBytes(StandardCharsets.UTF_8)).build()));
}
latchAssert(publishLatch).completes();
}
Aggregations