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