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;
018
019import java.util.List;
020import javax.jms.JMSException;
021import org.apache.activemq.command.MessageDispatch;
022
023public interface MessageDispatchChannel {
024
025    public abstract void enqueue(MessageDispatch message);
026
027    public abstract void enqueueFirst(MessageDispatch message);
028
029    public abstract boolean isEmpty();
030
031    /**
032     * Used to get an enqueued message. The amount of time this method blocks is
033     * based on the timeout value. - if timeout==-1 then it blocks until a
034     * message is received. - if timeout==0 then it it tries to not block at
035     * all, it returns a message if it is available - if timeout>0 then it
036     * blocks up to timeout amount of time. Expired messages will consumed by
037     * this method.
038     * 
039     * @throws JMSException
040     * @return null if we timeout or if the consumer is closed.
041     * @throws InterruptedException
042     */
043    public abstract MessageDispatch dequeue(long timeout) throws InterruptedException;
044
045    public abstract MessageDispatch dequeueNoWait();
046
047    public abstract MessageDispatch peek();
048
049    public abstract void start();
050
051    public abstract void stop();
052
053    public abstract void close();
054
055    public abstract void clear();
056
057    public abstract boolean isClosed();
058
059    public abstract int size();
060
061    public abstract Object getMutex();
062
063    public abstract boolean isRunning();
064
065    public abstract List<MessageDispatch> removeAll();
066
067}