@Override public void connectToExternal() throws ComponentException { try { opcuaClient = createClient(componentConfig.getExternalConnectionString()); //opcuaClient.connect().whenComplete((c, ex) -> this.isConnectedToExternal() = true).get(); opcuaClient.connect().get(); } catch (Exception e) { throw new ComponentException(e); } }
@Override public void connectToExternal() throws ComponentException { String patternString = "(?<protocol>wss?):\\/\\/(?<host>.*):(?<port>\\d*)"; Pattern pattern = Pattern.compile(patternString); Matcher matcher = pattern.matcher(componentConfig.getExternalConnectionString()); boolean matches = matcher.matches(); if (!matches) { throw new ComponentException("Invalid external connection string! " + componentConfig.getExternalConnectionString() + " does not match the expected pattern " + patternString); } protocol = matcher.group("protocol"); host = matcher.group("host"); port = Integer.parseInt(matcher.group("port")); //TODO: support also wss ros = new Ros(host, port, WebSocketType.valueOf(protocol)); if (!ros.connect()) { throw new ComponentException( getName() + " cannot connect to \"" + componentConfig.getExternalConnectionString() + "\""); } }
@Override public void connectToExternal() throws ComponentException { super.connectToExternal(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getConfig().getExternalConnectionString()); try { connection = connectionFactory.createConnection(); connection.setClientID(getId()); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { throw new ComponentException(e); } for (Property p : getConfig().getProperties()) { if (p.getKey().equals("incoming")) { String[] parts = p.getValue().split(" "); installOutgoingChannel(parts[0], parts[1]); } if (p.getKey().equals("outgoing")) { String[] parts = p.getValue().split(" "); installIncomingChannel(parts[0], parts[1]); } } }
throw new ComponentException("MqttGatewayComponent \"" + getId() + "\" cannot connect to \"" + componentConfig.getExternalConnectionString() + "\"", e);
@Override public void connectToExternal() throws ComponentException { MemoryPersistence persistence = new MemoryPersistence(); final MqttConnectOptions options = new MqttConnectOptions(); options.setCleanSession(true); try { mqttClient = new MqttAsyncClient(componentConfig.getExternalConnectionString(), getId(), persistence); mqttClient.connect(options, new IMqttActionListener() { @Override public void onSuccess(IMqttToken asyncActionToken) { LOGGER.info( getName() + " connected to " + componentConfig.getExternalConnectionString()); } @Override public void onFailure(IMqttToken asyncActionToken, Throwable exception) { LOGGER.info( getName() + " could not establish connection to " + componentConfig.getExternalConnectionString()); } }).waitForCompletion(); } catch (MqttException e) { throw new ComponentException( getName() + " cannot connect to \"" + componentConfig.getExternalConnectionString() + "\"", e); } }