首页 \ 问答 \ WebJob控制台应用程序中的ProcessQueueMessage函数(ProcessQueueMessage function in WebJob console app)

WebJob控制台应用程序中的ProcessQueueMessage函数(ProcessQueueMessage function in WebJob console app)

我正在创建一个新的控制台应用程序,我将在Azure上作为WebJob运行。 当我在Visual Studio中创建新应用程序时,它已经创建了一个Function.cs类,该类包含以下方法,该方法自动从队列中获取消息并对其进行处理。

public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
{
   log.WriteLine(message);
}

我的问题是如何更好地控制处理队列消息。 例如,我想确保处理和删除邮件。 这个方法似乎对我有用,但我怎么知道消息是否正确处理? 如果失败怎么办,怎么告诉它不要删除邮件呢?


I'm creating a new console app that I will run as a WebJob on Azure. When I created the new app in Visual Studio, it already created a Function.cs class that contains the following method which automatically picks up the message from my queue and processes it.

public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
{
   log.WriteLine(message);
}

My question is how do I have a bit more control over handling the queue message. For example, I 'd like to make sure the message is processed and deleted. This method seems to do all of that for me but how do I know if the message is processed correctly? What if it fails, how do I tell it not to delete the message?


原文:https://stackoverflow.com/questions/35052054
更新时间:2023-07-25 15:07

最满意答案

比在xrange(N)上循环更快的方法是:

import itertools

for _ in itertools.repeat(None, N):
    do_something()

A slightly faster approach than looping on xrange(N) is:

import itertools

for _ in itertools.repeat(None, N):
    do_something()

相关问答

更多
  • 这个答案基于Array.forEach ,没有任何库,只是原生的香草 。 基本上调用something() 3次,使用: [1,2,3].forEach(function(i) { something(); }); 为了完成这个问题,这里有一个方法可以分别调用something() 1,2和3次: 这是2017年,你可以使用ES6: [1,2,3].forEach(i => Array(i).fill(i).forEach(_ => { something() })) 或在旧的ES5: [1,2 ...
  • 是的,如果条件变量上的B和C都被阻塞,并且条件变量上没有其他线程被阻塞,那么保持互斥锁调用pthread_cond_signal()两次将保证(最终)将它们唤醒。 这直接来自POSIX中的要求: pthread_cond_signal()函数应解除阻塞在指定条件变量cond上阻塞的至少一个线程(如果在cond上阻塞了任何线程)。 第一次调用pthread_cond_signal()必须取消阻塞B和C中的至少一个,因为这些是条件变量上阻塞的唯一线程。 因为互斥量仍然由信令线程保持,所以在第二次调用pthrea ...
  • echo "cos(a)^3 +m1^4" | sed ' # encapsulate between + s/.*/+&+/ :a # For each power object /\^/!b end # isolate power object h s#\(.*[-+/*^]\)\([^-+/*^]*\)^\([0-9]\{1,2\}\)\(.*\)#\1\ \2\ \4# # isolate power value to convert it in useable reproducing fact ...
  • 比在xrange(N)上循环更快的方法是: import itertools for _ in itertools.repeat(None, N): do_something() A slightly faster approach than looping on xrange(N) is: import itertools for _ in itertools.repeat(None, N): do_something()
  • 使用模式fn n (x:xs) = ... ,表示x是列表中的第一个元素, xs是列表的其余部分。 您的case语句正在检查x是否为空列表,但模式匹配( (x:xs) )已经从列表中提取了它。 你想要的可能是其中之一(编译器知道它们是相同的,所以你使用哪一个是品味的问题): -- Version that uses a pattern match fn :: Int -> [a] -> [a] replicate' n x = take n (repeat x) fn _ [] = [] fn n (x:x ...
  • 您可以简单地使用list来迭代范围 : <#assign n = 5> <#list 0..hello 或者作为一个宏: <#macro repeat input times> <#list 0..${input} <@repeat input="hello" times=5/> You could simply use list to iterate a range: <#assign n = 5> <#li ...
  • 您编写的测试代码与本文中的示例代码不同。 在示例代码中,首先计算n % 2 ,并将结果传递给unless函数。 在那里,您正在对结果执行Logical Not操作。 如果n是偶数,则n % 2将从0传递到unless 。 布尔比较0返回false ,并且! 否定结果(逻辑上没有),所以!0 == true 。 反过来,这会导致then函数触发。 如果n是奇数,则发生相反的情况。 传递除0以外的某些值,其值为false ,从而导致不触发。 相反,您尝试在不使用高阶函数的情况下重现示例代码将不会以相同的方式工作 ...
  • 仅针对副本的隐藏元素,然后仅从克隆中删除该类: $('button').click(function() { $(".elements img.hidden").each(function() { var $this = $(this); if ($this.hasClass('image3')) { for (var i = 1; i < 3; i++) { $this.clone().removeClass('hidden').appendTo($this ...
  • 你需要打破这个问题(提醒我来自gg和fb的面试问题): 首先解决一个序列一个单一的位置 然后解决旋转序列N次 将每个“圆圈”或环形模型化为一个数组。 您可能或可能不需要存储在单独的数据中 迭代每个环并应用旋转算法 让我们考虑需要旋转R时间的长度为L的数组的情况。 请注意,如果R是L的倍数,则数组将保持不变。 也要注意,向右旋转x次与向左旋转L - x相同(反之亦然)。 因此,您可以首先设计一种算法,能够左右旋转一个正好一个位置 减少向左旋转R次的问题,以将R modulo L向左旋转 如果你想进一步减少旋转 ...
  • 此循环平均执行n / 2次: 在第一次迭代中,这将执行最多n-1次,因为j从1开始 在第二次迭代中,这最多执行n-2次,因为j从2开始 在第三次迭代中,这最多执行n-3次,因为j从3开始 ... 在最后一次迭代中,它执行零次,因为i + 1等于数组的长度。 如果你将第一行添加到最后一行,第二行从后面添加到第二行,从第三行添加到第三行,依此类推,每对将产生n-1; 对于n的偶数值,将存在n / 2个这样的对,因此循环在n上执行的平均次数是n / 2。 This loop executes n/2 times ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)