/** * Returns whether the invocation of the management operation on the server resource succeeded. */ public static boolean hasOperationSucceeded(final Message message) { if (!ManagementHelper.isOperationResult(message)) { return false; } if (message.containsProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED)) { return message.getBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED); } return false; }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(msg.isLargeMessage() ? "LargeMessage(" : "Message("); buffer.append("messageID=" + msg.getMessageID()); buffer.append(";properties=["); Set<SimpleString> properties = msg.getPropertyNames(); for (SimpleString prop : properties) { Object value = msg.getObjectProperty(prop); if (value instanceof byte[]) { buffer.append(prop + "=" + Arrays.toString((byte[])value) + ","); } else { buffer.append(prop + "=" + value + ","); } } buffer.append("#properties = " + properties.size()); buffer.append("]"); buffer.append(" - " + msg.toString()); return buffer.toString(); }
/** * Stores a resource attribute in a message to retrieve the value from the server resource. * * @param message message * @param resourceName the name of the resource * @param attribute the name of the attribute * @see ResourceNames */ public static void putAttribute(final Message message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(msg.isLargeMessage() ? "LargeMessage(" : "Message("); buffer.append("messageID=" + msg.getMessageID()); if (msg.getUserID() != null) { buffer.append(";userMessageID=" + msg.getUserID().toString()); } buffer.append(";msg=" + msg.toString()); return buffer.toString(); }
message.putShortProperty(key, Short.parseShort(value)); message.putBooleanProperty(key, Boolean.parseBoolean(value)); message.putByteProperty(key, Byte.parseByte(value)); message.putBytesProperty(key, decode(value)); message.putDoubleProperty(key, Double.parseDouble(value)); message.putFloatProperty(key, Float.parseFloat(value)); message.putIntProperty(key, Integer.parseInt(value)); message.putLongProperty(key, Long.parseLong(value)); message.putStringProperty(new SimpleString(key), new SimpleString(value)); message.putStringProperty(key, value);
/** * Stores a operation invocation in a message to invoke the corresponding operation the value from the server resource. * * @param message message * @param resourceName the name of the server resource * @param operationName the name of the operation to invoke on the server resource * @param parameters the parameters to use to invoke the server resource * @see ResourceNames */ public static void putOperationInvocation(final Message message, final String resourceName, final String operationName, final Object... parameters) throws Exception { // store the name of the operation in the headers message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_OPERATION_NAME, new SimpleString(operationName)); // and the params go in the body, since might be too large for header String paramString; if (parameters != null) { JSONArray jsonArray = ManagementHelper.toJSONArray(parameters); paramString = jsonArray.toString(); } else { paramString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString)); }
message.getBodyBuffer().writeBytes(decode(characters.trim()));
/** * @param refs * @return */ private Map<String, Object>[] convertMessagesToMaps(List<MessageReference> refs) { Map<String, Object>[] messages = new Map[refs.size()]; int i = 0; for (MessageReference ref : refs) { Message message = ref.getMessage(); messages[i++] = message.toMap(); } return messages; }
public void setAddress(final Message message, final SimpleString address) { if (defaultAddress == null) { defaultAddress = address; message.setAddress(address); } else { if (!address.equals(defaultAddress)) { message.setAddress(address); } else { message.setAddress(null); } } }
/** * Returns whether the JMS message corresponds to the result of a management operation invocation. */ public static boolean isOperationResult(final Message message) { return message.containsProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED); }
public synchronized void handleMessage(final SessionReceiveMessage message) throws Exception { if (closing) { // This is ok - we just ignore the message return; } if (message.getMessage().getBooleanProperty(Message.HDR_LARGE_COMPRESSED)) { handleCompressedMessage(message); } else { handleRegularMessage((ClientMessageInternal)message.getMessage(), message); } }
message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_OPERATION_NAME, new SimpleString(operationName)); message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString));
/** * Used by HornetQ management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); return ManagementHelper.fromJSONArray(jsonArray); } else { return null; } }
public Map<String, Object>[] listScheduledMessages() throws Exception { checkStarted(); clearIO(); try { List<MessageReference> refs = queue.getScheduledMessages(); Map<String, Object>[] messages = new Map[refs.size()]; int i = 0; for (MessageReference ref : refs) { Message message = ref.getMessage(); messages[i++] = message.toMap(); } return messages; } finally { blockOnIO(); } }
public void setAddress(final Message message, final SimpleString address) { if (defaultAddress == null) { defaultAddress = address; message.setAddress(address); } else { if (!address.equals(defaultAddress)) { message.setAddress(address); } else { message.setAddress(null); } } }
/** * Returns whether the JMS message corresponds to the result of a management operation invocation. */ public static boolean isOperationResult(final Message message) { return message.containsProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED); }
/** * Returns whether the invocation of the management operation on the server resource succeeded. */ public static boolean hasOperationSucceeded(final Message message) { if (!ManagementHelper.isOperationResult(message)) { return false; } if (message.containsProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED)) { return message.getBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED); } return false; }
/** * Used by HornetQ management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); return ManagementHelper.fromJSONArray(jsonArray); } else { return null; } }
public String getFirstMessageAsJSON() throws Exception { checkStarted(); clearIO(); try { List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>(); queue.flushExecutor(); LinkedListIterator<MessageReference> iterator = queue.totalIterator(); try { // returns just the first, as it's the first only if (iterator.hasNext()) { MessageReference ref = iterator.next(); Message message = ref.getMessage(); messages.add(message.toMap()); } return toJSON(messages.toArray(new Map[1])).toString(); } finally { iterator.close(); } } finally { blockOnIO(); } }
msg.setAddress(address1); msg.setAddress(this.address);