2
votes

I have created a azure webjob which will send a strongly typed message to a service bus queue and it successfully sends.

I want to create another webjob which should be triggered whenever there is a message in the servicebus queue. Please find below the code i am trying. For some reason, though there are messages in the servicebus queue, the webjob is not getting triggered and getting an error when i run the webjob locally.

Error:

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

Code:

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

Can anyone help me how to solve this?

Thanks

2

2 Answers

1
votes

You have to use

host.RunAndBlock();

instead of

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

Also, please take out the NoAutomaticTrigger attribute.