public void setJMSType(final String type) throws JMSException { if (type != null) { message.putStringProperty(HornetQMessage.TYPE_HEADER_NAME, new SimpleString(type)); jmsType = type; } }
public static void setHttpHeader(ClientMessage message, String name, String value) { message.putStringProperty(HttpHeaderProperty.toPropertyName(name), value); }
public void setStringProperty(final String name, final String value) throws JMSException { checkProperty(name, value); if (HornetQMessage.JMSXGROUPID.equals(name)) { message.putStringProperty(org.hornetq.api.core.Message.HDR_GROUP_ID, SimpleString.toSimpleString(value)); } else { message.putStringProperty(new SimpleString(name), SimpleString.toSimpleString(value)); } }
@Override public void sendMessage(String txt) throws Exception { System.out.println("-----> Attempting to send message"); ClientProducer producer = session.createProducer(QUEUE_EXAMPLE_QUEUE); ClientMessage message = session.createMessage(false); message.putStringProperty(BODY, "'" + txt + "' sent at " + new Date()); System.out.println("-----> Sending message"); producer.send(message); }
public void setJMSCorrelationID(final String correlationID) throws JMSException { if (correlationID == null) { message.removeProperty(HornetQMessage.CORRELATIONID_HEADER_NAME); jmsCorrelationID = null; } else { message.putStringProperty(HornetQMessage.CORRELATIONID_HEADER_NAME, new SimpleString(correlationID)); jmsCorrelationID = correlationID; } }
/** * Sends a message to the request address and wait for the given timeout for a reply. * The temporary queue is used for the REPLYTO_HEADER_NAME, and only one reply per request is expected * * @param request the message to send * @param timeout the timeout to wait for a reply (in milliseconds) * @return the reply message or <code>null</code> if no message is replied before the timeout elapses * @throws Exception */ public ClientMessage request(final ClientMessage request, final long timeout) throws Exception { request.putStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME, replyQueue); requestProducer.send(request); return replyConsumer.receive(timeout); }
/** * Sends a message to the request address and wait for the given timeout for a reply. * The temporary queue is used for the REPLYTO_HEADER_NAME, and only one reply per request is expected * * @param request the message to send * @param timeout the timeout to wait for a reply (in milliseconds) * @return the reply message or {@code null} if no message is replied before the timeout elapses * @throws Exception */ public ClientMessage request(final ClientMessage request, final long timeout) throws Exception { request.putStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME, replyQueue); requestProducer.send(request); return replyConsumer.receive(timeout); }
/** * Sets a message property to be the Content-Type passed in. Sets the message body to a serialized * byte array of the object. * * @param message * @param object * @param contentType HTTP Content-Type header */ public static void setEntity(ClientMessage message, Serializable object, String contentType) { if (contentType != null) message.putStringProperty(HttpHeaderProperty.CONTENT_TYPE, contentType); byte[] data; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); oos.flush(); data = baos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } message.getBodyBuffer().writeInt(data.length); message.getBodyBuffer().writeBytes(data); }
public void setJMSReplyTo(final Destination dest) throws JMSException { if (dest == null) { message.removeProperty(HornetQMessage.REPLYTO_HEADER_NAME); replyTo = null; } else { if (dest instanceof HornetQDestination == false) { throw new InvalidDestinationException("Not a HornetQ destination " + dest); } HornetQDestination jbd = (HornetQDestination)dest; message.putStringProperty(HornetQMessage.REPLYTO_HEADER_NAME, jbd.getSimpleAddress()); replyTo = jbd; } }
public static void writeHttpMessage(HttpHeaders headers, byte[] body, ClientMessage message) throws Exception { MultivaluedMap<String, String> hdrs = headers.getRequestHeaders(); for (Entry<String, List<String>> entry : hdrs.entrySet()) { String key = entry.getKey(); if (isTransferableHttpHeader(key)) { List<String> vals = entry.getValue(); String value = concatenateHeaderValue(vals); message.putStringProperty(HttpHeaderProperty.toPropertyName(key), value); } } message.putBooleanProperty(POSTED_AS_HTTP_MESSAGE, true); message.getBodyBuffer().writeBytes(body); }
message.putStringProperty(propName, "Hello sent at " + new Date()); System.out.println("Sending the message.");
message.putStringProperty("prop", "ping " + n);
@Override public void onMessage(ClientMessage message) { try { message.acknowledge(); } catch (HornetQException exp) { logError(MODULE_NAME, exp.getMessage(), exp); } String command = message.getStringProperty("command"); String result = CommandLineParser.parse(command); ClientMessage response = MessageBusServer.getSession().createMessage(false); response.putStringProperty("response", result); response.putObjectProperty("receiver", "iofog.commandline.response"); try { synchronized (messageBusSessionLock) { MessageBusServer.getCommandlineProducer().send(response); } } catch (Exception exp) { logError(MODULE_NAME, exp.getMessage(), exp); } }
public void publish(HttpHeaders headers, byte[] body, String dup, boolean durable, Long ttl, Long expiration, Integer priority) throws Exception { Pooled pooled = getPooled(); try { ClientProducer producer = pooled.producer; ClientMessage message = createHornetQMessage(headers, body, durable, ttl, expiration, priority, pooled.session); message.putStringProperty(ClientMessage.HDR_DUPLICATE_DETECTION_ID.toString(), dup); producer.send(message); HornetQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); } catch (Exception ex) { try { pooled.session.close(); } catch (HornetQException e) { } addPooled(); throw ex; } }
coreMessage.putStringProperty(HornetQConnection.CONNECTION_ID_PROPERTY_NAME, connID);