001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 **/ 018 019 package org.activemq.message; 020 021 /** 022 * Denotes an object that can be serialized/deserailized using a PacketReader or PacketWriter 023 */ 024 025 public interface Packet { 026 027 /** 028 * Return the type of Packet 029 * 030 * @return integer representation of the type of Packet 031 */ 032 033 public int getPacketType(); 034 035 /** 036 * @return the unique id for this Packet 037 */ 038 039 public short getId(); 040 041 /** 042 * Set the unique id for this Packet 043 * 044 * @param newId 045 */ 046 047 public void setId(short newId); 048 049 /** 050 * @return true if a Recipt is required 051 */ 052 public boolean isReceiptRequired(); 053 054 /** 055 * @return true if this is a Receipt 056 */ 057 public boolean isReceipt(); 058 059 /** 060 * Set if a Recipt if required on receiving this Packet 061 * 062 * @param value 063 */ 064 065 public void setReceiptRequired(boolean value); 066 067 /** 068 * Retrieve if a JMS Message type or not 069 * 070 * @return true if it is a JMS Message 071 */ 072 public boolean isJMSMessage(); 073 074 /** 075 * Get a hint about how much memory this Packet is consuming 076 * 077 * @return an aproximation of the current memory used by this instance 078 */ 079 public int getMemoryUsage(); 080 081 /** 082 * Set a hint about how mujch memory this packet is consuming 083 * 084 * @param newMemoryUsage 085 */ 086 public void setMemoryUsage(int newMemoryUsage); 087 088 /** 089 * Increment reference count for bounded memory collections 090 * 091 * @return the incremented reference value 092 * @see org.activemq.io.util.MemoryBoundedQueue 093 */ 094 public int incrementMemoryReferenceCount(); 095 096 097 /** 098 * Decrement reference count for bounded memory collections 099 * 100 * @return the decremented reference value 101 * @see org.activemq.io.util.MemoryBoundedQueue 102 */ 103 public int decrementMemoryReferenceCount(); 104 105 /** 106 * @return the current reference count for bounded memory collections 107 * @see org.activemq.io.util.MemoryBoundedQueue 108 */ 109 public int getMemoryUsageReferenceCount(); 110 111 /** 112 * As the packet passes through the broker add the broker to the visited list 113 * 114 * @param brokerName the name of the broker 115 */ 116 public void addBrokerVisited(String brokerName); 117 118 /** 119 * clear list of brokers visited 120 */ 121 public void clearBrokersVisited(); 122 123 124 /** 125 * test to see if the named broker has already seen this packet 126 * 127 * @param brokerName the name of the broker 128 * @return true if the packet has visited the broker 129 */ 130 public boolean hasVisited(String brokerName); 131 132 /** 133 * @return Returns the brokersVisited. 134 */ 135 public String getBrokersVisitedAsString(); 136 137 /** 138 * Unspecified Packet type 139 */ 140 public static final int NOT_SET = 0; 141 142 /** 143 * ActiveMQMessage object 144 */ 145 public static final int ACTIVEMQ_MESSAGE = 6; 146 147 /** 148 * ActiveMQTextMessage object 149 */ 150 151 public static final int ACTIVEMQ_TEXT_MESSAGE = 7; 152 153 /** 154 * ActiveMQObjectMessage object 155 */ 156 157 public static final int ACTIVEMQ_OBJECT_MESSAGE = 8; 158 159 /** 160 * ActiveMQBytesMessage 161 */ 162 163 public static final int ACTIVEMQ_BYTES_MESSAGE = 9; 164 165 /** 166 * ActiveMQStreamMessage object 167 */ 168 169 public static final int ACTIVEMQ_STREAM_MESSAGE = 10; 170 171 /** 172 * ActiveMQMapMessage object 173 */ 174 175 public static final int ACTIVEMQ_MAP_MESSAGE = 11; 176 177 /** 178 * Message acknowledge 179 */ 180 public static final int ACTIVEMQ_MSG_ACK = 15; 181 182 /** 183 * Recipt message 184 */ 185 186 public static final int RECEIPT_INFO = 16; 187 188 /** 189 * Consumer Infomation 190 */ 191 192 public static final int CONSUMER_INFO = 17; 193 194 /** 195 * Producer Info 196 */ 197 198 public static final int PRODUCER_INFO = 18; 199 200 /** 201 * Transaction info 202 */ 203 204 public static final int TRANSACTION_INFO = 19; 205 206 /** 207 * XA Transaction info 208 */ 209 210 public static final int XA_TRANSACTION_INFO = 20; 211 212 /** 213 * Broker infomation message 214 */ 215 216 public static final int ACTIVEMQ_BROKER_INFO = 21; 217 218 /** 219 * Connection info message 220 */ 221 222 public static final int ACTIVEMQ_CONNECTION_INFO = 22; 223 224 225 /** 226 * Session Info message 227 */ 228 public static final int SESSION_INFO = 23; 229 230 /** 231 * Durable Unsubscribe message 232 */ 233 234 public static final int DURABLE_UNSUBSCRIBE = 24; 235 236 237 /** 238 * A receipt with an Object reponse. 239 */ 240 public static final int RESPONSE_RECEIPT_INFO = 25; 241 242 243 /** 244 * A receipt with an Integer reponse. 245 */ 246 public static final int INT_RESPONSE_RECEIPT_INFO = 26; 247 248 /** 249 * Infomation about the Capacity for more Messages for either Connection/Broker 250 */ 251 public static final int CAPACITY_INFO = 27; 252 253 /** 254 * Request infomation about the current capacity 255 */ 256 public static final int CAPACITY_INFO_REQUEST = 28; 257 258 /** 259 * Infomation about the wire format expected 260 */ 261 public static final int WIRE_FORMAT_INFO = 29; 262 263 /** 264 * Keep-alive message 265 */ 266 public static final int KEEP_ALIVE = 30; 267 268 /** 269 * A command to the Broker Admin 270 */ 271 public static final int BROKER_ADMIN_COMMAND = 31; 272 273 /** 274 * transmit cached values for the wire format 275 */ 276 public static final int CACHED_VALUE_COMMAND = 32; 277 278 /** 279 * transmit cached values for the wire format 280 */ 281 public static final int CLEANUP_CONNECTION_INFO = 33; 282 }