01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.server.queue;
22
23 import org.apache.qpid.AMQException;
24 import org.apache.qpid.framing.ContentHeaderBody;
25 import org.apache.qpid.server.store.StoreContext;
26 import org.apache.qpid.framing.abstraction.ContentChunk;
27 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
28
29 /**
30 * A pluggable way of getting message data. Implementations can provide intelligent caching for example or
31 * even no caching at all to minimise the broker memory footprint.
32 */
33 public interface AMQMessageHandle
34 {
35 ContentHeaderBody getContentHeaderBody(StoreContext context) throws AMQException;
36
37 /**
38 *
39 * @return the messageId for the message associated with this handle
40 */
41 Long getMessageId();
42
43
44 /**
45 * @return the number of body frames associated with this message
46 */
47 int getBodyCount(StoreContext context) throws AMQException;
48
49 /**
50 * @return the size of the body
51 */
52 long getBodySize(StoreContext context) throws AMQException;
53
54 /**
55 * Get a particular content body
56 * @param index the index of the body to retrieve, must be between 0 and getBodyCount() - 1
57 * @return a content body
58 * @throws IllegalArgumentException if the index is invalid
59 */
60 ContentChunk getContentChunk(StoreContext context, int index) throws IllegalArgumentException, AMQException;
61
62 void addContentBodyFrame(StoreContext storeContext, ContentChunk contentBody, boolean isLastContentBody) throws AMQException;
63
64 MessagePublishInfo getMessagePublishInfo(StoreContext context) throws AMQException;
65
66 boolean isPersistent();
67
68 void setPublishAndContentHeaderBody(StoreContext storeContext, MessagePublishInfo messagePublishInfo,
69 ContentHeaderBody contentHeaderBody)
70 throws AMQException;
71
72 void removeMessage(StoreContext storeContext) throws AMQException;
73
74 long getArrivalTime();
75 }
|