private static boolean isErrorInjectionMessage(MessageAndResult messageAndResult) { MessageProperty[] properties = messageAndResult.message.getProperties(); for (int i = 0; i < properties.length; i++) { if (properties[i].getValue().equals(ErrorInjectionHelper.FaultCloseReason_Boom.toString()) || properties[i].getValue().equals(ErrorInjectionHelper.FaultCloseReason_Bye.toString())) { return true; } } return false; }
/** * Gets the values of user-defined properties of this Message. * @param name Name of the user-defined property to search for. * @return The value of the property if it is set, or null otherwise. */ public String getProperty(String name) { MessageProperty messageProperty = null; for (MessageProperty currentMessageProperty: this.properties) { if (currentMessageProperty.hasSameName(name)) { messageProperty = currentMessageProperty; break; } } // Codes_SRS_MESSAGE_11_034: [If no value associated with the property name is found, the function shall return null.] if (messageProperty == null) { return null; } // Codes_SRS_MESSAGE_11_032: [The function shall return the value associated with the message property name, where the name can be either the HTTPS or AMQPS property name.] return messageProperty.getValue(); }
for (MessageProperty p : properties) allProperties.put(p.getName(), p.getValue());
/** * Returns a copy of the message properties. * * @return a copy of the message properties. */ public MessageProperty[] getProperties() { // Codes_SRS_HTTPSSINGLEMESSAGE_11_013: [The function shall return a copy of the message properties.] int propertiesSize = this.properties.length; MessageProperty[] propertiesCopy = new MessageProperty[propertiesSize]; for (int i = 0; i < propertiesSize; ++i) { MessageProperty property = this.properties[i]; MessageProperty propertyCopy = new MessageProperty(property.getName(), property.getValue()); propertiesCopy[i] = propertyCopy; } return propertiesCopy; }
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; } }
String propertyValue = property.getValue(); msg.setProperty(propertyName, propertyValue);
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; } }
public IotHubTransportMessage(byte[] data, MessageType messageType, String messageId, String correlationId, MessageProperty[] messageProperties) { //Codes_SRS_IOTHUBTRANSPORTMESSAGE_34_017: [This constructor shall return an instance of IotHubTransportMessage with provided bytes, messagetype, correlationid, messageid, and application properties.] super(data); super.setMessageType(messageType); this.setMessageId(messageId); this.setCorrelationId(correlationId); for (MessageProperty messageProperty : messageProperties) { this.setProperty(messageProperty.getName(), messageProperty.getValue()); } }
for (MessageProperty messageProperty : msg.getProperties()) System.out.println(messageProperty.getName() + " : " + messageProperty.getValue());
for (MessageProperty messageProperty : msg.getProperties()) System.out.println(messageProperty.getName() + " : " + messageProperty.getValue());
property.getValue());
separatorNeeded = appendPropertyIfPresent(stringBuilder, separatorNeeded, property.getName(), property.getValue());
request.setHeaderField(property.getName(), property.getValue());
userProperties.put(messageProperty.getName(), messageProperty.getValue());
property.getValue());