private static void Main(string[] args) { var appSettings = ConfigurationManager.AppSettings; var totalInboundMessages = int.Parse(appSettings["TotalInboundMessages"]); var inboundExchangeName = appSettings["InboundExchangeName"]; var imageFileFolder = appSettings["ImageFileFolder"]; Console.WriteLine("Total inbound messages is {0}.", totalInboundMessages); Console.WriteLine("Inbound Exchange Name is {0}.", inboundExchangeName); Console.WriteLine("Image folder path is {0}.", imageFileFolder); using (var rabbitBus = InitMessageBus()) { IList <Task> tasks = new List <Task>(); var carResponseExchangePublisher = new ExchangePublisher <RecogniseBatchCourtesyAmountRequest>(rabbitBus.Advanced); carResponseExchangePublisher.Declare(inboundExchangeName); int i = 0; // Get batch names (image folders) var folderList = Directory.GetDirectories(imageFileFolder); ConcurrentBag <string> folderBag = new ConcurrentBag <string>(folderList); while (i++ < totalInboundMessages) { if (folderBag.IsEmpty) { folderBag = new ConcurrentBag <string>(folderList); } string path; do { folderBag.TryTake(out path); } while (path == null); var batchRequest = PopulateInboundQueue(path); var result = carResponseExchangePublisher.PublishAsync(batchRequest); tasks.Add(result); //Task.Run( async()=> await carResponseExchangePublisher.PublishAsync(batchRequest)); Console.WriteLine( "Message with jobIdentifier {0} has been pushed into inbound queue", batchRequest.jobIdentifier); } Task.WaitAll(tasks.ToArray()); } Console.ReadKey(); }
private static void Main(string[] args) { var appSettings = ConfigurationManager.AppSettings; var totalInboundMessages = int.Parse(appSettings["TotalInboundMessages"]); var inboundExchangeName = appSettings["InboundExchangeName"]; var imageFileFolder = appSettings["ImageFileFolder"]; Console.WriteLine("Total inbound messages is {0}.", totalInboundMessages); Console.WriteLine("Inbound Exchange Name is {0}.", inboundExchangeName); Console.WriteLine("Image folder path is {0}.", imageFileFolder); using (var rabbitBus = InitMessageBus()) { IList<Task> tasks = new List<Task>(); var carResponseExchangePublisher = new ExchangePublisher<RecogniseBatchCourtesyAmountRequest>(rabbitBus.Advanced); carResponseExchangePublisher.Declare(inboundExchangeName); int i = 0; // Get batch names (image folders) var folderList = Directory.GetDirectories(imageFileFolder); ConcurrentBag<string> folderBag = new ConcurrentBag<string>(folderList); while (i++ < totalInboundMessages) { if (folderBag.IsEmpty) { folderBag = new ConcurrentBag<string>(folderList); } string path; do { folderBag.TryTake(out path); } while (path == null); var batchRequest = PopulateInboundQueue(path); var result = carResponseExchangePublisher.PublishAsync(batchRequest); tasks.Add(result); //Task.Run( async()=> await carResponseExchangePublisher.PublishAsync(batchRequest)); Console.WriteLine( "Message with jobIdentifier {0} has been pushed into inbound queue", batchRequest.jobIdentifier); } Task.WaitAll(tasks.ToArray()); } Console.ReadKey(); }
public static void Publish(ValidateBatchCodelineRequest request, string jobIdentifier, string routingKey) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(GenerateCorrespondingVoucherRequest request, string jobIdentifier, string routingKey) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(CheckThirdPartyBatchRequest request, string jobIdentifier, string routingKey) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(RecogniseBatchCourtesyAmountRequest request) { Requests.Add(request); Task.WaitAll(InboundExchange.PublishAsync(request, null)); }
public static void Publish(GetVouchersInformationResponse response, string jobIdentifier, string routingKey) { Responses.Add(response); Task.WaitAll(ResponseExchange.PublishAsync(response, jobIdentifier, routingKey)); }
public static void Publish(CorrectBatchCodelineRequest request, string jobIdentifier, string routingKey) { Requests.Enqueue(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(GenerateBatchBulkCreditRequest request, string jobIdentifier, string routingKey) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(CorrectBatchTransactionRequest request, string jobIdentifier, string routingKey) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, routingKey)); }
public static void Publish(SendBatchValueInstructionFileRequest request) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, null)); }
public static void Publish(CreateBatchAdjustmentLettersRequest request, string jobIdentifier) { Requests.Add(request); Task.WaitAll(RequestExchange.PublishAsync(request, jobIdentifier, "NGAL")); }