use of io.vertx.amqp.AmqpClientOptions in project smallrye-reactive-messaging by smallrye.
the class ClientProducers method getNamedOptions.
// <named>
@Produces
@Identifier("my-named-options")
public AmqpClientOptions getNamedOptions() {
// You can use the produced options to configure the TLS connection
PemKeyCertOptions keycert = new PemKeyCertOptions().addCertPath("./tls/tls.crt").addKeyPath("./tls/tls.key");
PemTrustOptions trust = new PemTrustOptions().addCertPath("./tlc/ca.crt");
return new AmqpClientOptions().setSsl(true).setPemKeyCertOptions(keycert).setPemTrustOptions(trust).addEnabledSaslMechanism("EXTERNAL").setHostnameVerificationAlgorithm("").setConnectTimeout(30000).setReconnectInterval(5000).setContainerId("my-container");
}
use of io.vertx.amqp.AmqpClientOptions in project smallrye-reactive-messaging by smallrye.
the class AmqpClientHelper method createClientFromClientOptionsBean.
static AmqpClient createClientFromClientOptionsBean(Vertx vertx, Instance<AmqpClientOptions> instance, String optionsBeanName, AmqpConnectorCommonConfiguration config) {
Instance<AmqpClientOptions> options = instance.select(Identifier.Literal.of(optionsBeanName));
if (options.isUnsatisfied()) {
// this `if` block should be removed when support for the `@Named` annotation is removed
options = instance.select(NamedLiteral.of(optionsBeanName));
if (!options.isUnsatisfied()) {
ProviderLogging.log.deprecatedNamed();
}
}
if (options.isUnsatisfied()) {
throw ex.illegalStateFindingBean(AmqpClientOptions.class.getName(), optionsBeanName);
}
log.createClientFromBean(optionsBeanName);
// We must merge the channel config and the AMQP Client options.
// In case of conflict, use the channel config.
AmqpClientOptions clientOptions = getOptions(config);
AmqpClientOptions completeOptions = options.get();
mergeTo(clientOptions, completeOptions);
return AmqpClient.create(vertx, completeOptions);
}
use of io.vertx.amqp.AmqpClientOptions in project smallrye-reactive-messaging by smallrye.
the class AmqpClientHelper method getOptions.
static AmqpClientOptions getOptions(AmqpConnectorCommonConfiguration config) {
String username = config.getUsername().orElse(null);
String password = config.getPassword().orElse(null);
String host = config.getHost();
int port = config.getPort();
log.brokerConfigured(host, port, config.getChannel());
boolean useSsl = config.getUseSsl();
int reconnectAttempts = config.getReconnectAttempts();
int reconnectInterval = config.getReconnectInterval();
int connectTimeout = config.getConnectTimeout();
// We renamed containerID into container-id. So we must check both.
String containerId = config.getContainerId().orElseGet(() -> config.config.getOptionalValue("containerId", String.class).orElse(null));
AmqpClientOptions options = new AmqpClientOptions().setUsername(username).setPassword(password).setHost(host).setPort(port).setContainerId(containerId).setSsl(useSsl).setReconnectAttempts(reconnectAttempts).setReconnectInterval(reconnectInterval).setConnectTimeout(connectTimeout);
config.getSniServerName().ifPresent(options::setSniServerName);
config.getVirtualHost().ifPresent(options::setVirtualHost);
return options;
}
Aggregations