/// <summary> /// Configure specific routes for each component. This method must be updated for each routing configuration change. /// The publish nodes are for testing the simulation and documenting the expected interconnections. /// The subscribe nodes configure expected topics for this node. /// /// Each subscriptions is a separate binding to the component's internal queue. /// </summary> /// <remarks> /// [To] [From] /// /// Controller Publish: [Memory] .[Controller] /// Memory Publish: [Controller] .[Memory] /// /// Controller Subscribe: [Controller] .[*] /// Memory Subscribe: [Memory] .[*] /// </remarks> /// <param name="service">host service to facilitate access to all properties</param> /// <returns></returns> public static NodeInterface BuildNode(NodeServiceBase service) { NodeInterface node = new NodeInterface(service); switch (service.thisComponent) { case SystemNode.Controller: node.Publish.Add(node.RouteKey(service.thisComponent, SystemNode.Environment)); node.Publish.Add(node.RouteKey(service.thisComponent,SystemNode.Memory)); node.Subscribe.Add(node.RouteKey(SystemNode.Environment, service.thisComponent)); node.Subscribe.Add(node.RouteKey(SystemNode.Memory, service.thisComponent)); break; case SystemNode.Environment: node.Publish.Add(node.RouteKey(service.thisComponent,SystemNode.Controller)); node.Subscribe.Add(node.RouteKey(SystemNode.Controller,service.thisComponent)); break; case SystemNode.Memory: node.Publish.Add(node.RouteKey(service.thisComponent,SystemNode.Controller)); node.Subscribe.Add(node.RouteKey(SystemNode.Controller,service.thisComponent)); break; default: break; } node.QueueConfiguration(service); // define the queue subscription topics return (node); }
/// <summary> /// Connects/Links outgoing block to invoking router/controller instance. /// <list type="number"> /// <item>Initialize the interface node</item> /// <item>Connect outgoing node connection to the controller router</item> /// <item>Set miscellanous meta configurations</item> /// <item>Start asynchronous interface tasks</item> /// </list> /// </summary> /// <remarks> /// Note. The incoming controller connection is established here. The outgoing router was connected /// by the controller at the time the NodeService was defined. /// </remarks> /// <param name="cct">Controller initiated cancellation token</param> /// <param name="_waitHandle">Process completion signal</param> public Boolean Configure( CancellationToken cct, EventWaitHandle _waitHandle) { this.m_waitHandle = _waitHandle; this.m_cancellationController = cct; // controller cancellation token this.m_nodetoken = m_nodetokenSource.Token; // instantiate the token #region Build Node try { this.m_node = MQNetwork.BuildNode(this); // initialize the node interface traffic } catch (Exception ex) { Console.WriteLine(String.Format("1102 Service({0}) Ex:({1})", this.thisComponent,ex.Message)); return(false); } Console.WriteLine(String.Format("1100 Service({0}) Started", this.thisComponent)); return (true); #endregion }