Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Initialize properties
- ContextProperties contextProps = new ContextProperties()
- {
- TimerResolutionInMsecs = 5000
- };
- SessionProperties sessionProps = new SessionProperties()
- {
- Host = ConfigurationManager.AppSettings["Host"],
- VPNName = ConfigurationManager.AppSettings["VPNName"],
- UserName = ConfigurationManager.AppSettings["UserName"],
- Password = ConfigurationManager.AppSettings["Password"],
- ReconnectRetries = 2
- };
- #endregion
- ContextFactoryProperties cfp = new ContextFactoryProperties()
- {
- // Set log level.
- SolClientLogLevel = SolLogLevel.Debug
- };
- //SolLogInfo logInfo = new SolLogInfo()
- //logInfo.LoggerName = logger.Logger.Name;
- //cfp.LogDelegate(logger.Info);
- logger.Info("Going to create ContextFactory instance");
- // Must init the API before using any of its artifacts.
- ContextFactory.Instance.Init(cfp);
- logger.Info("SolaceTestQueuePublish initializing...");
- #region Create the Context
- context = ContextFactory.Instance.CreateContext(contextProps, null);
- {
- #region Create and connect the Session
- session = context.CreateSession(sessionProps, SolTest_OnMessage, SolTest_OnSessionEvent);
- {
- logger.Info("Solace Session Created.");
- try
- {
- logger.Info("Trying to connect to Solace now..");
- ReturnCode returnCode = session.Connect();
- if (ReturnCode.SOLCLIENT_OK == returnCode)
- {
- isSolaceConnected = true;
- logger.Info("Connected to Solace.Success!");
- }
- else
- logger.Info("Failed to connect Solace! Error Code:" + returnCode.ToString());
- }
- catch (Exception ex)
- {
- logger.Info("Failed to connect Solace!Error:" + ex.Message + "; Stack:" + ex.StackTrace);
- //throw;
- }
- }
- //session.Dispose();
- #endregion
- }
- //context.Dispose();
- #endregion
Add Comment
Please, Sign In to add comment