// Start the broker
try
{
// Get the configuration manager
ConfigurationManager configManager = loadMessagingConfiguration(servletConfig);
// Load configuration
MessagingConfiguration config = configManager.getMessagingConfiguration(servletConfig);
// Set up logging system ahead of everything else.
config.createLogAndTargets();
// Create broker.
broker = config.createBroker(servletConfig.getInitParameter("messageBrokerId"), loader);
// Set the servlet config as thread local
FlexContext.setThreadLocalObjects(null, null, broker, null, null, servletConfig);
setupInternalPathResolver();
// Set initial servlet context on broker
broker.setInitServletContext(servletConfig.getServletContext());
Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
if (Log.isInfo())
{
logger.info(VersionInfo.buildMessage());
}
// Create endpoints, services, security, and logger on the broker based on configuration
config.configureBroker(broker);
long timeBeforeStartup = 0;
if (Log.isDebug())
{
timeBeforeStartup = System.currentTimeMillis();
Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is starting.",
new Object[]{broker.getId()});
}
//initialize the httpSessionToFlexSessionMap
synchronized(HttpFlexSession.mapLock)
{
if (servletConfig.getServletContext().getAttribute(HttpFlexSession.SESSION_MAP) == null)
servletConfig.getServletContext().setAttribute(HttpFlexSession.SESSION_MAP, new ConcurrentHashMap());
}
broker.start();
if (Log.isDebug())
{
long timeAfterStartup = System.currentTimeMillis();
Long diffMillis = new Long(timeAfterStartup - timeBeforeStartup);
Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is ready (startup time: '{1}' ms)",
new Object[]{broker.getId(), diffMillis});
}
// Report replaced tokens
configManager.reportTokens();
// Report any unused properties.
config.reportUnusedProperties();
// clear the broker and servlet config as this thread is done