public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); counter.increment(); return IotHubMessageResult.COMPLETE; } }
public synchronized IotHubMessageResult execute(Message msg, Object context) { System.out.println("MessageCallback called"); this._client.setMessageCallback(this._inputName, null, null); String result = new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET); System.out.printf("result = %s%n", result); try { if (this._handler != null) { this._handler.handle(Future.succeededFuture(result)); } } catch (Exception e) { System.out.printf("Ignoring exception %s%n", e.toString()); } return IotHubMessageResult.COMPLETE; } }
public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties()) { System.out.println(messageProperty.getName() + " : " + messageProperty.getValue()); } counter.increment(); return IotHubMessageResult.COMPLETE; } }
public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties()) { System.out.println(messageProperty.getName() + " : " + messageProperty.getValue()); } counter.increment(); return IotHubMessageResult.COMPLETE; } }
public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties()) { System.out.println(messageProperty.getName() + " : " + messageProperty.getValue()); } counter.increment(); return IotHubMessageResult.COMPLETE; } }
public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); int switchVal = counter.get() % 3; IotHubMessageResult res; switch (switchVal) { case 0: res = IotHubMessageResult.COMPLETE; break; case 1: res = IotHubMessageResult.ABANDON; break; case 2: res = IotHubMessageResult.REJECT; break; default: // should never happen. throw new IllegalStateException("Invalid message result specified."); } System.out.println("Responding to message " + counter.toString() + " with " + res.name()); counter.increment(); return res; } }
private void addBlobInformation(Message responseMessage) throws IllegalArgumentException, URISyntaxException, UnsupportedEncodingException { /* Codes_SRS_FILEUPLOADTASK_21_015: [If the iothub accepts the request, it shall provide a `responseMessage` with the blob information with a correlationId.] */ /* Codes_SRS_FILEUPLOADTASK_21_016: [If the `responseMessage` is null, empty, do not contains a valid json, or if the information in json is not correct, the run shall call the `userCallback` reporting the error, and abort the upload.] */ String json = new String(responseMessage.getBytes(), DEFAULT_IOTHUB_MESSAGE_CHARSET); FileUploadResponseParser fileUploadResponseParser = new FileUploadResponseParser(json); /* Codes_SRS_FILEUPLOADTASK_21_017: [The run shall parse and store the blobName and correlationId in the response, by use the FileUploadResponseParser.] */ this.correlationId = fileUploadResponseParser.getCorrelationId(); this.blobName = fileUploadResponseParser.getBlobName(); String hostName = fileUploadResponseParser.getHostName(); String containerName = fileUploadResponseParser.getContainerName(); String sasToken = fileUploadResponseParser.getSasToken(); /* Codes_SRS_FILEUPLOADTASK_21_018: [The run shall create a blob URI `blobUri` with the format `https://[hostName]/[containerName]/[blobName,UTF-8][sasToken]`.] */ /* Codes_SRS_FILEUPLOADTASK_21_032: [If create the blob URI failed, the run shall call the `userCallback` reporting the error, and abort the upload.] */ String putString = HTTPS_URL_STRING + hostName + PATH_SEPARATOR_STRING + containerName + PATH_SEPARATOR_STRING + URLEncoder.encode(blobName, UTF_8_STRING) + // Pass URL encoded blob name to support special characters sasToken; this.blobURI = new URI(putString); }
public IotHubMessageResult execute(Message msg, Object context) { Counter counter = (Counter) context; System.out.println( "Device Client " + msg.getIotHubConnectionString().getDeviceId() + " received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties()) { System.out.println(messageProperty.getName() + " : " + messageProperty.getValue()); } IotHubMessageResult res = IotHubMessageResult.COMPLETE; System.out.println( "Responding to message " + counter.toString() + " with " + res.name()); counter.increment(); return res; } }
System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties())
System.out.println( "Received message " + counter.toString() + " with content: " + new String(msg.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)); for (MessageProperty messageProperty : msg.getProperties())
byte[] msgBody = message.getBytes(); httpsMsg.body = Arrays.copyOf(msgBody, msgBody.length);
if (message == null || message.getBytes() == null)
Binary binary = new Binary(message.getBytes()); Section section = new Data(binary); outgoingMessage.setBody(section);
transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); transportMessage.setIotHubConnectionString(message.getIotHubConnectionString());
transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); transportMessage.setMessageCallback(this.config.getDeviceTelemetryMessageCallback(message.getInputName())); transportMessage.setMessageCallbackContext(this.config.getDeviceTelemetryMessageContext(message.getInputName()));
IotHubTransportMessage transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); if (status == IotHubStatusCode.OK || status == IotHubStatusCode.OK_EMPTY)