public StoreLocatorQuery(string zipCode, string clientId, string key, decimal latitude, decimal longitude) { GeoCode = new GeoCode { PostalCode = zipCode, Latitude = latitude, Longitude = longitude }; ConsumerParameters = new ConsumerParameters { Culture = "en-US", Country = "US", Size = "D", Template = string.Empty, ClientId = clientId, Key = key }; }
public static RabbitMqEndpoint NewInboundConsumer(string name, string type, string routingKeyOrTopicName = "", ConsumerParameters p = null, CancellationToken token = default(CancellationToken)) { p ??= new ConsumerParameters(); var exchangeType = GetFullExchangeType(type); var ret = new RabbitMqEndpoint { Channel = _RabbitIn.CreateModel(), EndpointType = EndpointTypeEnum.Consumer, ExchangeName = name, LocalCancellationToken = _RabbitInCts?.Token ?? token, QueueTtlValues = new Dictionary <string, int>(), ChannelParameters = p, ExchangeType = GetFullExchangeType(type), QueueName = DefineQueueName(name, exchangeType, routingKeyOrTopicName, true), }; VerboseLoggingHandler.Log($"Building a {exchangeType} inbound consumer, name='{name}', routingKeyOrTopicName='{routingKeyOrTopicName}', durable='{p.Durable}', ttl='{p.Ttl}', autoDelete='{p.AutoDelete}', autoAckMode='{p.AutoAckMode}'"); ret.ConnectToExchange(); try { VerboseLoggingHandler.Log($"Binding queue '{ret.QueueName}'"); ret.Channel.QueueBind(ret.QueueName, name, routingKeyOrTopicName, new Dictionary <string, object>()); } catch (Exception e) { VerboseLoggingHandler.Log(e); throw e; } VerboseLoggingHandler.Log("Initiating the consumer"); ret.Consumer = new AsyncEventingBasicConsumer(ret.Channel); ret.Consumer.Received += ret.OnIncomingMessageAsync; VerboseLoggingHandler.Log("Consumer ready"); return(ret); }
static async Task Main(string[] args) { var mp = new MessageParameters() { AutoAck = false, Durable = true, Mandatory = true, Persistent = true, Priority = 3, Resilient = true, TimeOut = 32000 }; var ep = new PublisherParameters() { AutoDelete = false, Durable = true, AcceptReplies = true, ReplyQueueTtl = 8000, Ttl = 8000, EnableConfirmSelect = true }; Console.Write("Enter server name to connect to: "); var broker = Console.ReadLine(); Console.Write("Login Name: "); var login = Console.ReadLine(); Console.Write("Password: "******"/", login, password, 0, "RabbitMqFacadeTest1", cts); var cp = new ConsumerParameters() { AutoAckMode = ConsumerParameters.AutoAckModeEnum.Manual, AutoDelete = false, Durable = true }; var consumer = RabbitMqEndpoint.NewInboundConsumer("test", "d", "d", cp); consumer.IncomingMessage += OnIncomingMessage; consumer.Listen(); var publisher = RabbitMqEndpoint.NewOutboundPublisher("test", "d", "d", ep, mp); var response = await publisher.SendRpcMessageAsync("My name is Bob"); if (response == null) { Console.WriteLine("No one there!"); } else { Console.WriteLine(RabbitMqEndpoint.ConvertMessageToString(response)); } response = await publisher.SendRpcMessageAsync("My name is Sue"); if (response == null) { Console.WriteLine("No one there!"); } else { Console.WriteLine(RabbitMqEndpoint.ConvertMessageToString(response)); } response = await publisher.SendRpcMessageAsync("Ribbit"); if (response == null) { Console.WriteLine("No one there!"); } else { Console.WriteLine(RabbitMqEndpoint.ConvertMessageToString(response)); } response = await publisher.SendRpcMessageAsync("My name is Rachel"); if (response == null) { Console.WriteLine("No one there!"); } else { Console.WriteLine(RabbitMqEndpoint.ConvertMessageToString(response)); } Console.ReadLine(); }