public OldSendMessages(ILogger <SendMessages> logger, IOptions <ConnectionStrings> connectionStrings, IOptions <MessageQueueAppConfig> appConfig, IMessageQueueing messageQueueing, IMessageQueueProcessing messageProcessor) { _logger = logger; _appConfig = appConfig; _messageProcessor = messageProcessor; _messageQueueing = messageQueueing; _connectionStrings = connectionStrings; _messageQueueing.SetConnectionStrings(_connectionStrings.Value); _messageQueueing.InitializeMessageQueueing(appConfig.Value.MessageQueueHostName, appConfig.Value.MessageQueueUserName, appConfig.Value.MessageQueuePassword); _messageQueueing.SetInboundSemaphoreKey(appConfig.Value.InboundSemaphoreKey); _messageQueueing.SetOutboundSemaphoreKey(appConfig.Value.OutboundSemaphoreKey); _messageQueueing.InitializeExchange(appConfig.Value.ExchangeName, appConfig.Value.RoutingKey); _messageQueueing.InitializeAcknowledgementConfiguration(appConfig.Value.AcknowledgementMessageExchangeSuffix, appConfig.Value.AcknowledgementMessageQueueSuffix); string[] outboundQueues = appConfig.Value.OutboundMessageQueues.Split(","); foreach (string outboundQueue in outboundQueues) { _messageQueueing.InitializeQueue(outboundQueue); } _logger.LogInformation("Send Messages Constructor " + appConfig.Value.ExchangeName); }
/// <summary> /// Constructor /// </summary> /// <param name="messageProcessor"></param> /// <param name="appConfig"></param> /// <param name="connectionStrings"></param> public ProcessMessages(IMessageQueueProcessing messageProcessor, MessageQueueAppConfig appConfig, ConnectionStrings connectionStrings) { _appConfig = appConfig; _messageProcessor = messageProcessor; _connectionStrings = connectionStrings; Console.WriteLine("Process Messages Constructor "); }
public ReceiveMessages(IMessageQueueConnection messageQueueConnection, IMessageQueueProcessing messageProcessor, MessageQueueAppConfig appConfig, ConnectionStrings connectionStrings, List <IMessageQueueConfiguration> messageQueueConfigurations) { _messageQueueConnection = messageQueueConnection; _messageQueueConfigurations = messageQueueConfigurations; _connectionStrings = connectionStrings; _messageProcessor = messageProcessor; _appConfig = appConfig; }
/// <summary> /// Send Messages /// </summary> /// <param name="messageQueueConnection"></param> /// <param name="messageProcessor"></param> /// <param name="appConfig"></param> /// <param name="connectionStrings"></param> /// <param name="messageQueueConfigurations"></param> public SendMessages(IMessageQueueConnection messageQueueConnection, IMessageQueueProcessing messageProcessor, MessageQueueAppConfig appConfig, ConnectionStrings connectionStrings, List <IMessageQueueConfiguration> messageQueueConfigurations, string signalRQueue) { _messageQueueConnection = messageQueueConnection; _messageQueueConfigurations = messageQueueConfigurations; _connectionStrings = connectionStrings; _messageProcessor = messageProcessor; _appConfig = appConfig; _signalRQueue = signalRQueue; }
/// <summary> /// Send Messages /// </summary> /// <param name="messageQueueConnection"></param> /// <param name="messageProcessor"></param> /// <param name="appConfig"></param> /// <param name="connectionStrings"></param> /// <param name="messageQueueConfigurations"></param> public SendMessages(IMessageQueueConnection messageQueueConnection, IMessageQueueProcessing messageProcessor, MessageQueueAppConfig appConfig, ConnectionStrings connectionStrings, List <IMessageQueueConfiguration> messageQueueConfigurations, string signalRQueue) { _messageQueueConnection = messageQueueConnection; _messageQueueConfigurations = messageQueueConfigurations; _connectionStrings = connectionStrings; _messageProcessor = messageProcessor; _appConfig = appConfig; _signalRQueue = signalRQueue; using (var sw = File.AppendText(Path)) { sw.WriteLine("Send Messages Constructor"); } }
/// <summary> /// Receive Messages /// </summary> /// <param name="queueName"></param> /// <param name="subject"></param> public async Task ReceiveMessages(string queueName, Subject <MessageQueue> subject, IMessageQueueProcessing _messageProcessor) { Console.WriteLine("Receiving Messages at " + DateTime.Now); if (_running == true) { return; } _running = true; var response = _channel.QueueDeclarePassive(queueName); _channel.QueueDeclare(queue: queueName, durable: true, exclusive: false, autoDelete: false, arguments: null); _subscription = new Subscription(_channel, queueName, false); foreach (BasicDeliverEventArgs e in _subscription) { string message = Encoding.UTF8.GetString(e.Body); MessageQueue messageQueue = JsonConvert.DeserializeObject <MessageQueue>(message); messageQueue.MessageGuid = Guid.NewGuid(); if (messageQueue.QueueName == string.Empty || messageQueue.QueueName == null) { messageQueue.QueueName = _originatingQueueName; } Console.WriteLine("Receiving Message id " + messageQueue.TransactionQueueId); ResponseModel <MessageQueue> responseMessage = await _messageProcessor.CommitInboundMessage(messageQueue, _connectionStrings); if (responseMessage.ReturnStatus == true) { if (_sendToLoggingQueue == true) { responseMessage = SendReceivedMessageToLoggingQueue(messageQueue); } if (responseMessage.ReturnStatus == true) { Console.WriteLine($"Message Committed: {messageQueue.TransactionQueueId}"); _subscription.Ack(e); } await _messageProcessor.ProcessMessages(_inboundSemaphoreKey, _connectionStrings); } } }