List of usage examples for javax.jms Message hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:org.opencastproject.message.broker.impl.MessageSenderImpl.java
/** * A common function for sending all types of messages that this class handles. Only one Message or one message * payload can be provided.//from w ww. ja v a 2 s. com * * @param destinationId * The id of the queue or topic. * @param type * The type of the destination either queue or topic. * @param createdMessage * An optional user created message. * @param messageText * An optional text payload for a message. * @param messageBytes * An optional byte[] payload. * @param offset * An optional offset for a byte[] payload. * @param length * An optional length of bytes to add to the message byte[] payload. */ private void send(String destinationId, DestinationType type, Option<Message> createdMessage, Option<String> messageText, Option<byte[]> messageBytes, Option<Integer> offset, Option<Integer> length, Option<Serializable> messageObject) { try { // Create a message or use the provided one. Message message = null; if (createdMessage.isSome()) { message = createdMessage.get(); } else if (messageText.isSome()) { message = getSession().createTextMessage(messageText.get()); } else if (messageBytes.isSome() && offset.isNone() && length.isNone()) { BytesMessage bytesMessage = getSession().createBytesMessage(); bytesMessage.writeBytes(messageBytes.get()); message = bytesMessage; } else if (messageBytes.isSome() && offset.isSome() && length.isSome()) { BytesMessage bytesMessage = getSession().createBytesMessage(); bytesMessage.writeBytes(messageBytes.get(), offset.get(), length.get()); message = bytesMessage; } else if (messageObject.isSome()) { final Organization organization = securityService.getOrganization(); final User user = securityService.getUser(); final BaseMessage baseMessage = new BaseMessage(organization, user, messageObject.get()); message = getSession().createObjectMessage(baseMessage); } else { throw new IllegalArgumentException("To send a message there must be a message payload specified!"); } Destination destination; // Create the destination (Topic or Queue) if (type.equals(DestinationType.Queue)) { destination = getSession().createQueue(destinationId); } else { destination = getSession().createTopic(destinationId); } // Tell the producer to send the message logger.trace("Sent message: " + message.hashCode() + " : " + Thread.currentThread().getName()); // Send the message getMessageProducer().send(destination, message); } catch (JMSException e) { logger.error("Had an exception while trying to send a message {}", ExceptionUtils.getStackTrace(e)); } }