/** * Create a module client instance from your environment variables * @return the created module client instance * @throws ModuleClientException if the module client cannot be created */ public static ModuleClient createFromEnvironment() throws ModuleClientException { return createFromEnvironment(IotHubClientProtocol.AMQPS); }
public void connectFromEnvironment(String transportType, Handler<AsyncResult<ConnectResponse>> handler) { System.out.printf("ConnectFromEnvironment called with transport %s%n", transportType); IotHubClientProtocol protocol = this.transportFromString(transportType); if (protocol == null) { handler.handle(Future.failedFuture(new MainApiException(500, "invalid transport"))); return; } try { ModuleClient client = ModuleClient.createFromEnvironment(protocol); openClientWithRetry(client); this._clientCount++; String connectionId = "moduleClient_" + this._clientCount; this._map.put(connectionId, client); ConnectResponse cr = new ConnectResponse(); cr.setConnectionId(connectionId); handler.handle(Future.succeededFuture(cr)); } catch (ModuleClientException | InterruptedException e) { handler.handle(Future.failedFuture(e)); } }
String moduleIdToInvokeOn = args.length > 4 ? args[4] : null; ModuleClient client = ModuleClient.createFromEnvironment(protocol); client.open();