Guest User

Untitled

a guest
May 9th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #region Initialize properties
  2. ContextProperties contextProps = new ContextProperties()
  3. {
  4. TimerResolutionInMsecs = 5000
  5. };
  6. SessionProperties sessionProps = new SessionProperties()
  7. {
  8.  
  9. Host = ConfigurationManager.AppSettings["Host"],
  10. VPNName = ConfigurationManager.AppSettings["VPNName"],
  11. UserName = ConfigurationManager.AppSettings["UserName"],
  12. Password = ConfigurationManager.AppSettings["Password"],
  13. ReconnectRetries = 2
  14. };
  15. #endregion
  16.  
  17. ContextFactoryProperties cfp = new ContextFactoryProperties()
  18. {
  19. // Set log level.
  20. SolClientLogLevel = SolLogLevel.Debug
  21. };
  22.  
  23. //SolLogInfo logInfo = new SolLogInfo()
  24. //logInfo.LoggerName = logger.Logger.Name;
  25. //cfp.LogDelegate(logger.Info);
  26. logger.Info("Going to create ContextFactory instance");
  27. // Must init the API before using any of its artifacts.
  28. ContextFactory.Instance.Init(cfp);
  29.  
  30. logger.Info("SolaceTestQueuePublish initializing...");
  31.  
  32. #region Create the Context
  33.  
  34. context = ContextFactory.Instance.CreateContext(contextProps, null);
  35. {
  36. #region Create and connect the Session
  37.  
  38. session = context.CreateSession(sessionProps, SolTest_OnMessage, SolTest_OnSessionEvent);
  39. {
  40. logger.Info("Solace Session Created.");
  41.  
  42. try
  43. {
  44. logger.Info("Trying to connect to Solace now..");
  45. ReturnCode returnCode = session.Connect();
  46. if (ReturnCode.SOLCLIENT_OK == returnCode)
  47. {
  48. isSolaceConnected = true;
  49. logger.Info("Connected to Solace.Success!");
  50. }
  51. else
  52. logger.Info("Failed to connect Solace! Error Code:" + returnCode.ToString());
  53. }
  54. catch (Exception ex)
  55. {
  56. logger.Info("Failed to connect Solace!Error:" + ex.Message + "; Stack:" + ex.StackTrace);
  57. //throw;
  58. }
  59.  
  60.  
  61. }
  62.  
  63. //session.Dispose();
  64. #endregion
  65. }
  66. //context.Dispose();
  67. #endregion
Add Comment
Please, Sign In to add comment