示例#1
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            Uri      baseAddress = new Uri("net.tcp://localhost/Workmate/Messaging");
            Exchange exchange    = new Exchange();
            ExchangeMessageMonitor exchangeMessageMonitor = new ExchangeMessageMonitor(TimeSpan.FromSeconds(15), exchange);

            exchangeMessageMonitor.StartSnapshotLogging();

            using (ServiceHost host = new ServiceHost(exchange, baseAddress))
            {
                host.Open();

                Console.ReadLine();

                host.Close();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            Exchange exchange = new Exchange();
            ExchangeMessageMonitor exchangeMessageMonitor = new ExchangeMessageMonitor(TimeSpan.FromSeconds(15), exchange);

            exchangeMessageMonitor.StartSnapshotLogging();

            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ServiceModelSectionGroup           serviceModelSectionGroup = config.GetSectionGroup("system.serviceModel") as ServiceModelSectionGroup;

            if (serviceModelSectionGroup == null)
            {
                _Log.Error("Unable to load service model section group");
                return;
            }
            ServiceElement serviceElement = (from c in serviceModelSectionGroup.Services.Services.Cast <ServiceElement>()
                                             where c.Name == "Workmate.Messaging.Exchange"
                                             select c).FirstOrDefault();

            if (serviceElement == null)
            {
                _Log.Error("Unable to load service with name Workmate.Messaging.Exchange");
                return;
            }
            if (serviceElement.Endpoints.Count == 0)
            {
                _Log.Error("No endpoints defined for service Workmate.Messaging.Exchange");
                return;
            }

            using (Server server = new Server(exchange, serviceElement.Endpoints[0].Address))
            {
                _Log.InfoFormat("Starting server at " + serviceElement.Endpoints[0].Address);
                server.Start();

                System.Console.ReadLine();
            }
        }