[This post series is based on preview features that are subject to change]

This is an epilogue of my 3-part blog series on the recently released Service Bus preview features

part 1: Message Pump

part 2: Auto-expiration

part 3: Shared Access Authorization

Why an epilogue?

I’ve missed another feature in the preview library – message browse, which allows you to iterate through the messages without blocking any receivers. But, before I get to that, I have to clarify one thing regarding what I said in the Message Pump post. When you call Client.Receive() method, you can specify a timeout of any duration to wait for a message to arrive. This is not a long-polling, but it does allow you to specify a timeout period before the method returns. So, the price comparison in the original post isn’t that relevant after all. However, the gist of that post is never about price reduction, but about how Message Pump enables  event-driven programming model, which is really natural to client applications, especially rich clients. With that said, let’s move on to the main topic: Message Browse.

Message Browse

Message browse can be useful in scenarios where you need to provide monitoring or tracing capabilities without affecting existing clients. For example, you can examine top 10 messages from dead-lettered queue. Or, you can provide live monitoring of pending jobs (such as if a job related to a specific customer has appeared on the queue). Here I’ll just present a very simple Console application as an example:

static void Main(string[] args)
{
    var conString = "[SB Connection String]";
    var queueName = "workqueue";
    QueueClient sender = QueueClient.CreateFromConnectionString(conString, queueName);
    for (int i = 0; i < 10; i++)
        sender.Send(new BrokeredMessage(string.Format("Message {0}", i+1)));
    QueueClient receiver = QueueClient.CreateFromConnectionString(conString, queueName, 
        ReceiveMode.ReceiveAndDelete);

    BrokeredMessage message = null;
    do
    {
        message = receiver.Peek();
        if (message != null)
            Console.WriteLine("Message found: " + message.GetBody<string>());
    } while (message != null);

    Console.ReadLine();

    message = null;

    do
    {
        message = receiver.Receive();
        if (message != null)
            Console.WriteLine("Message received: " + message.GetBody<string>());
    } while (message != null);

    Console.ReadLine();
}

The above code sends 10 messages to a queue, browses the messages by using the Peek() method (highlighted yellow), and then retrieves the messages using the Receive() method (highlighted green). Because the Peek() method doesn’t remove any messages from the queue, Recevie() calls are not affected afterwards and all the messages can be received.

Send us your feedbacks!

I hope you’ve learned some useful information from this blog series. And I know the production team is eager to hear from you. Are the features useful in your scenarios? What are we missing? Where do we need to improve? The whole idea of the preview library is to get your feedbacks so that we can make the final product better. So, if you have any feedbacks, either positive or negative, please don’t hesitate to send them my way, and I’ll make sure they are heard by the team. You can either leave comments to this blog, or send tweets to @HaishiBai2010. Thank you for reading!

0

Add a comment

When we learn classic compute algorithms, we don't start with learning how a computer is built. We don't start with how a transistor works or how to build integrated circuits. Instead, we go straight with the abstraction - bits, commands, programs and such. I think we should take the same approach when we learn quantum computing. Instead of trying to understand the bizarre quantum world, we should take some quantum behaviors granted and go straight with higher-level abstracts such as qubits and quantum gates. And once we grasp these basic concepts, we should go even a level higher to use a high-level language like Q# and focus on how quantum algorithms work, and how we can apply quantum algorithms on practical problems.

Bono is an open source quantum algorithm visualizer I'm building in the open. This project is inspired by a few existing systems such as QuirkIBM Q Experience, and the Programming Quantum Computers book. Bono is a Javascript-based visualizer that features:

  • Drag-and-drop quantum circuit editing.
  • Dynamic circuit evaluation.
  • Works offline in a browser. No server is needed.
  •  Generates Q# code.
I've also created a YouTube channel dedicated to quantum algorithms. My goal is to create an easily digestable course for regular software developers to learn about quantum computing without needing to understand any underlying quantum physics. 

Bono is at its infancy. And I'm still a new student in the quantum world. I intentionally develop both Bono and the video series in the open. I hope the early results can inspire collaborations so that we can explore the quantum computing world together.

Last but not least, you can find more Q# related contents at the Q# Advent Calendar 2019.
0

Add a comment

Series
存档
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.