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 */
017package org.apache.activemq.camel;
018
019import javax.jms.JMSException;
020import javax.jms.Message;
021import javax.jms.Queue;
022import javax.jms.QueueSender;
023
024import org.apache.activemq.ActiveMQSession;
025import org.apache.camel.Endpoint;
026
027/**
028 * A JMS {@link javax.jms.QueueSender} which sends message exchanges to a Camel
029 * {@link org.apache.camel.Endpoint}
030 * 
031 * 
032 */
033public 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     * Gets the queue associated with this <CODE>QueueSender</CODE>.
041     * 
042     * @return this sender's queue
043     * @throws JMSException if the JMS provider fails to get the queue for this
044     *                 <CODE>QueueSender</CODE> due to some internal error.
045     */
046
047    public Queue getQueue() throws JMSException {
048        return (Queue)super.getDestination();
049    }
050
051    /**
052     * Sends a message to a queue for an unidentified message producer. Uses the
053     * <CODE>QueueSender</CODE>'s default delivery mode, priority, and time
054     * to live. <p/> <p/> Typically, a message producer is assigned a queue at
055     * creation time; however, the JMS API also supports unidentified message
056     * producers, which require that the queue be supplied every time a message
057     * is sent.
058     * 
059     * @param queue the queue to send this message to
060     * @param message the message to send
061     * @throws JMSException if the JMS provider fails to send the message due to
062     *                 some internal error.
063     * @see javax.jms.MessageProducer#getDeliveryMode()
064     * @see javax.jms.MessageProducer#getTimeToLive()
065     * @see javax.jms.MessageProducer#getPriority()
066     */
067
068    public void send(Queue queue, Message message) throws JMSException {
069        super.send(queue, message);
070    }
071
072    /**
073     * Sends a message to a queue for an unidentified message producer,
074     * specifying delivery mode, priority and time to live. <p/> <p/> Typically,
075     * a message producer is assigned a queue at creation time; however, the JMS
076     * API also supports unidentified message producers, which require that the
077     * queue be supplied every time a message is sent.
078     * 
079     * @param queue the queue to send this message to
080     * @param message the message to send
081     * @param deliveryMode the delivery mode to use
082     * @param priority the priority for this message
083     * @param timeToLive the message's lifetime (in milliseconds)
084     * @throws JMSException if the JMS provider fails to send the message due to
085     *                 some internal error.
086     */
087
088    public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException {
089        super.send(queue, message, deliveryMode, priority, timeToLive);
090    }
091}