Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » [javadoc | source]
org.apache.activemq.broker
public class: BrokerService [javadoc | source]
java.lang.Object
   org.apache.activemq.broker.BrokerService

All Implemented Interfaces:
    Service

Direct Known Subclasses:
    SslBrokerService, XBeanBrokerService

Manages the lifecycle of an ActiveMQ Broker. A BrokerService consists of a number of transport connectors, network connectors and a bunch of properties which can be used to configure the broker as its lazily created.
Field Summary
protected  CountDownLatch slaveStartSignal     
public static final  String DEFAULT_PORT     
public static final  String LOCAL_HOST_NAME     
public static final  String DEFAULT_BROKER_NAME     
protected  DestinationFactory destinationFactory     
Method from org.apache.activemq.broker.BrokerService Summary:
addConnector,   addConnector,   addConnector,   addConnector,   addInterceptors,   addJmsConnector,   addNetworkConnector,   addNetworkConnector,   addNetworkConnector,   addProxyConnector,   addProxyConnector,   addProxyConnector,   addService,   addShutdownHook,   addShutdownHook,   checkQueueSize,   configureService,   configureServices,   containerShutdown,   createAdminConnectionContext,   createBroker,   createBrokerObjectName,   createDefaultDestinationInterceptor,   createNetworkConnectorObjectName,   createPersistenceAdapter,   createPersistenceFactory,   createRegionBroker,   createRegionBroker,   createTransportConnector,   deleteAllMessages,   getAdminConnectionContext,   getAdminView,   getBroker,   getBrokerDataDirectory,   getBrokerName,   getBrokerObjectName,   getConnectorByName,   getConsumerSystemUsage,   getConsumerSystemUsagePortion,   getDataDirectoryFile,   getDestination,   getDestinationInterceptors,   getDestinationPolicy,   getDestinations,   getJmsBridgeConnectors,   getManagementContext,   getMasterConnectorURI,   getMessageAuthorizationPolicy,   getNetworkConnectorByName,   getNetworkConnectorURIs,   getNetworkConnectors,   getPersistenceAdapter,   getPersistenceFactory,   getPersistenceTaskRunnerFactory,   getPersistenceThreadPriority,   getPlugins,   getPort,   getProducerSystemUsage,   getProducerSystemUsagePortion,   getProxyConnectors,   getRegionBroker,   getServices,   getSlaveStartSignal,   getSslContext,   getSystemExitOnShutdownExitCode,   getSystemUsage,   getTaskRunnerFactory,   getTaskRunnerPriority,   getTempDataStore,   getTimeBeforePurgeTempDestinations,   getTmpDataDirectory,   getTransportConnectorURIs,   getTransportConnectorURIsAsMap,   getTransportConnectors,   getVmConnectorURI,   getWaitForSlaveTimeout,   handleIOException,   isAdvisorySupport,   isCacheTempDestinations,   isDedicatedTaskRunner,   isDeleteAllMessagesOnStartup,   isEnableStatistics,   isKeepDurableSubsActive,   isMonitorConnectionSplits,   isPassiveSlave,   isPersistent,   isPopulateJMSXUserID,   isShutdownOnMasterFailure,   isShutdownOnSlaveFailure,   isSlave,   isSplitSystemUsageForProducersConsumers,   isStarted,   isSupportFailOver,   isSystemExitOnShutdown,   isUseJmx,   isUseLocalHostBrokerName,   isUseLoggingForShutdownErrors,   isUseMirroredQueues,   isUseShutdownHook,   isUseTempMirroredQueues,   isUseVirtualTopics,   isWaitForSlave,   logError,   masterFailed,   processHelperProperties,   registerConnectorMBean,   registerFTConnectorMBean,   registerJmsConnectorMBean,   registerNetworkConnectorMBean,   registerPersistenceAdapterMBean,   registerProxyConnectorMBean,   removeConnector,   removeDestination,   removeJmsConnector,   removeNetworkConnector,   removeService,   removeShutdownHook,   removeShutdownHook,   setAdminView,   setAdvisorySupport,   setBrokerName,   setBrokerObjectName,   setCacheTempDestinations,   setConsumerSystemUsage,   setConsumerSystemUsagePortion,   setDataDirectory,   setDataDirectoryFile,   setDedicatedTaskRunner,   setDeleteAllMessagesOnStartup,   setDestinationFactory,   setDestinationInterceptors,   setDestinationPolicy,   setDestinations,   setEnableStatistics,   setIoExceptionHandler,   setJmsBridgeConnectors,   setKeepDurableSubsActive,   setManagementContext,   setMasterConnectorURI,   setMessageAuthorizationPolicy,   setMonitorConnectionSplits,   setNetworkConnectorURIs,   setNetworkConnectors,   setPassiveSlave,   setPersistenceAdapter,   setPersistenceFactory,   setPersistenceTaskRunnerFactory,   setPersistenceThreadPriority,   setPersistent,   setPlugins,   setPopulateJMSXUserID,   setProducerSystemUsage,   setProducerSystemUsagePortion,   setProxyConnectors,   setRegionBroker,   setServices,   setShutdownOnMasterFailure,   setShutdownOnSlaveFailure,   setSplitSystemUsageForProducersConsumers,   setSslContext,   setSupportFailOver,   setSystemExitOnShutdown,   setSystemExitOnShutdownExitCode,   setSystemUsage,   setTaskRunnerFactory,   setTaskRunnerPriority,   setTempDataStore,   setTimeBeforePurgeTempDestinations,   setTmpDataDirectory,   setTransportConnectorURIs,   setTransportConnectors,   setUseJmx,   setUseLocalHostBrokerName,   setUseLoggingForShutdownErrors,   setUseMirroredQueues,   setUseShutdownHook,   setUseTempMirroredQueues,   setUseVirtualTopics,   setVmConnectorURI,   setWaitForSlave,   setWaitForSlaveTimeout,   slaveConnectionEstablished,   start,   start,   startAllConnectors,   startDestinations,   startDestinationsInPersistenceStore,   startManagementContext,   startTransportConnector,   stop,   stopAllConnectors,   stopGracefully,   toString,   unregisterConnectorMBean,   unregisterNetworkConnectorMBean,   unregisterPersistenceAdapterMBean,   waitForSlave,   waitUntilStarted,   waitUntilStopped
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.activemq.broker.BrokerService Detail:
 public TransportConnector addConnector(String bindAddress) throws Exception 
    Adds a new transport connector for the given bind address
 public TransportConnector addConnector(URI bindAddress) throws Exception 
    Adds a new transport connector for the given bind address
 public TransportConnector addConnector(TransportServer transport) throws Exception 
    Adds a new transport connector for the given TransportServer transport
 public TransportConnector addConnector(TransportConnector connector) throws Exception 
    Adds a new transport connector
 protected Broker addInterceptors(Broker broker) throws Exception 
    Strategy method to add interceptors to the broker
 public JmsConnector addJmsConnector(JmsConnector connector) throws Exception 
 public NetworkConnector addNetworkConnector(String discoveryAddress) throws Exception 
    Adds a new network connector using the given discovery address
 public NetworkConnector addNetworkConnector(URI discoveryAddress) throws Exception 
    Adds a new network connector using the given discovery address
 public NetworkConnector addNetworkConnector(NetworkConnector connector) throws Exception 
    Adds a new network connector to connect this broker to a federated network
 public ProxyConnector addProxyConnector(String bindAddress) throws Exception 
    Adds a new proxy connector using the given bind address
 public ProxyConnector addProxyConnector(URI bindAddress) throws Exception 
    Adds a new proxy connector using the given bind address
 public ProxyConnector addProxyConnector(ProxyConnector connector) throws Exception 
 public  void addService(Service service) 
    Adds a new service so that it will be started as part of the broker lifecycle
 protected  void addShutdownHook() 
 public  void addShutdownHook(Runnable hook) 
 public boolean checkQueueSize(String queueName) 
 protected  void configureService(Object service) 
    Perform any custom dependency injection
 protected  void configureServices(Object[] services) 
    Perform any custom dependency injection
 protected  void containerShutdown() 
    Causes a clean shutdown of the container when the VM is being shut down
 protected ConnectionContext createAdminConnectionContext() throws Exception 
    Factory method to create the new administration connection context object. Note this method is here rather than inside a default broker implementation to ensure that the broker reference inside it is the outer most interceptor
 protected Broker createBroker() throws Exception 
    Factory method to create a new broker
 protected ObjectName createBrokerObjectName() throws IOException 
 protected DestinationInterceptor[] createDefaultDestinationInterceptor() 
    Create the default destination interceptor
 protected ObjectName createNetworkConnectorObjectName(NetworkConnector connector) throws MalformedObjectNameException 
 protected PersistenceAdapter createPersistenceAdapter() throws IOException 
 protected AMQPersistenceAdapterFactory createPersistenceFactory() 
 protected Broker createRegionBroker() throws Exception 
    Factory method to create the core region broker onto which interceptors are added
 protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws IOException 
 protected TransportConnector createTransportConnector(URI brokerURI) throws Exception 
 public  void deleteAllMessages() throws IOException 
    Delete all messages from the persistent store
 public ConnectionContext getAdminConnectionContext() throws Exception 
    Returns the broker's administration connection context used for configuring the broker at startup
 public BrokerView getAdminView() throws Exception 
    Returns the administration view of the broker; used to create and destroy resources such as queues and topics. Note this method returns null if JMX is disabled.
 public Broker getBroker() throws Exception 
    Returns the message broker
 public File getBrokerDataDirectory() 
 public String getBrokerName() 
 public ObjectName getBrokerObjectName() throws IOException 
 public TransportConnector getConnectorByName(String connectorName) 
 public SystemUsage getConsumerSystemUsage() throws IOException 
 public int getConsumerSystemUsagePortion() 
 public File getDataDirectoryFile() 
 public Destination getDestination(ActiveMQDestination destination) throws Exception 
    Looks up and lazily creates if necessary the destination for the given JMS name
 public DestinationInterceptor[] getDestinationInterceptors() 
 public PolicyMap getDestinationPolicy() 
 public ActiveMQDestination[] getDestinations() 
 public JmsConnector[] getJmsBridgeConnectors() 
 public ManagementContext getManagementContext() 
 public String getMasterConnectorURI() 
 public MessageAuthorizationPolicy getMessageAuthorizationPolicy() 
 public NetworkConnector getNetworkConnectorByName(String connectorName) 
 public String[] getNetworkConnectorURIs() 
 public List<NetworkConnector> getNetworkConnectors() 
 public PersistenceAdapter getPersistenceAdapter() throws IOException 
 public PersistenceAdapterFactory getPersistenceFactory() 
 public TaskRunnerFactory getPersistenceTaskRunnerFactory() 
 public int getPersistenceThreadPriority() 
 public BrokerPlugin[] getPlugins() 
 protected Object getPort(Map options) 
    Extracts the port from the options
 public SystemUsage getProducerSystemUsage() throws IOException 
 public int getProducerSystemUsagePortion() 
 public List<ProxyConnector> getProxyConnectors() 
 public Broker getRegionBroker() 
 public Service[] getServices() 
 public CountDownLatch getSlaveStartSignal() 
 public SslContext getSslContext() 
 public int getSystemExitOnShutdownExitCode() 
 public SystemUsage getSystemUsage() 
 public TaskRunnerFactory getTaskRunnerFactory() 
 public int getTaskRunnerPriority() 
 public synchronized Store getTempDataStore() 
 public int getTimeBeforePurgeTempDestinations() 
 public File getTmpDataDirectory() 
 public String[] getTransportConnectorURIs() 
 public Map<String, String> getTransportConnectorURIsAsMap() 
 public List<TransportConnector> getTransportConnectors() 
 public URI getVmConnectorURI() 
 public long getWaitForSlaveTimeout() 
 public  void handleIOException(IOException exception) 
 public boolean isAdvisorySupport() 
 public boolean isCacheTempDestinations() 
 public boolean isDedicatedTaskRunner() 
 public boolean isDeleteAllMessagesOnStartup() 
 public boolean isEnableStatistics() 
 public boolean isKeepDurableSubsActive() 
 public boolean isMonitorConnectionSplits() 
 public boolean isPassiveSlave() 
    Get the passiveSlave
 public boolean isPersistent() 
 public boolean isPopulateJMSXUserID() 
 public boolean isShutdownOnMasterFailure() 
 public boolean isShutdownOnSlaveFailure() 
 public boolean isSlave() 
 public boolean isSplitSystemUsageForProducersConsumers() 
 public boolean isStarted() 
 public boolean isSupportFailOver() 
 public boolean isSystemExitOnShutdown() 
 public boolean isUseJmx() 
 public boolean isUseLocalHostBrokerName() 
 public boolean isUseLoggingForShutdownErrors() 
 public boolean isUseMirroredQueues() 
 public boolean isUseShutdownHook() 
 public boolean isUseTempMirroredQueues() 
 public boolean isUseVirtualTopics() 
 public boolean isWaitForSlave() 
 protected  void logError(String message,
    Throwable e) 
 public  void masterFailed() 
 protected  void processHelperProperties() throws Exception 
    Handles any lazy-creation helper properties which are added to make things easier to configure inside environments such as Spring
 protected TransportConnector registerConnectorMBean(TransportConnector connector) throws IOException 
 protected  void registerFTConnectorMBean(MasterConnector connector) throws IOException 
 protected  void registerJmsConnectorMBean(JmsConnector connector) throws IOException 
 protected  void registerNetworkConnectorMBean(NetworkConnector connector) throws IOException 
 protected PersistenceAdapter registerPersistenceAdapterMBean(PersistenceAdapter adaptor) throws IOException 
 protected  void registerProxyConnectorMBean(ProxyConnector connector) throws IOException 
 public boolean removeConnector(TransportConnector connector) throws Exception 
    Stops and removes a transport connector from the broker.
 public  void removeDestination(ActiveMQDestination destination) throws Exception 
 public JmsConnector removeJmsConnector(JmsConnector connector) 
 public boolean removeNetworkConnector(NetworkConnector connector) 
    Removes the given network connector without stopping it. The caller should call NetworkConnector#stop() to close the connector
 public  void removeService(Service service) 
 protected  void removeShutdownHook() 
 public  void removeShutdownHook(Runnable hook) 
 public  void setAdminView(BrokerView adminView) 
 public  void setAdvisorySupport(boolean advisorySupport) 
    Allows the support of advisory messages to be disabled for performance reasons.
 public  void setBrokerName(String brokerName) 
    Sets the name of this broker; which must be unique in the network
 public  void setBrokerObjectName(ObjectName brokerObjectName) 
    Sets the JMX ObjectName for this broker
 public  void setCacheTempDestinations(boolean cacheTempDestinations) 
 public  void setConsumerSystemUsage(SystemUsage consumerSystemUsaage) 
 public  void setConsumerSystemUsagePortion(int consumerSystemUsagePortion) 
 public  void setDataDirectory(String dataDirectory) 
    Sets the directory in which the data files will be stored by default for the JDBC and Journal persistence adaptors.
 public  void setDataDirectoryFile(File dataDirectoryFile) 
    Sets the directory in which the data files will be stored by default for the JDBC and Journal persistence adaptors.
 public  void setDedicatedTaskRunner(boolean dedicatedTaskRunner) 
 public  void setDeleteAllMessagesOnStartup(boolean deletePersistentMessagesOnStartup) 
    Sets whether or not all messages are deleted on startup - mostly only useful for testing.
 public  void setDestinationFactory(DestinationFactory destinationFactory) 
 public  void setDestinationInterceptors(DestinationInterceptor[] destinationInterceptors) 
    Sets the destination interceptors to use
 public  void setDestinationPolicy(PolicyMap policyMap) 
    Sets the destination specific policies available either for exact destinations or for wildcard areas of destinations.
 public  void setDestinations(ActiveMQDestination[] destinations) 
    Sets the destinations which should be loaded/created on startup
 public  void setEnableStatistics(boolean enableStatistics) 
    Sets whether or not the Broker's services enable statistics or not.
 public  void setIoExceptionHandler(IOExceptionHandler ioExceptionHandler) 
 public  void setJmsBridgeConnectors(JmsConnector[] jmsConnectors) 
 public  void setKeepDurableSubsActive(boolean keepDurableSubsActive) 
 public  void setManagementContext(ManagementContext managementContext) 
 public  void setMasterConnectorURI(String masterConnectorURI) 
 public  void setMessageAuthorizationPolicy(MessageAuthorizationPolicy messageAuthorizationPolicy) 
    Sets the policy used to decide if the current connection is authorized to consume a given message
 public  void setMonitorConnectionSplits(boolean monitorConnectionSplits) 
 public  void setNetworkConnectorURIs(String[] networkConnectorURIs) 
 public  void setNetworkConnectors(List networkConnectors) throws Exception 
    Sets the network connectors which this broker will use to connect to other brokers in a federated network
 public  void setPassiveSlave(boolean passiveSlave) 
    Set the passiveSlave
 public  void setPersistenceAdapter(PersistenceAdapter persistenceAdapter) throws IOException 
    Sets the persistence adaptor implementation to use for this broker
 public  void setPersistenceFactory(PersistenceAdapterFactory persistenceFactory) 
 public  void setPersistenceTaskRunnerFactory(TaskRunnerFactory persistenceTaskRunnerFactory) 
 public  void setPersistenceThreadPriority(int persistenceThreadPriority) 
 public  void setPersistent(boolean persistent) 
    Sets whether or not persistence is enabled or disabled.
 public  void setPlugins(BrokerPlugin[] plugins) 
    Sets a number of broker plugins to install such as for security authentication or authorization
 public  void setPopulateJMSXUserID(boolean populateJMSXUserID) 
    Sets whether or not the broker should populate the JMSXUserID header.
 public  void setProducerSystemUsage(SystemUsage producerUsageManager) 
 public  void setProducerSystemUsagePortion(int producerSystemUsagePortion) 
 public  void setProxyConnectors(List proxyConnectors) throws Exception 
    Sets the network connectors which this broker will use to connect to other brokers in a federated network
 public  void setRegionBroker(Broker regionBroker) 
 public  void setServices(Service[] services) 
 public  void setShutdownOnMasterFailure(boolean shutdownOnMasterFailure) 
 public  void setShutdownOnSlaveFailure(boolean shutdownOnSlaveFailure) 
 public  void setSplitSystemUsageForProducersConsumers(boolean splitSystemUsageForProducersConsumers) 
 public  void setSslContext(SslContext sslContext) 
 public  void setSupportFailOver(boolean supportFailOver) 
 public  void setSystemExitOnShutdown(boolean systemExitOnShutdown) 
 public  void setSystemExitOnShutdownExitCode(int systemExitOnShutdownExitCode) 
 public  void setSystemUsage(SystemUsage memoryManager) 
 public  void setTaskRunnerFactory(TaskRunnerFactory taskRunnerFactory) 
 public  void setTaskRunnerPriority(int taskRunnerPriority) 
 public  void setTempDataStore(Store tempDataStore) 
 public  void setTimeBeforePurgeTempDestinations(int timeBeforePurgeTempDestinations) 
 public  void setTmpDataDirectory(File tmpDataDirectory) 
 public  void setTransportConnectorURIs(String[] transportConnectorURIs) 
 public  void setTransportConnectors(List<TransportConnector> transportConnectors) throws Exception 
    Sets the transport connectors which this broker will listen on for new clients
 public  void setUseJmx(boolean useJmx) 
    Sets whether or not the Broker's services should be exposed into JMX or not.
 public  void setUseLocalHostBrokerName(boolean useLocalHostBrokerName) 
 public  void setUseLoggingForShutdownErrors(boolean useLoggingForShutdownErrors) 
    Sets whether or not we should use commons-logging when reporting errors when shutting down the broker
 public  void setUseMirroredQueues(boolean useMirroredQueues) 
    Sets whether or not Mirrored Queues should be supported by default if they have not been explicitly configured.
 public  void setUseShutdownHook(boolean useShutdownHook) 
    Sets whether or not we should use a shutdown handler to close down the broker cleanly if the JVM is terminated. It is recommended you leave this enabled.
 public  void setUseTempMirroredQueues(boolean useTempMirroredQueues) 
 public  void setUseVirtualTopics(boolean useVirtualTopics) 
    Sets whether or not Virtual Topics should be supported by default if they have not been explicitly configured.
 public  void setVmConnectorURI(URI vmConnectorURI) 
 public  void setWaitForSlave(boolean waitForSlave) 
 public  void setWaitForSlaveTimeout(long waitForSlaveTimeout) 
 protected  void slaveConnectionEstablished() 
 public  void start() throws Exception 
 public  void start(boolean force) throws Exception 
 protected  void startAllConnectors() throws Exception 
    Start all transport and network connections, proxies and bridges
 protected  void startDestinations() throws Exception 
    Starts any configured destinations on startup
 protected  void startDestinationsInPersistenceStore(Broker broker) throws Exception 
    Starts all destiantions in persistence store. This includes all inactive destinations
 protected  void startManagementContext() throws Exception 
 protected TransportConnector startTransportConnector(TransportConnector connector) throws Exception 
 public  void stop() throws Exception 
 protected  void stopAllConnectors(ServiceStopper stopper) 
 public  void stopGracefully(String connectorName,
    String queueName,
    long timeout,
    long pollInterval) throws Exception 
    This method (both connectorName and queueName are using regex to match) 1. stop the connector (supposed the user input the connector which the clients connect to) 2. to check whether there is any pending message on the queues defined by queueName 3. supposedly, after stop the connector, client should failover to other broker and pending messages should be forwarded. if no pending messages, the method finally call stop to stop the broker.
 public String toString() 
 protected  void unregisterConnectorMBean(TransportConnector connector) throws IOException 
 protected  void unregisterNetworkConnectorMBean(NetworkConnector connector) 
 protected  void unregisterPersistenceAdapterMBean(PersistenceAdapter adaptor) throws IOException 
 protected  void waitForSlave() 
 public  void waitUntilStarted() 
    A helper method to block the caller thread until the broker has been started
 public  void waitUntilStopped() 
    A helper method to block the caller thread until the broker has been stopped