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.network; 018 019import org.apache.activemq.advisory.AdvisorySupport; 020import org.apache.activemq.command.ActiveMQDestination; 021import org.apache.activemq.command.ConsumerInfo; 022 023import java.util.List; 024 025/** 026 * Configuration for a NetworkBridge 027 * 028 * 029 */ 030public class NetworkBridgeConfiguration { 031 private boolean conduitSubscriptions = true; 032 private boolean dynamicOnly; 033 private boolean dispatchAsync = true; 034 private boolean decreaseNetworkConsumerPriority; 035 private int consumerPriorityBase = ConsumerInfo.NETWORK_CONSUMER_PRIORITY; 036 private boolean duplex; 037 private boolean bridgeTempDestinations = true; 038 private int prefetchSize = 1000; 039 private int networkTTL = 1; 040 private String brokerName = "localhost"; 041 private String brokerURL = ""; 042 private String userName; 043 private String password; 044 private String destinationFilter = null; 045 private String name = "NC"; 046 047 private List<ActiveMQDestination> excludedDestinations; 048 private List<ActiveMQDestination> dynamicallyIncludedDestinations; 049 private List<ActiveMQDestination> staticallyIncludedDestinations; 050 051 private boolean suppressDuplicateQueueSubscriptions = false; 052 private boolean suppressDuplicateTopicSubscriptions = true; 053 054 private boolean alwaysSyncSend = false; 055 private boolean staticBridge = false; 056 057 /** 058 * @return the conduitSubscriptions 059 */ 060 public boolean isConduitSubscriptions() { 061 return this.conduitSubscriptions; 062 } 063 064 /** 065 * @param conduitSubscriptions the conduitSubscriptions to set 066 */ 067 public void setConduitSubscriptions(boolean conduitSubscriptions) { 068 this.conduitSubscriptions = conduitSubscriptions; 069 } 070 071 /** 072 * @return the dynamicOnly 073 */ 074 public boolean isDynamicOnly() { 075 return this.dynamicOnly; 076 } 077 078 /** 079 * @param dynamicOnly the dynamicOnly to set 080 */ 081 public void setDynamicOnly(boolean dynamicOnly) { 082 this.dynamicOnly = dynamicOnly; 083 } 084 085 /** 086 * @return the bridgeTempDestinations 087 */ 088 public boolean isBridgeTempDestinations() { 089 return this.bridgeTempDestinations; 090 } 091 092 /** 093 * @param bridgeTempDestinations the bridgeTempDestinations to set 094 */ 095 public void setBridgeTempDestinations(boolean bridgeTempDestinations) { 096 this.bridgeTempDestinations = bridgeTempDestinations; 097 } 098 099 /** 100 * @return the decreaseNetworkConsumerPriority 101 */ 102 public boolean isDecreaseNetworkConsumerPriority() { 103 return this.decreaseNetworkConsumerPriority; 104 } 105 106 /** 107 * @param decreaseNetworkConsumerPriority the 108 * decreaseNetworkConsumerPriority to set 109 */ 110 public void setDecreaseNetworkConsumerPriority(boolean decreaseNetworkConsumerPriority) { 111 this.decreaseNetworkConsumerPriority = decreaseNetworkConsumerPriority; 112 } 113 114 /** 115 * @return the dispatchAsync 116 */ 117 public boolean isDispatchAsync() { 118 return this.dispatchAsync; 119 } 120 121 /** 122 * @param dispatchAsync the dispatchAsync to set 123 */ 124 public void setDispatchAsync(boolean dispatchAsync) { 125 this.dispatchAsync = dispatchAsync; 126 } 127 128 /** 129 * @return the duplex 130 */ 131 public boolean isDuplex() { 132 return this.duplex; 133 } 134 135 /** 136 * @param duplex the duplex to set 137 */ 138 public void setDuplex(boolean duplex) { 139 this.duplex = duplex; 140 } 141 142 /** 143 * @return the brokerName 144 */ 145 public String getBrokerName() { 146 return this.brokerName; 147 } 148 149 /** 150 * @param brokerName the localBrokerName to set 151 */ 152 public void setBrokerName(String brokerName) { 153 this.brokerName = brokerName; 154 } 155 156 /** 157 * @return the networkTTL 158 */ 159 public int getNetworkTTL() { 160 return this.networkTTL; 161 } 162 163 /** 164 * @param networkTTL the networkTTL to set 165 */ 166 public void setNetworkTTL(int networkTTL) { 167 this.networkTTL = networkTTL; 168 } 169 170 /** 171 * @return the password 172 */ 173 public String getPassword() { 174 return this.password; 175 } 176 177 /** 178 * @param password the password to set 179 */ 180 public void setPassword(String password) { 181 this.password = password; 182 } 183 184 /** 185 * @return the prefetchSize 186 */ 187 public int getPrefetchSize() { 188 return this.prefetchSize; 189 } 190 191 /** 192 * @param prefetchSize the prefetchSize to set 193 * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryIntPropertyEditor" 194 */ 195 public void setPrefetchSize(int prefetchSize) { 196 this.prefetchSize = prefetchSize; 197 } 198 199 /** 200 * @return the userName 201 */ 202 public String getUserName() { 203 return this.userName; 204 } 205 206 /** 207 * @param userName the userName to set 208 */ 209 public void setUserName(String userName) { 210 this.userName = userName; 211 } 212 213 /** 214 * @return the destinationFilter 215 */ 216 public String getDestinationFilter() { 217 if (this.destinationFilter == null) { 218 if (dynamicallyIncludedDestinations != null && !dynamicallyIncludedDestinations.isEmpty()) { 219 StringBuffer filter = new StringBuffer(); 220 String delimiter = ""; 221 for (ActiveMQDestination destination : dynamicallyIncludedDestinations) { 222 if (!destination.isTemporary()) { 223 filter.append(delimiter); 224 filter.append(AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX); 225 filter.append(destination.getDestinationTypeAsString()); 226 filter.append("."); 227 filter.append(destination.getPhysicalName()); 228 delimiter = ","; 229 } 230 } 231 return filter.toString(); 232 } else { 233 return AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + ">"; 234 } 235 } else { 236 // prepend consumer advisory prefix 237 // to keep backward compatibility 238 if (!this.destinationFilter.startsWith(AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX)) { 239 return AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + this.destinationFilter; 240 } else { 241 return this.destinationFilter; 242 } 243 } 244 } 245 246 /** 247 * @param destinationFilter the destinationFilter to set 248 */ 249 public void setDestinationFilter(String destinationFilter) { 250 this.destinationFilter = destinationFilter; 251 } 252 253 /** 254 * @return the name 255 */ 256 public String getName() { 257 return this.name; 258 } 259 260 /** 261 * @param name the name to set 262 */ 263 public void setName(String name) { 264 this.name = name; 265 } 266 267 public List<ActiveMQDestination> getExcludedDestinations() { 268 return excludedDestinations; 269 } 270 271 public void setExcludedDestinations( 272 List<ActiveMQDestination> excludedDestinations) { 273 this.excludedDestinations = excludedDestinations; 274 } 275 276 public List<ActiveMQDestination> getDynamicallyIncludedDestinations() { 277 return dynamicallyIncludedDestinations; 278 } 279 280 public void setDynamicallyIncludedDestinations( 281 List<ActiveMQDestination> dynamicallyIncludedDestinations) { 282 this.dynamicallyIncludedDestinations = dynamicallyIncludedDestinations; 283 } 284 285 public List<ActiveMQDestination> getStaticallyIncludedDestinations() { 286 return staticallyIncludedDestinations; 287 } 288 289 public void setStaticallyIncludedDestinations( 290 List<ActiveMQDestination> staticallyIncludedDestinations) { 291 this.staticallyIncludedDestinations = staticallyIncludedDestinations; 292 } 293 294 295 296 public boolean isSuppressDuplicateQueueSubscriptions() { 297 return suppressDuplicateQueueSubscriptions; 298 } 299 300 /** 301 * 302 * @param val if true, duplicate network queue subscriptions (in a cyclic network) will be suppressed 303 */ 304 public void setSuppressDuplicateQueueSubscriptions(boolean val) { 305 suppressDuplicateQueueSubscriptions = val; 306 } 307 308 public boolean isSuppressDuplicateTopicSubscriptions() { 309 return suppressDuplicateTopicSubscriptions; 310 } 311 312 /** 313 * 314 * @param val if true, duplicate network topic subscriptions (in a cyclic network) will be suppressed 315 */ 316 public void setSuppressDuplicateTopicSubscriptions(boolean val) { 317 suppressDuplicateTopicSubscriptions = val; 318 } 319 320 /** 321 * @return the brokerURL 322 */ 323 public String getBrokerURL() { 324 return this.brokerURL; 325 } 326 327 /** 328 * @param brokerURL the brokerURL to set 329 */ 330 public void setBrokerURL(String brokerURL) { 331 this.brokerURL = brokerURL; 332 } 333 334 public boolean isAlwaysSyncSend() { 335 return alwaysSyncSend; 336 } 337 338 /** 339 * @param alwaysSyncSend when true, both persistent and non persistent 340 * messages will be sent using a request. When false, non persistent messages 341 * are acked once the oneway send succeeds, which can potentially lead to 342 * message loss. 343 * Using an async request, allows multiple outstanding requests. This ensures 344 * that a bridge need not block all sending when the remote broker needs to 345 * flow control a single destination. 346 */ 347 public void setAlwaysSyncSend(boolean alwaysSyncSend) { 348 this.alwaysSyncSend = alwaysSyncSend; 349 } 350 351 public int getConsumerPriorityBase() { 352 return consumerPriorityBase; 353 } 354 355 /** 356 * @param consumerPriorityBase , default -5. Sets the starting priority 357 * for consumers. This base value will be decremented by the length of the 358 * broker path when decreaseNetworkConsumerPriority is set. 359 */ 360 public void setConsumerPriorityBase(int consumerPriorityBase) { 361 this.consumerPriorityBase = consumerPriorityBase; 362 } 363 364 public boolean isStaticBridge() { 365 return staticBridge; 366 } 367 368 public void setStaticBridge(boolean staticBridge) { 369 this.staticBridge = staticBridge; 370 } 371}