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.broker.region; 018 019import java.io.IOException; 020import java.util.List; 021 022import org.apache.activemq.Service; 023import org.apache.activemq.broker.ConnectionContext; 024import org.apache.activemq.broker.ProducerBrokerExchange; 025import org.apache.activemq.broker.region.policy.DeadLetterStrategy; 026import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy; 027import org.apache.activemq.broker.region.policy.SlowConsumerStrategy; 028import org.apache.activemq.command.ActiveMQDestination; 029import org.apache.activemq.command.Message; 030import org.apache.activemq.command.MessageAck; 031import org.apache.activemq.command.MessageDispatchNotification; 032import org.apache.activemq.command.ProducerInfo; 033import org.apache.activemq.store.MessageStore; 034import org.apache.activemq.thread.Task; 035import org.apache.activemq.usage.MemoryUsage; 036import org.apache.activemq.usage.TempUsage; 037import org.apache.activemq.usage.Usage; 038 039/** 040 * 041 */ 042public interface Destination extends Service, Task, Message.MessageDestination { 043 044 public static final DeadLetterStrategy DEFAULT_DEAD_LETTER_STRATEGY = new SharedDeadLetterStrategy(); 045 public static final long DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL = 30000; 046 047 void addSubscription(ConnectionContext context, Subscription sub) throws Exception; 048 049 void removeSubscription(ConnectionContext context, Subscription sub, long lastDeliveredSequenceId) throws Exception; 050 051 void addProducer(ConnectionContext context, ProducerInfo info) throws Exception; 052 053 void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception; 054 055 void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception; 056 057 void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException; 058 059 long getInactiveTimeoutBeforeGC(); 060 061 void markForGC(long timeStamp); 062 063 boolean canGC(); 064 065 void gc(); 066 067 ActiveMQDestination getActiveMQDestination(); 068 069 @Override 070 MemoryUsage getMemoryUsage(); 071 072 void setMemoryUsage(MemoryUsage memoryUsage); 073 074 TempUsage getTempUsage(); 075 076 void dispose(ConnectionContext context) throws IOException; 077 078 boolean isDisposed(); 079 080 DestinationStatistics getDestinationStatistics(); 081 082 DeadLetterStrategy getDeadLetterStrategy(); 083 084 Message[] browse(); 085 086 String getName(); 087 088 MessageStore getMessageStore(); 089 090 boolean isProducerFlowControl(); 091 092 void setProducerFlowControl(boolean value); 093 094 boolean isAlwaysRetroactive(); 095 096 void setAlwaysRetroactive(boolean value); 097 098 /** 099 * Set's the interval at which warnings about producers being blocked by 100 * resource usage will be triggered. Values of 0 or less will disable 101 * warnings 102 * 103 * @param blockedProducerWarningInterval the interval at which warning about 104 * blocked producers will be triggered. 105 */ 106 public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval); 107 108 /** 109 * 110 * @return the interval at which warning about blocked producers will be 111 * triggered. 112 */ 113 public long getBlockedProducerWarningInterval(); 114 115 int getMaxProducersToAudit(); 116 117 void setMaxProducersToAudit(int maxProducersToAudit); 118 119 int getMaxAuditDepth(); 120 121 void setMaxAuditDepth(int maxAuditDepth); 122 123 boolean isEnableAudit(); 124 125 void setEnableAudit(boolean enableAudit); 126 127 boolean isActive(); 128 129 int getMaxPageSize(); 130 131 public void setMaxPageSize(int maxPageSize); 132 133 public int getMaxBrowsePageSize(); 134 135 public void setMaxBrowsePageSize(int maxPageSize); 136 137 public boolean isUseCache(); 138 139 public void setUseCache(boolean useCache); 140 141 @Override 142 public int getMinimumMessageSize(); 143 144 public void setMinimumMessageSize(int minimumMessageSize); 145 146 public int getCursorMemoryHighWaterMark(); 147 148 public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark); 149 150 /** 151 * optionally called by a Subscriber - to inform the Destination its ready 152 * for more messages 153 */ 154 public void wakeup(); 155 156 /** 157 * @return true if lazyDispatch is enabled 158 */ 159 public boolean isLazyDispatch(); 160 161 /** 162 * set the lazy dispatch - default is false 163 * 164 * @param value 165 */ 166 public void setLazyDispatch(boolean value); 167 168 /** 169 * Inform the Destination a message has expired 170 * 171 * @param context 172 * @param subs 173 * @param node 174 */ 175 void messageExpired(ConnectionContext context, Subscription subs, MessageReference node); 176 177 /** 178 * called when message is consumed 179 * 180 * @param context 181 * @param messageReference 182 */ 183 void messageConsumed(ConnectionContext context, MessageReference messageReference); 184 185 /** 186 * Called when message is delivered to the broker 187 * 188 * @param context 189 * @param messageReference 190 */ 191 void messageDelivered(ConnectionContext context, MessageReference messageReference); 192 193 /** 194 * Called when a message is discarded - e.g. running low on memory This will 195 * happen only if the policy is enabled - e.g. non durable topics 196 * 197 * @param context 198 * @param messageReference 199 * @param sub 200 */ 201 void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference); 202 203 /** 204 * Called when there is a slow consumer 205 * 206 * @param context 207 * @param subs 208 */ 209 void slowConsumer(ConnectionContext context, Subscription subs); 210 211 /** 212 * Called to notify a producer is too fast 213 * 214 * @param context 215 * @param producerInfo 216 */ 217 void fastProducer(ConnectionContext context, ProducerInfo producerInfo); 218 219 /** 220 * Called when a Usage reaches a limit 221 * 222 * @param context 223 * @param usage 224 */ 225 void isFull(ConnectionContext context, Usage<?> usage); 226 227 List<Subscription> getConsumers(); 228 229 /** 230 * called on Queues in slave mode to allow dispatch to follow subscription 231 * choice of master 232 * 233 * @param messageDispatchNotification 234 * @throws Exception 235 */ 236 void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception; 237 238 boolean isPrioritizedMessages(); 239 240 SlowConsumerStrategy getSlowConsumerStrategy(); 241 242 boolean isDoOptimzeMessageStorage(); 243 void setDoOptimzeMessageStorage(boolean doOptimzeMessageStorage); 244 245 public void clearPendingMessages(); 246 247 void duplicateFromStore(Message message, Subscription subscription); 248}