public void Run( ReqRepArgs args ) { /** * Basic concepts: * - the master plays the role of the requesting subject * - the slave plays the role of the replying subject * - each "client" refers to an independent connection against the broker * * How this demo works: * - the user defines M master clients and S slave clients, thus a total of M+S connections * - each slave client is logically targeted by one or more masters, thus M should be a multiple of S * - each slave targets a different subject meant as a "base path" * - the user defines also how many subjects each slave should subscribe (as T) * - each subscription being indexed matches a subject path composed as follows: * (base-path).sub(index).> * - at the end, there are S*T unique subscriptions reachable through the broker * - to match them all, each master client will run S*T/M so-called "endpoints" as threads * - each endpoint will match its paired subscription target * - each endpoint will run "loopcount" different requests sequentially validating the response **/ for (int ixs = 0; ixs < args.SlaveClientCount; ixs++) { var sl = new SlaveClientContext(args.BaseSubjectPath + ixs, args.SlaveSubsPerClient); this._slaveClients.Add(sl); for (int ixm = 0; ixm < args.MasterClientPerSlave; ixm++) { var ms = new MasterClientContext(); this._masterClients.Add(ms); for (int ixt = 0; ixt < args.SlaveSubsPerClient; ixt++) { string targetPath = sl.GetSubjectPath(ixt, ixm); var bridge = new ReqRepBridge( ms, sl, targetPath, args.SampleText ); this._bridges.Add(bridge); sl.EndPoints.Add(targetPath, bridge); ms.EndPoints.Add(bridge); } ms.LoopCount = args.LoopCount; ms.BlockingEvent = new CountdownEvent(ms.EndPoints.Count); } } var tlist = new List <Thread>(); //slave clients for (int i = 0; i < this._slaveClients.Count; i++) { var t = new Thread(this.SlaveClientWorker); t.Start(this._slaveClients[i]); tlist.Add(t); } //master clients for (int i = 0; i < this._masterClients.Count; i++) { var t = new Thread(this.MasterClientWorker); t.Start(this._masterClients[i]); tlist.Add(t); } foreach (var t in tlist) { t.Join(); } }