private string GetSelectedQueue(OrderQueueLocation queueLocation) { switch (queueLocation) { case OrderQueueLocation.Normal: return(Configuration.RabbitMQQueueOrderCreated); case OrderQueueLocation.History: return(Configuration.RabbitMQQueueOrderHistory); case OrderQueueLocation.Error: return(Configuration.RabbitMQQueueOrderError); case OrderQueueLocation.Reprocess: return(Configuration.RabbitMQQueueOrderReprocess); default: return(Configuration.RabbitMQQueueOrderCreated); } }
private string GetSelectedExchange(OrderQueueLocation exchangeLocation) { switch (exchangeLocation) { case OrderQueueLocation.Normal: return(Configuration.RabbitMQExchangeOrdersCreated); case OrderQueueLocation.History: return(Configuration.RabbitMQExchangeOrdersHistory); case OrderQueueLocation.Error: return(Configuration.RabbitMQExchangeOrdersError); case OrderQueueLocation.Reprocess: return(Configuration.RabbitMQExchangeOrdersReprocess); default: return(Configuration.RabbitMQExchangeOrdersCreated); } }
private void WorkOrderQueue(OrderQueueLocation queue) { string rawOrder = _orderQueue.ConsumeFromQueue(Configuration.RabbitMQOrderServer, Configuration.RabbitMQUserNameConsumer, Configuration.RabbitMQUserPasswordConsumer, Configuration.RabbitMQVHostOrder, GetSelectedQueue(queue)); while (!string.IsNullOrEmpty(rawOrder)) { OrderFile order = JsonConvert.DeserializeObject <OrderFile>(rawOrder); try { _log.WriteInformationLog(string.Format("Sending order to mainframe({0})", order.Header.ControlNumber)); SendToHost(order); SendToHistory(rawOrder); _log.WriteInformationLog(string.Format("Order sent to mainframe({0})", order.Header.ControlNumber)); } catch (Exception ex) { string errorMessage = string.Format("Error while sending order({0})", order.Header.ControlNumber); _log.WriteErrorLog(errorMessage, ex); ExceptionEmail.Send(ex, "", errorMessage); if (ex is EarlySocketException || ex is CancelledTransactionException) { SendToReprocess(rawOrder); } else { SendToError(ex, rawOrder); } throw; } rawOrder = _orderQueue.ConsumeFromQueue(Configuration.RabbitMQOrderServer, Configuration.RabbitMQUserNameConsumer, Configuration.RabbitMQUserPasswordConsumer, Configuration.RabbitMQVHostOrder, GetSelectedQueue(queue)); } }