本文整理汇总了Java中com.microsoft.azure.iothub.Message.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setProperty方法的具体用法?Java Message.setProperty怎么用?Java Message.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.iothub.Message
的用法示例。
在下文中一共展示了Message.setProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMessage
import com.microsoft.azure.iothub.Message; //导入方法依赖的package包/类
/**
* Returns the Iot Hub message represented by the HTTPS message.
*
* @return the IoT Hub message represented by the HTTPS message.
*/
public Message toMessage()
{
// Codes_SRS_HTTPSSINGLEMESSAGE_11_007: [The function shall return an IoT Hub message with a copy of the message body as its body.]
Message msg = new Message(this.getBody());
// Codes_SRS_HTTPSSINGLEMESSAGE_11_008: [The function shall return an IoT Hub message with application-defined properties that have the prefix 'iothub-app' removed.]
for (MessageProperty property : this.properties)
{
String propertyName =
httpsAppPropertyToAppProperty(property.getName());
msg.setProperty(propertyName, property.getValue());
}
return msg;
}
示例2: sendEvents
import com.microsoft.azure.iothub.Message; //导入方法依赖的package包/类
@Override
public int sendEvents(int index, int numEventsToSend)
{
int eventIndex = index;
for (int i = 0; i < numEventsToSend; i++)
{
if (eventIndex == events.size())
eventIndex = 0;
String msgStr = augmentMessage(events.get(eventIndex++));
try
{
msgStr = getCurrentTime() + "," + msgStr;
byte[] bytes = msgStr.getBytes();
Message msg = new Message(bytes);
msg.setProperty("messageCount", Integer.toString(i));
clients[0].sendEventAsync(msg, callback, i);
System.out.println("S sent message - " + msgStr.trim());
if (running.get() == false)
break;
}
catch (Exception error)
{
error.printStackTrace();
}
}
return eventIndex;
}