Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Trace.OnTraceEvent += Trace.ConsoleTraceEventHandler;
            // Create an AmqpClient from a URI pointing to an address (i.e. a queue)
            // 1) The URI format, simply, is "amqps://[username:password@]host/address"
            // 2) "amqps" specifies TLS over TCP
            // 3) "amqp" specifies TCP
            // 4) Including a username/password specifies SASL authentication.
            // 5) "address" specifies the endpoint at which to send/receive.
            var client = AmqpClient.CreateFromURI("amqps://*****:*****@jdaigle-test-amqp.servicebus.windows.net/event_queue");

            // The client will automatically maintain and pool connections/sessions, reconnecting as necessary.

            // Send a message to the specified endpoint. The message is automatically
            // encoded using the default encoding of the client.
            var task = client.SendAsync(new HelloWorldMessage()
            {
                Data = "Hello World! " + Guid.NewGuid().ToString(),
            });

            // All client API operations are async.
            task.Wait();

            Console.WriteLine("Press Enter To Exit");
            Console.ReadLine();
        }