0

We have below code to QueueTrigger and we want to have message metadata(ie: dequequecount, lastretrival) at ProcessQueueMessage. Is there way to achive it?

 public static void ProcessQueueMessage([QueueTrigger(AppConstants.AzureBlobQueue)] string message, TextWriter log, ExecutionContext context)
    {
        try
        {
            //Do Something
            log.WriteLine(message);
        }
        catch (Exception ex)
        {
            if(message.DequeueCount == 1)
            {
              //Logic 1 to notify 
            }
             if(message.DequeueCount == 2)
            {
              //Logic 2 to notify 
            } if(message.DequeueCount == 3)
            {
              //Logic 3 to notify 
            } if(message.DequeueCount == 4)
            {
              //Logic 4 to notify 
            } if(message.DequeueCount == 5)
            {
              //Logic 5 to notify 
            }
        }

    }

We have different logic for dequeue count == 5 we want to move message to db, we can achive it via queue-poison but just does not want to add another webjob/function for same.

oypatel
  • 73
  • 1
  • 11

1 Answers1

2

Sure you can, just change the type of message from string to CloudQueueMessage:

public static void ProcessQueueMessage(
    [QueueTrigger(AppConstants.AzureBlobQueue)] CloudQueueMessage message, 
    TextWriter log, ExecutionContext context)
Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107