@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); }
/** * 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); }
producer.send(message); producer.close();
public void run() { try { producer.send(dest, message); // as soon as we are done sending the large message // we unset the delivery flag and we will call the deliveryAsync on the queue // so the bridge will be able to resume work unsetLargeMessageDelivery(); if (queue != null) { queue.deliverAsync(); } } catch (final HornetQException e) { unsetLargeMessageDelivery(); HornetQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); connectionFailed(e, false); } } });
/** * @param ref * @param message * @return */ private HandleStatus deliverStandardMessage(SimpleString dest, final MessageReference ref, ServerMessage message) { // if we failover during send then there is a chance that the // that this will throw a disconnect, we need to remove the message // from the acks so it will get resent, duplicate detection will cope // with any messages resent if (log.isTraceEnabled()) { log.trace("going to send message " + message); } try { producer.send(dest, message); } catch (final HornetQException e) { log.warn("Unable to send message " + ref + ", will try again once bridge reconnects", e); // We remove this reference as we are returning busy which means the reference will never leave the Queue. // because of this we have to remove the reference here refs.remove(ref); connectionFailed(e, false); return HandleStatus.BUSY; } return HandleStatus.HANDLED; }
public void run() { try { producer.send(dest, message); // as soon as we are done sending the large message // we unset the delivery flag and we will call the deliveryAsync on the queue // so the bridge will be able to resume work unsetLargeMessageDelivery(); if (queue != null) { queue.deliverAsync(); } } catch (final HornetQException e) { unsetLargeMessageDelivery(); log.warn("Unable to send message " + ref + ", will try again once bridge reconnects", e); connectionFailed(e, false); } } });
/** * @param ref * @param message * @return */ private HandleStatus deliverStandardMessage(SimpleString dest, final MessageReference ref, ServerMessage message) { // if we failover during send then there is a chance that the // that this will throw a disconnect, we need to remove the message // from the acks so it will get resent, duplicate detection will cope // with any messages resent if (HornetQServerLogger.LOGGER.isTraceEnabled()) { HornetQServerLogger.LOGGER.trace("going to send message " + message); } try { producer.send(dest, message); } catch (final HornetQException e) { HornetQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); // We remove this reference as we are returning busy which means the reference will never leave the Queue. // because of this we have to remove the reference here refs.remove(ref); connectionFailed(e, false); return HandleStatus.BUSY; } return HandleStatus.HANDLED; }
System.out.println("Sending the message."); producer.send(message);
producer.send(message);
/** * publishes a {@link Message} * * @param message - {@link Message} to be published * @throws Exception */ synchronized void publish(Message message) throws Exception { byte[] bytes = message.getBytes(); try { archive.save(bytes, message.getTimestamp()); } catch (Exception e) { logError("Message Publisher (" + this.name + ")", "unable to archive massage --> " + e.getMessage(), e); } for (String receiver : route.getReceivers()) { ClientMessage msg = session.createMessage(false); msg.putObjectProperty("receiver", receiver); msg.putBytesProperty("message", bytes); synchronized (messageBusSessionLock) { producer.send(msg); } } }
public void publish(HttpHeaders headers, byte[] body, 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); 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; } }
@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; } }
producer.send(address, coreMessage);
prod.send(message);
prod.send(message);