/// <inheritdoc /> /// <summary> /// Delete a message queue /// </summary> /// <param name="queue">Message Queue connection instance</param> /// <returns>true if the message queue was deleted; otherwise, false.</returns> public bool Delete(MQConnection queue) { var client = new NsqdHttpClient(queue.Route.Replace(":4150", ":4151"), TimeSpan.FromSeconds(60)); client.DeleteChannel(queue.Name, queue.Name); client.DeleteTopic(queue.Name); return(true); }
static ConsumerRdyRedistributionTest() { //nsqd.exe -lookupd-tcp-address=127.0.0.1:4160 -mem-queue-size=0 _nsqdHttpClient1 = new NsqdHttpClient("127.0.0.1:4151", TimeSpan.FromSeconds(5)); //nsqd.exe -lookupd-tcp-address=127.0.0.1:4160 -http-address 127.0.0.1:5151 -mem-queue-size=0 -tcp-address 127.0.0.1:5150 _nsqdHttpClient2 = new NsqdHttpClient("127.0.0.1:5151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
/// <summary>Initializes a new instance of the <see cref="NsqdHttpPublisher"/> class.</summary> /// <exception cref="ArgumentNullException">Thrown when <paramref name="nsqdHttpEndpoint"/> is null or empty. /// </exception> /// <param name="nsqdHttpEndpoint">The nsqd HTTP endpoint.</param> /// <param name="httpRequestTimeout">The HTTP request timeout.</param> public NsqdHttpPublisher(string nsqdHttpEndpoint, TimeSpan httpRequestTimeout) { if (string.IsNullOrEmpty(nsqdHttpEndpoint)) { throw new ArgumentNullException("nsqdHttpEndpoint"); } _nsqdHttpClient = new NsqdHttpClient(nsqdHttpEndpoint, httpRequestTimeout); }
/// <inheritdoc /> /// <summary> /// Purge all messages from a message queue /// </summary> /// <param name="queue">Message Queue connection instance</param> public void Purge(MQConnection queue) { if (!Exist(queue)) { return; } var client = new NsqdHttpClient(queue.Route.Replace(":4150", ":4151"), TimeSpan.FromSeconds(60)); client.EmptyChannel(queue.Name, queue.Name); client.EmptyTopic(queue.Name); }
/// <inheritdoc /> /// <summary> /// Create a new message queue /// </summary> /// <param name="queue">Message Queue connection instance</param> /// <returns>true if the message queue was created; otherwise, false.</returns> public bool Create(MQConnection queue) { if (Exist(queue)) { return(false); } var client = new NsqdHttpClient(queue.Route.Replace(":4150", ":4151"), TimeSpan.FromSeconds(60)); client.CreateTopic(queue.Name); client.CreateChannel(queue.Name, queue.Name); return(true); }
public SynchronizedPosition() { if (producer == null) { //Println //producer = new Producer("127.0.0.1:4150"); //producer = new Producer("http://127.0.0.1:4151/"); TimeSpan httpRequestTimeout = new TimeSpan(200000000); producer = new NsqdHttpClient("120.25.195.214:4151", httpRequestTimeout); //producer = new Producer("120.25.195.214:4150"); //producer.Publish("position","测试语句"); } }
private void GetNsqdInformation(ProducerInformation nsqdNode) { var httpUri = string.Format("http://{0}:{1}", nsqdNode.BroadcastAddress, nsqdNode.HttpPort); var client = new NsqdHttpClient(httpUri, TimeSpan.FromSeconds(10)); var stats = client.GetStats(); var topics = new List <TopicModel>(Topics); foreach (var topic in topics) { var nsqdTopic = stats.Topics.SingleOrDefault(p => p.TopicName == topic.Topic); //int? messageCount = nsqdTopic == null ? (int?)null : nsqdTopic.MessageCount; topic.SetNsqdStats(nsqdNode, nsqdTopic); } }
static ConsumerRdyRedistributionTest() { _nsqdHttpClient1 = new NsqdHttpClient("127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqdHttpClient2 = new NsqdHttpClient("127.0.0.1:5151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
static ProducerTest() { _nsqdHttpClient = new NsqdHttpClient("127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
static MultiImplementIHandleMessagesTest() { _nsqdHttpClient = new NsqdHttpClient("127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
static AutofacBusTest() { _nsqdHttpClient = new NsqdHttpClient("http://127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("http://127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
static MessageMutatorTest() { _nsqdHttpClient = new NsqdHttpClient("127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
static BusCurrentMessageTest() { _nsqdHttpClient = new NsqdHttpClient("http://127.0.0.1:4151", TimeSpan.FromSeconds(5)); _nsqLookupdHttpClient = new NsqLookupdHttpClient("http://127.0.0.1:4161", TimeSpan.FromSeconds(5)); }
public void StartBus() { // TODO: Needs to move to NsqBus. See below comment about async bus start. // TODO: This also makes an assumption nsqd is running locally on port 4151. Convenient for testing and sample // TODO: apps, probably shouldn't be used in PROD. This needs to be thought through. if (_preCreateTopicsAndChannels) { const string nsqdHttpAddress = "127.0.0.1:4151"; var nsqdHttpClient = new NsqdHttpClient(nsqdHttpAddress, TimeSpan.FromSeconds(5)); var wg = new WaitGroup(); foreach (var tch in GetHandledTopics()) { foreach (var channel in tch.Channels) { string localTopic = tch.Topic; string localChannel = channel; wg.Add(1); GoFunc.Run(() => { try { nsqdHttpClient.CreateTopic(localTopic); nsqdHttpClient.CreateChannel(localTopic, localChannel); } catch (Exception ex) { _nsqLogger.Output(LogLevel.Error, string.Format("error creating topic/channel on {0} - {1}", nsqdHttpAddress, ex)); } wg.Done(); }, "BusConfiguration pre-create topics/channels"); } } wg.Wait(); } if (_busStateChangedHandler != null) { _busStateChangedHandler.OnBusStarting(this); } _bus = new NsqBus( _topicChannelHandlers, _dependencyInjectionContainer, _messageTypeToTopicProvider, _defaultMessageSerializer, _nsqLogger, _messageMutator, _messageTopicRouter, _nsqdPublisher ); _bus.Start(); // TODO: BusConfiguration should not be responsible for these callbacks. With an async _bus.Start // TODO: this will need to be moved to NsqBus. if (_busStateChangedHandler != null) { _busStateChangedHandler.OnBusStarted(this, _bus); } }