private async Task GetStartedBroker()
        {
            IBrokerClient rabbitMQBrokerClient = new RabbitMQBrokerClient("40.121.32.117", "developerAdmin", "developerAdmin");

            ConfigurationPublisherClient publisher = new ConfigurationPublisherClient
            {
                Applicacion  = "ExternalConsulting",
                Module       = "Diagnostic",
                Action       = "Update",
                DocumentName = "indexation"
            };

            // string json =await System.IO.File.ReadAllTextAsync(@"C:\Users\developerAdmin\Downloads\sincronizacion.txt");
            string json = await System.IO.File.ReadAllTextAsync(@"C:\Users\developerAdmin\Downloads\899999017-5415848-0004-005_data.json");


            for (int i = 0; i < 1000; i++)
            {
                try
                {
                    bool send = rabbitMQBrokerClient.SendMessage <object, object>(JsonConvert.DeserializeObject(json), null, publisher);
                    Console.WriteLine(i.ToString());
                }
                catch { }
            }

            Console.WriteLine(DateTime.Now);
            Console.Read();
        }
Exemple #2
0
        public bool SendMessage <T, V>(T message, V configurationMessage, ConfigurationPublisherClient configurationPublisher)
        {
            var publisher = _configurationPublishers.SingleOrDefault(c => c.Applicacion == configurationPublisher.Applicacion &&
                                                                     c.Module == configurationPublisher.Module && c.Action == configurationPublisher.Action);

            var properties = _channel.CreateBasicProperties();

            properties.Headers = (configurationPublisher.PropertiesCustom ?? new Dictionary <string, object>());
            properties.Headers.Add("application", configurationPublisher.Applicacion);
            properties.Headers.Add("module", configurationPublisher.Module);
            properties.Headers.Add("documentName", configurationPublisher.DocumentName);
            properties.Headers.Add("callbackResponse", true);


            if (configurationMessage != null)
            {
                properties.Headers.Add("configuration", configurationMessage);
            }


            _channel.BasicPublish(exchange: publisher.ExchageName,
                                  routingKey: publisher.KeyRouting,
                                  basicProperties: properties,
                                  body: message.Serialize());

            return(true);
        }
Exemple #3
0
        public async Task <IActionResult> Post([FromBody] Patient patient)
        {
            this.context.Patients.Add(patient);
            await this.context.SaveChangesAsync();

            ConfigurationPublisherClient publisher = new ConfigurationPublisherClient
            {
                Applicacion  = "ExternalConsulting",
                Module       = "Basic_information",
                Action       = "Add",
                DocumentName = "Patient"
            };

            this.rabbitMQBrokerClient.SendMessage <Patient, object>(patient, null, publisher);

            return(CreatedAtRoute(new { id = patient.Id }, patient));
        }