/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * Stores an 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 ICoreMessage 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 = JsonUtil.toJSONArray(parameters); paramString = jsonArray.toString(); } else { paramString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString)); }
msg.putStringProperty(Message.HDR_GROUP_ID, groupID);
@Override public final void setJMSMessageID(String id) throws JMSException { if (id != null) { message.putStringProperty(NATIVE_MESSAGE_ID, id); } }
@Override public final void setJMSMessageID(String id) throws JMSException { if (id != null) { message.putStringProperty(NATIVE_MESSAGE_ID, id); } }
@Override public final void setStringProperty(String name, String value) throws JMSException { message.putStringProperty(name, value); }
/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * 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 ICoreMessage message, final String resourceName, final String attribute) { message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_ATTRIBUTE, new SimpleString(attribute)); }
/** * 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 ICoreMessage 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 boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException { System.out.println("Outgoin:Packet : " + packet); if (packet.getType() == PacketImpl.SESS_SEND) { SessionSendMessage p = (SessionSendMessage) packet; p.getMessage().putStringProperty("Outgoing", "sending"); } return true; }
@Override public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException { System.out.println("Incoming:Packet : " + packet); if (packet.getType() == PacketImpl.SESS_RECEIVE_MSG) { SessionReceiveMessage p = (SessionReceiveMessage) packet; p.getMessage().putStringProperty("Incoming", "was here"); } return true; }
protected void sendServerMessage(ICoreMessage message, String txID) throws ActiveMQStompException { try { StompSession stompSession = getSession(txID); if (stompSession.isNoLocal()) { message.putStringProperty(CONNECTION_ID_PROP, getID().toString()); } if (isEnableMessageID()) { message.putStringProperty("amqMessageId", "STOMP" + message.getMessageID()); } if (minLargeMessageSize == -1 || (message.getBodyBuffer().writerIndex() < minLargeMessageSize)) { stompSession.sendInternal(message, false); } else { stompSession.sendInternalLarge((CoreMessage)message, false); } } catch (Exception e) { throw BUNDLE.errorSendMessage(message, e).setHandler(frameHandler); } }
protected void sendServerMessage(ICoreMessage message, String txID) throws ActiveMQStompException { StompSession stompSession = getSession(txID); if (stompSession.isNoLocal()) { message.putStringProperty(CONNECTION_ID_PROP, getID().toString()); } if (isEnableMessageID()) { message.putStringProperty("amqMessageId", "STOMP" + message.getMessageID()); } try { if (minLargeMessageSize == -1 || (message.getBodyBuffer().writerIndex() < minLargeMessageSize)) { stompSession.sendInternal(message, false); } else { stompSession.sendInternalLarge((CoreMessage)message, false); } } catch (Exception e) { throw BUNDLE.errorSendMessage(message, e).setHandler(frameHandler); } }
@Override public boolean intercept(final Packet packet, final RemotingConnection conn) throws ActiveMQException { log.debug("DummyFilter packet = " + packet.getClass().getName()); syncCounter.addAndGet(1); if (sendException) { throw new ActiveMQInternalErrorException(); } if (changeMessage) { if (packet instanceof SessionReceiveMessage) { SessionReceiveMessage deliver = (SessionReceiveMessage) packet; log.debug("msg = " + deliver.getMessage().getClass().getName()); deliver.getMessage().putStringProperty(new SimpleString("DummyInterceptor"), new SimpleString("was here")); } } return true; }
@Override public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException { if (packet.getType() == PacketImpl.SESS_CREATECONSUMER) { String userName = getUsername(packet, connection); SessionCreateConsumerMessage createQueue = (SessionCreateConsumerMessage) packet; createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); System.out.println("userName = " + userName); } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); System.out.println("userName on send = " + userName); } return true; }
@Override public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException { if (packet.getType() == PacketImpl.CREATE_QUEUE || packet.getType() == PacketImpl.CREATE_QUEUE_V2) { String userName = getUsername(packet, connection); CreateQueueMessage createQueue = (CreateQueueMessage) packet; createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); System.out.println("userName on createQueue = " + userName); } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); System.out.println("userName on send = " + userName); } return true; }
@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; }