use of io.fabric8.gateway.fabric.support.vertx.VertxService in project fabric8 by jboss-fuse.
the class FabricMQGateway method createListener.
protected GatewayServiceTreeCache createListener() {
String zkPath = getZooKeeperPath();
// TODO we should discover the broker group configuration here using the same
// mq-create / mq-client profiles so that we only listen to a subset of the available brokers here?
ServiceMap serviceMap = new ServiceMap();
VertxService vertxService = getVertxService();
Vertx vertx = vertxService.getVertx();
CuratorFramework curator = getCurator();
LoadBalancer pathLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
LoadBalancer serviceLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
LOG.info("activating MQ mapping ZooKeeper path: " + zkPath + " host: " + host + " with load balancer: " + pathLoadBalancer);
List<TcpGateway> gateways = new ArrayList<TcpGateway>();
addGateway(gateways, vertx, serviceMap, "tcp", isOpenWireEnabled(), getOpenWirePort(), pathLoadBalancer, serviceLoadBalancer);
addGateway(gateways, vertx, serviceMap, "stomp", isStompEnabled(), getStompPort(), pathLoadBalancer, serviceLoadBalancer);
addGateway(gateways, vertx, serviceMap, "amqp", isAmqpEnabled(), getAmqpPort(), pathLoadBalancer, serviceLoadBalancer);
addGateway(gateways, vertx, serviceMap, "mqtt", isMqttEnabled(), getMqttPort(), pathLoadBalancer, serviceLoadBalancer);
addGateway(gateways, vertx, serviceMap, "ws", isWebsocketEnabled(), getWebsocketPort(), pathLoadBalancer, serviceLoadBalancer);
if (gateways.isEmpty()) {
return null;
}
return new GatewayServiceTreeCache(curator, zkPath, serviceMap, gateways);
}
use of io.fabric8.gateway.fabric.support.vertx.VertxService in project fabric8 by jboss-fuse.
the class FabricDetectingGateway method createDetectingGateway.
protected DetectingGateway createDetectingGateway() {
DetectingGateway gateway = new DetectingGateway();
VertxService vertxService = getVertxService();
LoadBalancer serviceLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
gateway.setVertx(vertxService.getVertx());
gateway.setPort(port);
gateway.setServiceMap(serviceMap);
gateway.setShutdownTacker(shutdownTacker);
gateway.setServiceLoadBalancer(serviceLoadBalancer);
gateway.setDefaultVirtualHost(defaultVirtualHost);
ArrayList<Protocol> protocols = new ArrayList<Protocol>();
if (isStompEnabled()) {
protocols.add(new StompProtocol());
}
if (isMqttEnabled()) {
protocols.add(new MqttProtocol());
}
if (isAmqpEnabled()) {
protocols.add(new AmqpProtocol());
}
if (isOpenWireEnabled()) {
protocols.add(new OpenwireProtocol());
}
if (isHttpEnabled()) {
protocols.add(new HttpProtocol());
}
if (isSslEnabled()) {
SslConfig sslConfig = new SslConfig();
if (Strings.isNotBlank(sslAlgorithm)) {
sslConfig.setAlgorithm(sslAlgorithm);
}
if (Strings.isNotBlank(keyAlias)) {
sslConfig.setKeyAlias(keyAlias);
}
if (Strings.isNotBlank(keyPassword)) {
sslConfig.setKeyPassword(keyPassword);
}
if (Strings.isNotBlank(keyStorePassword)) {
sslConfig.setKeyStorePassword(keyStorePassword);
}
if (keyStoreURL != null) {
sslConfig.setKeyStoreURL(keyStoreURL);
}
if (Strings.isNotBlank(sslProtocol)) {
sslConfig.setProtocol(sslProtocol);
}
if (Strings.isNotBlank(sslStoreType)) {
sslConfig.setStoreType(sslStoreType);
}
if (Strings.isNotBlank(trustStorePassword)) {
sslConfig.setTrustStorePassword(trustStorePassword);
}
if (trustStoreURL != null) {
sslConfig.setTrustStoreURL(trustStoreURL);
}
if (Strings.isNotBlank(enabledCipherSuites)) {
sslConfig.setEnabledCipherSuites(enabledCipherSuites);
}
if (Strings.isNotBlank(disabledCypherSuites)) {
sslConfig.setDisabledCypherSuites(disabledCypherSuites);
}
gateway.setSslConfig(sslConfig);
// validating configuration
try {
SSLContext sslContext = SSLContext.getInstance(sslConfig.getProtocol());
sslContext.init(sslConfig.getKeyManagers(), sslConfig.getTrustManagers(), null);
} catch (Exception e) {
throw new ComponentException(e);
}
protocols.add(new SslProtocol());
}
if (protocols.isEmpty()) {
return null;
}
gateway.setProtocols(protocols);
return gateway;
}
Aggregations