@Override public final Object getObjectProperty(String name) throws JMSException { Object val = message.getObjectProperty(name); if (val instanceof SimpleString) { val = ((SimpleString) val).toString(); } return val; }
private static void setAMQMsgObjectProperties(final ActiveMQMessage amqMsg, final ICoreMessage coreMessage, final Set<SimpleString> props, final AMQConsumer consumer) throws IOException { for (SimpleString s : props) { final String keyStr = s.toString(); if (!consumer.hasNotificationDestination() && (keyStr.startsWith("_AMQ") || keyStr.startsWith("__HDR_"))) { continue; } final Object prop = coreMessage.getObjectProperty(s); try { if (prop instanceof SimpleString) { amqMsg.setObjectProperty(keyStr, prop.toString()); } else { if (keyStr.equals(MessageUtil.JMSXDELIVERYCOUNT) && prop instanceof Long) { Long l = (Long) prop; amqMsg.setObjectProperty(keyStr, l.intValue()); } else { amqMsg.setObjectProperty(keyStr, prop); } } } catch (JMSException e) { throw new IOException("exception setting property " + s + " : " + prop, e); } } } }
final ActiveMQMessage amqMsg; final byte coreType = coreMessage.getType(); final Boolean compressProp = (Boolean) coreMessage.getObjectProperty(AMQ_MSG_COMPRESSED); final boolean isCompressed = compressProp == null ? false : compressProp.booleanValue(); final byte[] bytes; Long brokerInTime = (Long) coreMessage.getObjectProperty(AMQ_MSG_BROKER_IN_TIME); if (brokerInTime == null) { brokerInTime = 0L; Long arrival = (Long) coreMessage.getObjectProperty(AMQ_MSG_ARRIVAL); if (arrival == null) { final String brokerPath = (String) coreMessage.getObjectProperty(AMQ_MSG_BROKER_PATH); if (brokerPath != null && !brokerPath.isEmpty()) { setAMQMsgBrokerPath(amqMsg, brokerPath); final String clusterPath = (String) coreMessage.getObjectProperty(AMQ_MSG_CLUSTER); if (clusterPath != null && !clusterPath.isEmpty()) { setAMQMsgClusterPath(amqMsg, clusterPath); Integer commandId = (Integer) coreMessage.getObjectProperty(AMQ_MSG_COMMAND_ID); if (commandId == null) { commandId = -1; final SimpleString corrId = (SimpleString) coreMessage.getObjectProperty(JMS_CORRELATION_ID_PROPERTY); if (corrId != null) { amqMsg.setCorrelationId(corrId.toString());
@Override public Message transform(final Message messageParameter) { ICoreMessage message = messageParameter.toCore(); SimpleString oldProp = (SimpleString) message.getObjectProperty(new SimpleString("wibble")); if (!oldProp.equals(new SimpleString("bing"))) { throw new IllegalStateException("Wrong property value!!"); } // Change a property message.putStringProperty(new SimpleString("wibble"), new SimpleString("bong")); // Change the body ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.readerIndex(0); String str = buffer.readString(); if (!str.equals("doo be doo be doo be doo")) { throw new IllegalStateException("Wrong body!!"); } buffer.clear(); buffer.writeString("dee be dee be dee be dee"); return message; }