private void Initialize()
        {
            EntityManager em = new EntityManager();
            List<Hub> hubs = em.GetHubsByGateway(ObjectID);
            foreach (var hub in hubs)
            {
                List<HubService> spokes = em.GetSpokesByHub(hub.HubId);
                //ServiceHost host =
                //     CreateServiceHost<TetsuoHubService>("Tetsuo.Core.Contracts.IRouteDispatcher", hub.HubName + ".request");
                //(host.SingletonInstance as TetsuoHubService).SetObjectID(Common.InstrumentationSources.Hub, hub.HubId);
                Instrument(Common.TransmissionStatusCodes.SVC_START, "Starting hub " + hub.HubName, Common.InstrumentationSources.Hub, hub.HubId);

                spokes.ForEach(spoke =>
                {
                    string qName = string.Format(@"{0}\private$\{1}.{2}.request",Environment.MachineName,
                        hub.HubName,spoke.HubServiceName);
                    if(!(MessageQueue.Exists(qName)))
                        MessageQueue.Create(qName,true);
                    ServiceHost spokeHost =
                     CreateServiceHost<TetsuoHubService>("Tetsuo.Core.Contracts.IRouteDispatcher", hub.HubName + "." + spoke.HubServiceName + ".request");
                    //spokeHost.AddServiceEndpoint(spoke.SpokeContract, new MsmqIntegrationBinding(), @"msmq.formatname:DIRECT=OS:.\private$\" + hub.HubName + "." + spoke.SpokeName + ".request");
                    (spokeHost.SingletonInstance as TetsuoHubService).SetObjectID(Common.InstrumentationSources.Spoke, spoke.HubServiceId);
                    Assembly asm = Assembly.LoadFrom(spoke.HubServiceAssembly);
                    if (!(spokeHost.SingletonInstance as TetsuoHubService).Assemblies.Contains(asm))
                        (spokeHost.SingletonInstance as TetsuoHubService).Assemblies.Add(asm);
                    (spokeHost.SingletonInstance as TetsuoHubService).HostedContract = asm.CreateInstance(spoke.ClientClass);
                    serviceThreads.Add(spokeHost);
                    Instrument(Common.TransmissionStatusCodes.SVC_START, "Service for " + spoke.HubServiceName + " successfully started.", Common.InstrumentationSources.Spoke, spoke.HubServiceId);

                });
                //host.Open();
                //serviceThreads.Add(host);
            }
        }
 private void InitializeHubs(Uri address)
 {
     EntityManager em = new EntityManager();
     List<Hub> hubs = em.GetHubsByGateway(address);
     foreach(var hub in hubs)
     {
         IServiceHub currentHub = new ServiceHub();
         currentHub.Name = hub.HubName;
         currentHub.OriginAddress = address.OriginalString;
         currentHub.DestinationAddress = address.OriginalString + hub.HubEndpoint;
         ServiceHubs.Add(currentHub);
         Console.WriteLine("Gateway: successfully created endpoint {0}.",
             currentHub.DestinationAddress);
         currentHub.InitializeSpokes(hub.HubId,
             currentHub.OriginAddress, currentHub.DestinationAddress);
     }
 }