/// <summary> /// Writes message to a queue /// </summary> /// <param name="inputParams"></param> public static bool WriteMessage([PropertyTab] WriteInputParams inputParams) { OpenConnectionIfClosed(inputParams.HostName, inputParams.ConnectWithURI); if (inputParams.Create) { _channel.QueueDeclare(queue: inputParams.QueueName, durable: inputParams.Durable, exclusive: false, autoDelete: false, arguments: null); } IBasicProperties basicProperties = null; if (inputParams.Durable == true) { basicProperties = _channel.CreateBasicProperties(); basicProperties.Persistent = true; } _channel.BasicPublish(exchange: inputParams.ExchangeName, routingKey: inputParams.RoutingKey, basicProperties: basicProperties, body: inputParams.Data); return(true); }
/// <summary> /// Writes message to queue. Message is a string and there is internal conversion from string to byte[] using UTF8 encoding /// </summary> /// <param name="inputParams"></param> /// <returns></returns> public static bool WriteMessageString([PropertyTab] WriteInputParamsString inputParams) { WriteInputParams wip = new WriteInputParams { ConnectWithURI = inputParams.ConnectWithURI, Create = inputParams.Create, Data = Encoding.UTF8.GetBytes(inputParams.Data), Durable = inputParams.Durable, HostName = inputParams.HostName, ExchangeName = inputParams.ExchangeName, QueueName = inputParams.QueueName, RoutingKey = inputParams.RoutingKey }; return(WriteMessage(wip)); }