/** * Create a JMS BytesMessage for the given byte array. * @param bytes the byte array to convert * @param session current JMS session * @return the resulting message * @throws JMSException if thrown by JMS methods * @see javax.jms.Session#createBytesMessage */ protected BytesMessage createMessageForByteArray(byte[] bytes, Session session) throws JMSException { BytesMessage message = session.createBytesMessage(); message.writeBytes(bytes); return message; }
/** * Create a new JMS Session for this JMS invoker. */ protected Session createSession(Connection con) throws JMSException { return con.createSession(false, Session.AUTO_ACKNOWLEDGE); }
@Override public void setDisableMessageID(boolean disableMessageID) throws JMSException { if (this.originalDisableMessageID == null) { this.originalDisableMessageID = this.target.getDisableMessageID(); } this.target.setDisableMessageID(disableMessageID); }
@Override public void send(Message message, int deliveryMode, int priority, long timeToLive, CompletionListener completionListener) throws JMSException { this.target.send(message, deliveryMode, priority, timeToLive, completionListener); }
/** * Extract a String from the given TextMessage. * @param message the message to convert * @return the resulting String * @throws JMSException if thrown by JMS methods */ protected String extractStringFromMessage(TextMessage message) throws JMSException { return message.getText(); }
/** * Create a JMS TextMessage for the given String. * @param text the String to convert * @param session current JMS session * @return the resulting message * @throws JMSException if thrown by JMS methods * @see javax.jms.Session#createTextMessage */ protected TextMessage createMessageForString(String text, Session session) throws JMSException { return session.createTextMessage(text); }
@Override public String getJMSType() throws JMSException { throw new JMSException("illegal property"); } };
/** * Extract a byte array from the given {@link BytesMessage}. * @param message the message to convert * @return the resulting byte array * @throws JMSException if thrown by JMS methods */ protected byte[] extractByteArrayFromMessage(BytesMessage message) throws JMSException { byte[] bytes = new byte[(int) message.getBodyLength()]; message.readBytes(bytes); return bytes; }
/** * Extract a Serializable object from the given {@link ObjectMessage}. * @param message the message to convert * @return the resulting Serializable object * @throws JMSException if thrown by JMS methods */ protected Serializable extractSerializableFromMessage(ObjectMessage message) throws JMSException { return message.getObject(); }
/** * Create a JMS ObjectMessage for the given Serializable object. * @param object the Serializable object to convert * @param session current JMS session * @return the resulting message * @throws JMSException if thrown by JMS methods * @see javax.jms.Session#createObjectMessage */ protected ObjectMessage createMessageForSerializable(Serializable object, Session session) throws JMSException { return session.createObjectMessage(object); }
public CachedMessageProducer(MessageProducer target) throws JMSException { this.target = target; this.deliveryMode = target.getDeliveryMode(); this.priority = target.getPriority(); this.timeToLive = target.getTimeToLive(); }
@Override public Session createSession(Connection con) throws JMSException { return ((TopicConnection) con).createTopicSession( synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE); } @Override
@Override public TopicConnection createTopicConnection(String username, String password) throws JMSException { throw new javax.jms.IllegalStateException( "SingleConnectionFactory does not support custom username and password"); }
/** * Create a JMS Session for the given Connection. * <p>This implementation uses JMS 1.1 API. * @param con the JMS Connection to create a Session for * @return the new JMS Session * @throws javax.jms.JMSException if thrown by JMS API methods */ protected Session createSession(Connection con) throws JMSException { return con.createSession(true, Session.AUTO_ACKNOWLEDGE); }
@Override public int getJMSDeliveryMode() throws JMSException { throw new JMSException("illegal property"); } };
@Override public String getJMSMessageID() throws JMSException { throw new JMSException("illegal property"); } };
@Override public long getJMSTimestamp() throws JMSException { throw new JMSException("illegal property"); } };
@Override public Destination getJMSDestination() throws JMSException { throw new JMSException("illegal property"); } };
@Override public int getJMSPriority() throws JMSException { throw new JMSException("illegal property"); } };
@Override public void setJMSReplyTo(Destination replyTo) throws JMSException { throw new JMSException("illegal property"); } };