001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.jms;
018    
019    import org.apache.activemq.ActiveMQSession;
020    import org.apache.camel.Endpoint;
021    
022    import javax.jms.JMSException;
023    import javax.jms.Message;
024    import javax.jms.Queue;
025    import javax.jms.QueueSender;
026    
027    /**
028     * A JMS {@link javax.jms.QueueSender} which sends message exchanges to a
029     * Camel {@link org.apache.camel.Endpoint}
030     *
031     * @version $Revision: $
032     */
033    public class CamelQueueSender extends CamelMessageProducer implements QueueSender {
034    
035        public CamelQueueSender(CamelQueue destination, Endpoint endpoint, ActiveMQSession session) throws JMSException {
036            super(destination, endpoint, session);
037        }
038    
039    
040        /**
041         * Gets the queue associated with this <CODE>QueueSender</CODE>.
042         *
043         * @return this sender's queue
044         * @throws JMSException if the JMS provider fails to get the queue for this
045         *                      <CODE>QueueSender</CODE> due to some internal error.
046         */
047    
048        public Queue getQueue() throws JMSException {
049            return (Queue) super.getDestination();
050        }
051    
052        /**
053         * Sends a message to a queue for an unidentified message producer. Uses
054         * the <CODE>QueueSender</CODE>'s default delivery mode, priority, and
055         * time to live.
056         * <p/>
057         * <p/>
058         * Typically, a message producer is assigned a queue at creation time;
059         * however, the JMS API also supports unidentified message producers, which
060         * require that the queue be supplied every time a message is sent.
061         *
062         * @param queue   the queue to send this message to
063         * @param message the message to send
064         * @throws JMSException if the JMS provider fails to send the message due to some
065         *                      internal error.
066         * @see javax.jms.MessageProducer#getDeliveryMode()
067         * @see javax.jms.MessageProducer#getTimeToLive()
068         * @see javax.jms.MessageProducer#getPriority()
069         */
070    
071        public void send(Queue queue, Message message) throws JMSException {
072            super.send(queue, message);
073        }
074    
075        /**
076         * Sends a message to a queue for an unidentified message producer,
077         * specifying delivery mode, priority and time to live.
078         * <p/>
079         * <p/>
080         * Typically, a message producer is assigned a queue at creation time;
081         * however, the JMS API also supports unidentified message producers, which
082         * require that the queue be supplied every time a message is sent.
083         *
084         * @param queue        the queue to send this message to
085         * @param message      the message to send
086         * @param deliveryMode the delivery mode to use
087         * @param priority     the priority for this message
088         * @param timeToLive   the message's lifetime (in milliseconds)
089         * @throws JMSException if the JMS provider fails to send the message due to some
090         *                      internal error.
091         */
092    
093        public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive)
094                throws JMSException {
095            super.send(queue,
096                    message,
097                    deliveryMode,
098                    priority,
099                    timeToLive);
100        }
101    }