001 /*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements. See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership. The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied. See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 *
020 */
021 package org.apache.qpid.server.queue;
022
023 import org.apache.qpid.framing.AMQDataBlock;
024 import org.apache.qpid.framing.ContentHeaderBody;
025 import org.apache.qpid.framing.abstraction.ContentChunk;
026 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
027 import org.apache.qpid.server.protocol.AMQProtocolSession;
028 import org.apache.qpid.server.store.StoreContext;
029 import org.apache.qpid.AMQException;
030
031 import java.util.Iterator;
032
033 public interface AMQMessage
034 {
035 //Get Content relating to this message
036
037 Long getMessageId();
038
039 Iterator<AMQDataBlock> getBodyFrameIterator(AMQProtocolSession protocolSession, int channel);
040
041 Iterator<ContentChunk> getContentBodyIterator();
042
043 ContentHeaderBody getContentHeaderBody();
044
045 ContentChunk getContentChunk(int index);
046
047 Object getPublisherClientInstance();
048
049 Object getPublisherIdentifier();
050
051 MessagePublishInfo getMessagePublishInfo();
052
053 int getBodyCount();
054
055 long getSize();
056
057 long getArrivalTime();
058
059
060
061 //Check the status of this message
062
063 /**
064 * Called selectors to determin if the message has already been sent
065 *
066 * @return _deliveredToConsumer
067 */
068 boolean getDeliveredToConsumer();
069
070 /**
071 * Called to enforce the 'immediate' flag.
072 *
073 * @returns true if the message is marked for immediate delivery but has not been marked as delivered
074 * to a consumer
075 */
076 boolean immediateAndNotDelivered();
077
078 /**
079 * Checks to see if the message has expired. If it has the message is dequeued.
080 *
081 * @return true if the message has expire
082 *
083 * @throws org.apache.qpid.AMQException
084 */
085 boolean expired() throws AMQException;
086
087 /** Is this a persistent message
088 *
089 * @return true if the message is persistent
090 */
091 boolean isPersistent();
092
093
094 /**
095 * Called when this message is delivered to a consumer. (used to implement the 'immediate' flag functionality).
096 * And for selector efficiency.
097 */
098 void setDeliveredToConsumer();
099
100 void setExpiration(long expiration);
101
102 void setClientIdentifier(AMQProtocolSession.ProtocolSessionIdentifier sessionIdentifier);
103
104 /**
105 * This is called when all the content has been received.
106 * @param storeContext
107 *@param messagePublishInfo
108 * @param contentHeaderBody @throws org.apache.qpid.AMQException
109 */
110 void setPublishAndContentHeaderBody(StoreContext storeContext, MessagePublishInfo messagePublishInfo, ContentHeaderBody contentHeaderBody)
111 throws AMQException;
112
113 void addContentBodyFrame(StoreContext storeContext, ContentChunk contentChunk, boolean isLastContentBody)
114 throws AMQException;
115
116
117
118 String toString();
119
120 String debugIdentity();
121 }
|