簡體   English   中英

服務總線觸發azure webjob

[英]service bus Trigger azure webjob

我創建了一個 azure webjob,它將向服務總線隊列發送強類型消息並成功發送。

我想創建另一個 webjob,只要 servicebus 隊列中有消息就應該觸發它。 請在下面找到我正在嘗試的代碼。 出於某種原因,雖然 servicebus 隊列中有消息,但當我在本地運行 webjob 時,webjob 沒有被觸發並出現錯誤。

錯誤:

System.InvalidOperationException
{"Missing value for trigger parameter 'blobIinfo'."}

代碼:

public static void Main()
{
    var config = new JobHostConfiguration
    {
        NameResolver = new QueueNameResolver(),
        ServiceBusConnectionString = ApplicationSettings.ServiceBusConnectionString
    };
    var host = new JobHost(config);
    host.Call(typeof(BankLineFileProcessorWebJob).GetMethod("ProcessQueueMessage"));
}


[NoAutomaticTrigger]
public static void ProcessQueueMessage(
    TextWriter log,
    [ServiceBusTrigger("testsftppollingqueue")] SftpQueueMessage blobIinfo
    )
{
    while (true)
    {
        log.WriteLine("Queue message refers to blob: " + blobIinfo.BlobUri);
        Thread.Sleep(TimeSpan.FromMinutes(PollingInterval));
    }
}

誰能幫我解決這個問題?

謝謝

你必須使用

host.RunAndBlock();

代替

host.Call(typeof(BankLineFileProcessorWebJob).GetMethod("ProcessQueueMessage"));

另外,請去掉 NoAutomaticTrigger 屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM