Ejemplo n.º 1
0
        /// <inheritdoc />
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (Factory != null)
            {
                var requestOption = (request.Properties.TryGetValue(RabbitRequestOption.RequestProperty, out var requestObjectOption) ?
                                     requestObjectOption as RabbitRequestOption : null) ??
                                    new RabbitRequestOption();

                requestOption.ConnectionFactory = Factory;
            }


            var response = await _client.Send(request, cancellationToken);

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Get(int id)
        {
            foreach (var i in Enumerable.Range(1, 1000))
            {
                var person = new Person
                {
                    Name   = "Ivan",
                    Amount = id,
                    Parent = new Person
                    {
                        Name   = "Ilya",
                        Amount = i * 10
                    }
                };



                var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/values/postPerson")
                {
                    Content = new StringContent(JsonConvert.SerializeObject(person), Encoding.UTF8, "application/json")
                };

                var response = await _rabbitQueue.Send(request, CancellationToken.None);

                //var response = await _queueClient.Send(request, CancellationToken.None);
            }
            //var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/values/postPerson")
            //{
            //	Content = new StringContent(JsonConvert.SerializeObject(person), Encoding.UTF8, "application/json")
            //};
            //		request.Headers.AddCorrelation(Guid.NewGuid().ToString("N"));
            //request.AddRetry(new RepeatConfig
            //{
            //	Count = 3,
            //	Strategy = RepeatStrategy.Progression
            //});

            //request.AddRabbitRequestOption(new RabbitRequestOption
            //{
            //	Delay = TimeSpan.FromMinutes(1)
            //});
            //var response = await _queueClient.Send(request, CancellationToken.None);


            //	var pers = await response.Content.ReadAsAsync<Person>();
            return(Ok());
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            await _client.Send(request, cancellationToken);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }