简体   繁体   中英

Azure Queue Trigger giving null queue item incorrectly

I'm trying to write a system in Azure, and for one part of it I want to be able to have a number of bits of code writing to a queue, and have a single bit of processing code deal with each item in the queue.

Items are being added to the queue correctly. I've checked this; I have Visual Studio with the Azure plugins. I can then use Cloud Explorer to pull up the storage account and view the queue. In here, the queue content seems correct, in that the Message Text Preview looks as I would expect.

However, when I add an Azure Functions with a Queue Trigger to process this, while the trigger fires, the queue item comes out empty. I've tried the tutorial code, cut down a little. When I set the run function to be:

public static void Run(string myQueueItem,
    DateTimeOffset expirationTime,
    DateTimeOffset insertionTime,
    DateTimeOffset nextVisibleTime,
    string queueTrigger,        
    TraceWriter log)
{
    log.Info($"C# Queue trigger function processed:     '{myQueueItem.GetType()}'\n" +
        $"queueTrigger={queueTrigger}\n" +
        $"expirationTime={expirationTime}\n" +
        $"insertionTime={insertionTime}\n" +
        $"nextVisibleTime={nextVisibleTime}\n");
}

I then get output with the queue item is empty, when I know it isn't. The queue trigger element is also empty. Here is some sample output, when I run the function directly in Azure Functions:

016-11-01T13:47:41.834 C# Queue trigger function processed: 
queueTrigger=
expirationTime=12/31/9999 11:59:59 PM +00:00
insertionTime=11/1/2016 1:47:41 PM +00:00

The fact that this triggers at all, and has a sensible looking insertion time suggests that I'm connecting to the right queue.

Does anyone know why the string myQueueItem coming out empty, when the queue peeking tool can see the full preview string?

I've now got this working. I did two things.

First I cleared out the 'poison' queue. I had been trying to deserialize some object from the queue earlier.

Then, I enabled the queue - it was disabled earlier. It seems to me that, when you manually run a disabled Queue Trigger, it provides some fake information, and doesn't take anything from the queue - it doesn't even dequeue a message, wihch was the hint.

From this point on, when I add queues, they get processed correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM