public static void Main(string[] args) { try { const string connectionUrl = @"amqp://*****:*****@clientid/test?brokerlist='tcp://localhost:5672'"; const string queueName = @"test-queue"; var connectionInfo = QpidConnectionInfo.FromUrl(connectionUrl); var connection = new AMQConnection(connectionInfo); var channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1); channel.DeclareQueue(queueName, false, true, true); channel.Bind(queueName, ExchangeNameDefaults.DIRECT, queueName); IMessageConsumer consumer = channel.CreateConsumerBuilder(queueName).Create(); connection.Start(); ITextMessage message = (ITextMessage)consumer.Receive(); Console.WriteLine("Got: " + message.Text); connection.Dispose(); } catch (Exception e) { Console.WriteLine(e); } }
public static void Main(string[] args) { try { const string connectionUrl = @"amqp://*****:*****@clientid/test?brokerlist='tcp://localhost:5672'"; const string queueName = @"test-queue"; var connectionInfo = QpidConnectionInfo.FromUrl(connectionUrl); var connection = new AMQConnection(connectionInfo); var channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge); var publisher = channel.CreatePublisherBuilder() .WithExchangeName(ExchangeNameDefaults.DIRECT) .WithRoutingKey(queueName) .Create(); IMessage message = channel.CreateTextMessage("0123456789"); publisher.Send(message); Console.WriteLine("Sent message"); connection.Dispose(); } catch (Exception e) { Console.WriteLine(e); } }