use of io.nats.client.ConnectionFactory in project camel by apache.
the class NatsProducer method getConnection.
private Connection getConnection() throws TimeoutException, IOException, GeneralSecurityException {
Properties prop = getEndpoint().getNatsConfiguration().createProperties();
ConnectionFactory factory = new ConnectionFactory(prop);
if (getEndpoint().getNatsConfiguration().getSslContextParameters() != null && getEndpoint().getNatsConfiguration().isSecure()) {
SSLContext sslCtx = getEndpoint().getNatsConfiguration().getSslContextParameters().createSSLContext(getEndpoint().getCamelContext());
factory.setSSLContext(sslCtx);
if (getEndpoint().getNatsConfiguration().isTlsDebug()) {
factory.setTlsDebug(getEndpoint().getNatsConfiguration().isTlsDebug());
}
}
connection = factory.createConnection();
return connection;
}
use of io.nats.client.ConnectionFactory in project camel by apache.
the class NatsConsumerLoadTest method testLoadConsumer.
@Test
public void testLoadConsumer() throws InterruptedException, IOException, TimeoutException {
mockResultEndpoint.setExpectedMessageCount(10000);
ConnectionFactory cf = new ConnectionFactory("nats://localhost:4222");
Connection connection = cf.createConnection();
for (int i = 0; i < 10000; i++) {
connection.publish("test", ("test" + i).getBytes());
}
mockResultEndpoint.assertIsSatisfied();
}
use of io.nats.client.ConnectionFactory in project camel by apache.
the class NatsConsumer method getConnection.
private Connection getConnection() throws IOException, InterruptedException, TimeoutException, GeneralSecurityException {
Properties prop = getEndpoint().getNatsConfiguration().createProperties();
ConnectionFactory factory = new ConnectionFactory(prop);
if (getEndpoint().getNatsConfiguration().getSslContextParameters() != null && getEndpoint().getNatsConfiguration().isSecure()) {
SSLContext sslCtx = getEndpoint().getNatsConfiguration().getSslContextParameters().createSSLContext(getEndpoint().getCamelContext());
factory.setSSLContext(sslCtx);
if (getEndpoint().getNatsConfiguration().isTlsDebug()) {
factory.setTlsDebug(getEndpoint().getNatsConfiguration().isTlsDebug());
}
}
connection = factory.createConnection();
return connection;
}
Aggregations