服务总线触发 azure webjob
service bus Trigger azure webjob
我创建了一个 azure webjob,它将向服务总线队列发送强类型消息并成功发送。
我想创建另一个 web 作业,只要服务总线队列中有消息,它就会被触发。请在下面找到我正在尝试的代码。出于某种原因,尽管服务总线队列中有消息,但当我在本地 运行 Web 作业时,Web 作业未被触发并出现错误。
错误:
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属性。
我创建了一个 azure webjob,它将向服务总线队列发送强类型消息并成功发送。
我想创建另一个 web 作业,只要服务总线队列中有消息,它就会被触发。请在下面找到我正在尝试的代码。出于某种原因,尽管服务总线队列中有消息,但当我在本地 运行 Web 作业时,Web 作业未被触发并出现错误。
错误:
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属性。