azure - 获取队列触发器 azure webjob 的消息元数据

标签 azure azure-functions azure-webjobs azure-webjobssdk

我们有以下 QueueTrigger 代码,并且我们希望在 ProcessQueueMessage 中拥有消息元数据(即:dequequecount、lastretrival)。有办法实现吗?

 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 
            }
        }

    }

我们对于出队计数 == 5 有不同的逻辑,我们想要将消息移动到数据库,我们可以通过队列毒药来实现它,但只是不想为此添加另一个网络作业/函数。

最佳答案

当然可以,只需将消息类型从string更改为CloudQueueMessage即可:

public static void ProcessQueueMessage(
    [QueueTrigger(AppConstants.AzureBlobQueue)] CloudQueueMessage message, 
    TextWriter log, ExecutionContext context)

关于azure - 获取队列触发器 azure webjob 的消息元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46425322/

相关文章:

azure-functions - 持久函数 Blob 触发器

.net - 连续 WebJob Stopping_wait_time 被忽略?

azure - 安排网络作业

azure - 我可以在 Mac 上使用哪个工具来创建 Analysis Services 表格模型?

azure - 如何在任务执行期间(实时)更新stdout.txt?

AzureML 模型注册

powershell - 无需外部工具即可设置新的 Azure 虚拟机

azure - 比较 AWS-lambda、Azure 函数和 Google Cloud Function

azure - Azure 数据工厂中的 DayOfWeek 动态函数

c# - 在应用服务上运行简单的 WebJob