/// <summary> /// new /// </summary> /// <param name="queueName"></param> /// <param name="config"></param> /// <param name="callback"></param> public Consumer(string queueName, Config.RabbitMQ config, Action <Messaging.Message> callback) { if (string.IsNullOrEmpty(queueName)) { throw new ArgumentNullException("queueName"); } if (callback == null) { throw new ArgumentNullException("callback"); } this.QueueName = queueName; this._callback = callback; this.Exchange = config.Exchange; this._factory = new ConnectionFactory { HostName = config.Host, Port = config.Port, UserName = config.UserName, Password = config.Password, VirtualHost = config.VHost, RequestedHeartbeat = 10, }; this._server = GenServer.Start(this); this._server.Call(new ListenMessage()); }
/// <summary> /// new /// </summary> /// <param name="publisher"></param> /// <param name="exchange"></param> public Worker(Publisher publisher, string exchange) { if (publisher == null) { throw new ArgumentNullException("publisher"); } if (string.IsNullOrEmpty(exchange)) { throw new ArgumentNullException("exchange"); } this._publisher = publisher; this._exchange = exchange; this._server = GenServer.Start(this); }
/// <summary> /// new /// </summary> /// <param name="config"></param> public Publisher(Config.RabbitMQ config) { if (config == null) { throw new ArgumentNullException("config"); } this._factory = new ConnectionFactory { HostName = config.Host, Port = config.Port, UserName = config.UserName, Password = config.Password, VirtualHost = config.VHost }; this._arrWorkers = Enumerable.Range(0, 4).Select(_ => new Worker(this, config.Exchange)).ToArray(); this._server = GenServer.Start(this); }
public Object Start() { return(GenServer.StartLink(() => new CodeAppGenServer())); }
public Object Start() { return(Supervisor.StartLink("primary-sup", () => new SupervisorConfig(SupervisionStrategy.OneForAll, new SupervisorChild [] { new SupervisorWorker("c1", () => GenServer.StartLink("genserver-one", () => new WorkerGenServer1())) , new SupervisorWorker("c2", () => GenServer.StartLink("genserver-two", () => new WorkerGenServer1())) , new SupervisorWorker("c3", () => GenServer.StartLink("genserver-three", () => new WorkerGenServer1())) , new Supervisor("s1", () => Supervisor.StartLink("secondary-sup", () => new SupervisorConfig(SupervisionStrategy.OneForOne, new [] { new SupervisorWorker("sc1", () => GenServer.StartLink("nested-one", () => new WorkerGenServer1())) , new SupervisorWorker("sc2", () => GenServer.StartLink("nested-two", () => new WorkerGenServer1())) , new SupervisorWorker("sc3", () => GenServer.StartLink("nested-three", () => new WorkerGenServer1())) }))) }))); }
ProcessResult WorkerLoopReceive(Process ctx, Object msg) { GenServer.Stop(workerOne); GenServer.Stop(workerTwo); return(ctx.Finish(new Atom("ok"))); }
ProcessResult WorkerInit(Process ctx) { workerOne = GenServer.StartLink(new Atom("named-one"), () => new MyNamedGenServer("one")); workerTwo = GenServer.StartLink(new Atom("named-two"), () => new MyNamedGenServer("two")); return(ctx.Receive((Process ctx, Object msg) => WorkerLoopReceive(ctx, msg))); }
public Worker() { this._server = GenServer.Start(this); }