public IEnumerable<string> GetMessagesFromQueue(QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); yield break; } var count = 0; while (++count < parameters.NumberOfMessagesToRetrieve) { var basicGetResult = channel.BasicGet(parameters.QueueName, noAck: parameters.Purge); if (basicGetResult == null) break; // no more messages on the queue yield return Encoding.UTF8.GetString(basicGetResult.Body); } } }
public IEnumerable <string> GetMessagesFromQueue(QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); yield break; } var count = 0; while (++count < parameters.NumberOfMessagesToRetrieve) { var basicGetResult = channel.BasicGet(parameters.QueueName, noAck: parameters.Purge); if (basicGetResult == null) { break; // no more messages on the queue } yield return(Encoding.UTF8.GetString(basicGetResult.Body)); } } }
public void Write(IEnumerable<HosepipeMessage> messages, QueueParameters parameters) { var count = 0; foreach (var message in messages) { var uniqueFileName = SanitiseQueueName(parameters.QueueName) + "." + count.ToString(); var bodyPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".message.txt"); var propertiesPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".properties.txt"); var infoPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".info.txt"); if(File.Exists(bodyPath)) { Console.WriteLine("Overwriting existing messsage file: {0}", bodyPath); } try { File.WriteAllText(bodyPath, message.Body); File.WriteAllText(propertiesPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Properties)); File.WriteAllText(infoPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Info)); } catch (DirectoryNotFoundException) { throw new EasyNetQHosepipeException( string.Format("Directory '{0}' does not exist", parameters.MessageFilePath)); } count++; } }
public void Write(IEnumerable <HosepipeMessage> messages, QueueParameters parameters) { var count = 0; foreach (var message in messages) { var uniqueFileName = SanitiseQueueName(parameters.QueueName) + "." + count.ToString(); var bodyPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".message.txt"); var propertiesPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".properties.txt"); var infoPath = Path.Combine(parameters.MessageFilePath, uniqueFileName + ".info.txt"); if (File.Exists(bodyPath)) { Console.WriteLine("Overwriting existing messsage file: {0}", bodyPath); } try { File.WriteAllText(bodyPath, message.Body); File.WriteAllText(propertiesPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Properties)); File.WriteAllText(infoPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Info)); } catch (DirectoryNotFoundException) { throw new EasyNetQHosepipeException( string.Format("Directory '{0}' does not exist", parameters.MessageFilePath)); } count++; } }
public void Write(IEnumerable <HosepipeMessage> messages, QueueParameters parameters) { if (!Directory.Exists(parameters.MessagesOutputDirectory)) { Console.WriteLine("Creating messages output directory: {0}", parameters.MessagesOutputDirectory); Directory.CreateDirectory(parameters.MessagesOutputDirectory); } var count = 0; foreach (var message in messages) { var uniqueFileName = SanitiseQueueName(parameters.QueueName) + "." + count; var bodyPath = Path.Combine(parameters.MessagesOutputDirectory, uniqueFileName + ".message.txt"); var propertiesPath = Path.Combine(parameters.MessagesOutputDirectory, uniqueFileName + ".properties.txt"); var infoPath = Path.Combine(parameters.MessagesOutputDirectory, uniqueFileName + ".info.txt"); if (File.Exists(bodyPath)) { Console.WriteLine("Overwriting existing message file: {0}", bodyPath); } File.WriteAllText(bodyPath, message.Body); File.WriteAllText(propertiesPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Properties)); File.WriteAllText(infoPath, Newtonsoft.Json.JsonConvert.SerializeObject(message.Info)); count++; } }
public void PublishMessagesToQueue(IEnumerable <string> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); return; } foreach (var message in messages) { var body = Encoding.UTF8.GetBytes(message); var properties = channel.CreateBasicProperties(); // take advantage of the fact that every AMQP queue binds to the default ("") // queue using its name as the routing key channel.BasicPublish("", parameters.QueueName, properties, body); } } }
public void RepublishError(Error error, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var model = connection.CreateModel()) { try { if (error.Exchange != string.Empty) { model.ExchangeDeclarePassive(error.Exchange); } var properties = model.CreateBasicProperties(); error.BasicProperties.CopyTo(properties); var body = Encoding.UTF8.GetBytes(error.Message); model.BasicPublish(error.Exchange, error.RoutingKey, properties, body); } catch (OperationInterruptedException) { Console.WriteLine("The exchange, '{0}', described in the error message does not exist on '{1}', '{2}'", error.Exchange, parameters.HostName, parameters.VHost); } } }
public static IConnection FromParameters(QueueParameters parameters) { var connectionFactory = new ConnectionFactory { HostName = parameters.HostName, VirtualHost = parameters.VHost, UserName = parameters.Username, Password = parameters.Password, Port = parameters.HostPort }; try { return(connectionFactory.CreateConnection()); } catch (BrokerUnreachableException) { throw new EasyNetQHosepipeException(string.Format( "The broker at '{0}{2}' VirtualHost '{1}', is unreachable. This message can also be caused " + "by incorrect credentials.", parameters.HostName, parameters.VHost, parameters.HostPort == -1 ? string.Empty: ":" + parameters.HostPort)); } }
public IEnumerable <HosepipeMessage> ReadMessages(QueueParameters parameters, string messageName) { if (!Directory.Exists(parameters.MessageFilePath)) { Console.WriteLine("Directory '{0}' does not exist", parameters.MessageFilePath); yield break; } var bodyPattern = (messageName ?? "*") + ".*.message.txt"; foreach (var file in Directory.GetFiles(parameters.MessageFilePath, bodyPattern)) { const string messageTag = ".message."; var directoryName = Path.GetDirectoryName(file); var fileName = Path.GetFileName(file); var propertiesFileName = Path.Combine(directoryName, fileName.Replace(messageTag, ".properties.")); var infoFileName = Path.Combine(directoryName, fileName.Replace(messageTag, ".info.")); var body = File.ReadAllText(file); var propertiesJson = File.ReadAllText(propertiesFileName); var properties = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageProperties>(propertiesJson); var infoJson = File.ReadAllText(infoFileName); var info = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageReceivedInfo>(infoJson); yield return(new HosepipeMessage(body, properties, info)); } }
public IEnumerable<HosepipeMessage> ReadMessages(QueueParameters parameters, string messageName) { if (!Directory.Exists(parameters.MessageFilePath)) { Console.WriteLine("Directory '{0}' does not exist", parameters.MessageFilePath); yield break; } var bodyPattern = (messageName ?? "*") + ".*.message.txt"; foreach (var file in Directory.GetFiles(parameters.MessageFilePath, bodyPattern)) { var propertiesFileName = file.Replace("message", "properties"); var infoFileName = file.Replace("message", "info"); var body = File.ReadAllText(file); var propertiesJson = File.ReadAllText(propertiesFileName); var properties = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageProperties>(propertiesJson); var infoJson = File.ReadAllText(infoFileName); var info = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageReceivedInfo>(infoJson); yield return new HosepipeMessage(body, properties, info); } }
public void PublishMessagesToQueue(IEnumerable<string> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); return; } foreach (var message in messages) { var body = Encoding.UTF8.GetBytes(message); var properties = channel.CreateBasicProperties(); // take advantage of the fact that every AMQP queue binds to the default ("") // queue using its name as the routing key channel.BasicPublish("", parameters.QueueName, properties, body); } } }
public IEnumerable<HosepipeMessage> GetMessagesFromQueue(QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); yield break; } var count = 0; while (count++ < parameters.NumberOfMessagesToRetrieve) { var basicGetResult = channel.BasicGet(parameters.QueueName, noAck: parameters.Purge); if (basicGetResult == null) break; // no more messages on the queue var properties = new MessageProperties(basicGetResult.BasicProperties); var info = new MessageReceivedInfo( "hosepipe", basicGetResult.DeliveryTag, basicGetResult.Redelivered, basicGetResult.Exchange, basicGetResult.RoutingKey, parameters.QueueName); yield return new HosepipeMessage(errorMessageSerializer.Serialize(basicGetResult.Body), properties, info); } } }
public void Start(string[] args) { var arguments = argParser.Parse(args); var results = new StringBuilder(); var succeeded = true; Func <string, Action> messsage = m => () => { results.AppendLine(m); succeeded = false; }; var parameters = new QueueParameters(); arguments.WithKey("s", a => parameters.HostName = a.Value); arguments.WithKey("v", a => parameters.VHost = a.Value); arguments.WithKey("u", a => parameters.Username = a.Value); arguments.WithKey("p", a => parameters.Password = a.Value); arguments.WithKey("o", a => parameters.MessageFilePath = a.Value); arguments.WithTypedKeyOptional <int>("n", a => parameters.NumberOfMessagesToRetrieve = int.Parse(a.Value)) .FailWith(messsage("Invalid number of messages to retrieve")); try { arguments.At(0, "dump", () => arguments.WithKey("q", a => { parameters.QueueName = a.Value; Dump(parameters); }).FailWith(messsage("No Queue Name given"))); arguments.At(0, "insert", () => arguments.WithKey("q", a => { parameters.QueueName = a.Value; Insert(parameters); }).FailWith(messsage("No Queue Name given"))); arguments.At(0, "err", () => ErrorDump(parameters)); arguments.At(0, "retry", () => Retry(parameters)); arguments.At(0, "?", PrintUsage); // print usage if there are no arguments arguments.At(0, a => {}).FailWith(PrintUsage); } catch (EasyNetQHosepipeException easyNetQHosepipeException) { Console.WriteLine("Operation Failed:"); Console.WriteLine(easyNetQHosepipeException.Message); } if (!succeeded) { Console.WriteLine("Operation failed"); Console.Write(results.ToString()); Console.WriteLine(); PrintUsage(); } }
private void ErrorDump(QueueParameters parameters) { if (parameters.QueueName == null) { parameters.QueueName = conventions.ErrorQueueNamingConvention(null); } Dump(parameters); }
public void RetryErrors(IEnumerable<HosepipeMessage> rawErrorMessages, QueueParameters parameters) { foreach (var rawErrorMessage in rawErrorMessages) { var error = serializer.BytesToMessage<Error>(errorMessageSerializer.Deserialize(rawErrorMessage.Body)); RepublishError(error, parameters); } }
private void ErrorDump(QueueParameters parameters) { if (parameters.QueueName == null) { parameters.QueueName = conventions.ErrorQueueNamingConvention(new MessageReceivedInfo()); } Dump(parameters); }
public void RetryErrors(IEnumerable <HosepipeMessage> rawErrorMessages, QueueParameters parameters) { foreach (var rawErrorMessage in rawErrorMessages) { var error = serializer.BytesToMessage <Error>(Encoding.UTF8.GetBytes(rawErrorMessage.Body)); RepublishError(error, parameters); } }
public void RetryErrors(IEnumerable <HosepipeMessage> rawErrorMessages, QueueParameters parameters) { foreach (var rawErrorMessage in rawErrorMessages) { var error = (Error)serializer.BytesToMessage(typeof(Error), errorMessageSerializer.Deserialize(rawErrorMessage.Body)); RepublishError(error, parameters); } }
public void RetryErrors(IEnumerable<string> rawErrorMessages, QueueParameters parameters) { foreach (var rawErrorMessage in rawErrorMessages) { var error = serializer.BytesToMessage<Error>(Encoding.UTF8.GetBytes(rawErrorMessage)); RepublishError(error, parameters); } }
private void Dump(QueueParameters parameters) { var count = 0; messageWriter.Write(WithEach(queueRetreival.GetMessagesFromQueue(parameters), () => count++), parameters); Console.WriteLine("{0} Messages from queue '{1}'\r\noutput to directory '{2}'", count, parameters.QueueName, parameters.MessagesOutputDirectory); }
public void Start(string[] args) { var arguments = argParser.Parse(args); var results = new StringBuilder(); var succeeded = true; Func<string, Action> messsage = m => () => { results.AppendLine(m); succeeded = false; }; var parameters = new QueueParameters(); arguments.WithKey("s", a => parameters.HostName = a.Value); arguments.WithKey("v", a => parameters.VHost = a.Value); arguments.WithKey("u", a => parameters.Username = a.Value); arguments.WithKey("p", a => parameters.Password = a.Value); arguments.WithKey("o", a => parameters.MessageFilePath = a.Value); arguments.WithKey("q", a => parameters.QueueName = a.Value); arguments.WithTypedKeyOptional<int>("n", a => parameters.NumberOfMessagesToRetrieve = int.Parse(a.Value)) .FailWith(messsage("Invalid number of messages to retrieve")); arguments.WithTypedKeyOptional<bool>("x", a => parameters.Purge = bool.Parse(a.Value)) .FailWith(messsage("Invalid purge (x) parameter")); try { arguments.At(0, "dump", () => arguments.WithKey("q", a => { parameters.QueueName = a.Value; Dump(parameters); }).FailWith(messsage("No Queue Name given"))); arguments.At(0, "insert", () => Insert(parameters)); arguments.At(0, "err", () => ErrorDump(parameters)); arguments.At(0, "retry", () => Retry(parameters)); arguments.At(0, "?", PrintUsage); // print usage if there are no arguments arguments.At(0, a => {}).FailWith(PrintUsage); } catch (EasyNetQHosepipeException easyNetQHosepipeException) { Console.WriteLine("Operation Failed:"); Console.WriteLine(easyNetQHosepipeException.Message); } if(!succeeded) { Console.WriteLine("Operation failed"); Console.Write(results.ToString()); Console.WriteLine(); PrintUsage(); } }
private void Insert(QueueParameters parameters) { var count = 0; queueInsertion.PublishMessagesToQueue( WithEach(messageReader.ReadMessages(parameters), () => count++), parameters); Console.WriteLine("{0} Messages from directory '{1}'\r\ninserted into queue '{2}'", count, parameters.MessagesOutputDirectory, parameters.QueueName); }
public void RepublishError(Error error, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParameters(parameters)) using (var model = connection.CreateModel()) { var properties = model.CreateBasicProperties(); error.BasicProperties.CopyTo(properties); var body = errorMessageSerializer.Deserialize(error.Message); model.BasicPublish("", error.Queue, true, properties, body); } }
private void Retry(QueueParameters parameters) { var count = 0; errorRetry.RetryErrors( WithEach( messageReader.ReadMessages(parameters, DefaultConsumerErrorStrategy.EasyNetQErrorQueue), () => count++), parameters); Console.WriteLine("{0} Error messages from directory '{1}' republished", count, parameters.MessageFilePath); }
private void Retry(QueueParameters parameters) { var count = 0; errorRetry.RetryErrors( WithEach( messageReader.ReadMessages(parameters, conventions.ErrorQueueNamingConvention()), () => count++), parameters); Console.WriteLine("{0} Error messages from directory '{1}' republished", count, parameters.MessageFilePath); }
private void Retry(QueueParameters parameters) { var count = 0; var queueName = parameters.QueueName ?? conventions.ErrorQueueNamingConvention(null); errorRetry.RetryErrors( WithEach(messageReader.ReadMessages(parameters, queueName), () => count++), parameters ); Console.WriteLine( "{0} error messages from directory '{1}' were republished", count, parameters.MessagesOutputDirectory ); }
public void Start(string[] args) { var arguments = argParser.Parse(args); var parameters = new QueueParameters(); arguments.WithKey("s", a => parameters.HostName = a.Value); arguments.WithKey("sp", a => parameters.HostPort = Convert.ToInt32(a.Value)); arguments.WithKey("v", a => parameters.VHost = a.Value); arguments.WithKey("u", a => parameters.Username = a.Value); arguments.WithKey("p", a => parameters.Password = a.Value); arguments.WithKey("o", a => parameters.MessagesOutputDirectory = a.Value); arguments.WithKey("q", a => parameters.QueueName = a.Value); arguments.WithTypedKeyOptional <int>("n", a => parameters.NumberOfMessagesToRetrieve = int.Parse(a.Value)) .FailWith(messsage("Invalid number of messages to retrieve")); arguments.WithTypedKeyOptional <bool>("x", a => parameters.Purge = bool.Parse(a.Value)) .FailWith(messsage("Invalid purge (x) parameter")); try { arguments.At(0, "dump", () => arguments.WithKey("q", a => { parameters.QueueName = a.Value; Dump(parameters); }).FailWith(messsage("No Queue Name given"))); arguments.At(0, "insert", () => Insert(parameters)); arguments.At(0, "err", () => ErrorDump(parameters)); arguments.At(0, "retry", () => Retry(parameters)); arguments.At(0, "?", PrintUsage); // print usage if there are no arguments arguments.At(0, a => {}).FailWith(PrintUsage); } catch (EasyNetQHosepipeException easyNetQHosepipeException) { Console.WriteLine("Operation Failed:"); Console.WriteLine(easyNetQHosepipeException.Message); } if (!succeeded) { Console.WriteLine("Operation failed"); Console.Write(results.ToString()); Console.WriteLine(); PrintUsage(); } }
public IEnumerable<string> ReadMessages(QueueParameters parameters, string messageName) { if (!Directory.Exists(parameters.MessageFilePath)) { Console.WriteLine("Directory '{0}' does not exist", parameters.MessageFilePath); yield break; } var pattern = (messageName ?? "*") + ".*.message.txt"; foreach (var file in Directory.GetFiles(parameters.MessageFilePath, pattern)) { yield return File.ReadAllText(file); } }
public IEnumerable <string> ReadMessages(QueueParameters parameters, string messageName) { if (!Directory.Exists(parameters.MessageFilePath)) { Console.WriteLine("Directory '{0}' does not exist", parameters.MessageFilePath); yield break; } var pattern = (messageName ?? "*") + ".*.message.txt"; foreach (var file in Directory.GetFiles(parameters.MessageFilePath, pattern)) { yield return(File.ReadAllText(file)); } }
public void PublishMessagesToQueue(IEnumerable <HosepipeMessage> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { foreach (var message in messages) { var body = Encoding.UTF8.GetBytes(message.Body); var properties = new BasicProperties(); message.Properties.CopyTo(properties); channel.BasicPublish(message.Info.Exchange, message.Info.RoutingKey, properties, body); } } }
public void PublishMessagesToQueue(IEnumerable<HosepipeMessage> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParamters(parameters)) using (var channel = connection.CreateModel()) { foreach (var message in messages) { var body = Encoding.UTF8.GetBytes(message.Body); var properties = new BasicProperties(); message.Properties.CopyTo(properties); channel.BasicPublish(message.Info.Exchange, message.Info.RoutingKey, properties, body); } } }
public void PublishMessagesToQueue(IEnumerable <HosepipeMessage> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParameters(parameters)) using (var channel = connection.CreateModel()) { foreach (var message in messages) { var body = errorMessageSerializer.Deserialize(message.Body); var properties = channel.CreateBasicProperties(); message.Properties.CopyTo(properties); channel.BasicPublish(message.Info.Exchange, message.Info.RoutingKey, true, properties, body); } } }
public void RetryErrors(IEnumerable <HosepipeMessage> rawErrorMessages, QueueParameters parameters) { using var connection = HosepipeConnection.FromParameters(parameters); using var model = connection.CreateModel(); model.ConfirmSelect(); foreach (var rawErrorMessage in rawErrorMessages) { var error = (Error)serializer.BytesToMessage(typeof(Error), errorMessageSerializer.Deserialize(rawErrorMessage.Body)); var properties = model.CreateBasicProperties(); error.BasicProperties.CopyTo(properties); var body = errorMessageSerializer.Deserialize(error.Message); model.BasicPublish("", error.Queue, true, properties, body); model.WaitForConfirmsOrDie(); } }
public void PublishMessagesToQueue(IEnumerable <HosepipeMessage> messages, QueueParameters parameters) { using (var connection = HosepipeConnection.FromParameters(parameters)) using (var channel = connection.CreateModel()) { foreach (var message in messages) { var body = errorMessageSerializer.Deserialize(message.Body); var properties = channel.CreateBasicProperties(); message.Properties.CopyTo(properties); var queueName = string.IsNullOrEmpty(parameters.QueueName) ? message.Info.Queue : parameters.QueueName; channel.BasicPublish("", queueName, true, properties, body); } } }
public static IConnection FromParamters(QueueParameters parameters) { var connectionFactory = new ConnectionFactory { HostName = parameters.HostName, VirtualHost = parameters.VHost, UserName = parameters.Username, Password = parameters.Password }; try { return connectionFactory.CreateConnection(); } catch (BrokerUnreachableException) { throw new EasyNetQHosepipeException(string.Format( "The broker at '{0}', VirtualHost '{1}', is unreachable. This message can also be caused " + "by incorrect credentials.", parameters.HostName, parameters.VHost)); } }
public void RetryErrors(IEnumerable <HosepipeMessage> rawErrorMessages, QueueParameters parameters) { using var connection = HosepipeConnection.FromParameters(parameters); using var model = connection.CreateModel(); model.ConfirmSelect(); var errors = rawErrorMessages .Select(x => (Error)serializer.BytesToMessage(typeof(Error), errorMessageSerializer.Deserialize(x.Body))) .ToArray(); var tempExchangeName = DeclareTemporaryExchange(model); try { RouteMessagesToExchange(model, tempExchangeName, errors); PublishMessages(model, tempExchangeName, errors); } finally { model.ExchangeDelete(tempExchangeName); } }
public void Write(IEnumerable<string> messages, QueueParameters parameters) { var count = 0; foreach (string message in messages) { var fileName = parameters.QueueName + "." + count.ToString() + ".message.txt"; var path = Path.Combine(parameters.MessageFilePath, fileName); if(File.Exists(path)) { Console.WriteLine("Overwriting existing messsage file: {0}", path); } try { File.WriteAllText(path, message); } catch (DirectoryNotFoundException) { throw new EasyNetQHosepipeException( string.Format("Directory '{0}' does not exist", parameters.MessageFilePath)); } count++; } }
public IEnumerable <HosepipeMessage> GetMessagesFromQueue(QueueParameters parameters) { using (var connection = HosepipeConnection.FromParameters(parameters)) using (var channel = connection.CreateModel()) { try { channel.QueueDeclarePassive(parameters.QueueName); } catch (OperationInterruptedException exception) { Console.WriteLine(exception.Message); yield break; } var count = 0; while (count++ < parameters.NumberOfMessagesToRetrieve) { var basicGetResult = channel.BasicGet(parameters.QueueName, parameters.Purge); if (basicGetResult == null) { break; // no more messages on the queue } var properties = new MessageProperties(basicGetResult.BasicProperties); var info = new MessageReceivedInfo( "hosepipe", basicGetResult.DeliveryTag, basicGetResult.Redelivered, basicGetResult.Exchange, basicGetResult.RoutingKey, parameters.QueueName ); yield return(new HosepipeMessage(errorMessageSerializer.Serialize(basicGetResult.Body.ToArray()), properties, info)); } } }
public void Write(IEnumerable <string> messages, QueueParameters parameters) { var count = 0; foreach (string message in messages) { var fileName = SanitiseQueueName(parameters.QueueName) + "." + count.ToString() + ".message.txt"; var path = Path.Combine(parameters.MessageFilePath, fileName); if (File.Exists(path)) { Console.WriteLine("Overwriting existing messsage file: {0}", path); } try { File.WriteAllText(path, message); } catch (DirectoryNotFoundException) { throw new EasyNetQHosepipeException( string.Format("Directory '{0}' does not exist", parameters.MessageFilePath)); } count++; } }
public IEnumerable<string> ReadMessages(QueueParameters parameters) { return ReadMessages(parameters, null); }
public IEnumerable<HosepipeMessage> ReadMessages(QueueParameters parameters) { return ReadMessages(parameters, null); }
public IEnumerable <string> ReadMessages(QueueParameters parameters) { return(ReadMessages(parameters, null)); }
private void Insert(QueueParameters parameters) { var count = 0; queueInsertion.PublishMessagesToQueue( WithEach(messageReader.ReadMessages(parameters), () => count++), parameters); Console.WriteLine("{0} Messages from directory '{1}'\r\ninserted into queue '{2}'", count, parameters.MessageFilePath, parameters.QueueName); }
private void ErrorDump(QueueParameters parameters) { parameters.QueueName = conventions.ErrorQueueNamingConvention(); Dump(parameters); }
private void Dump(QueueParameters parameters) { var count = 0; messageWriter.Write(WithEach(queueRetreival.GetMessagesFromQueue(parameters), () => count++), parameters); Console.WriteLine("{0} Messages from queue '{1}'\r\noutput to directory '{2}'", count, parameters.QueueName, parameters.MessageFilePath); }
private void ErrorDump(QueueParameters parameters) { parameters.QueueName = DefaultConsumerErrorStrategy.EasyNetQErrorQueue; Dump(parameters); }
public IEnumerable <HosepipeMessage> ReadMessages(QueueParameters parameters) { return(ReadMessages(parameters, null)); }