- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有多个队列触发器的 .NET Azure 函数。我配置了 host.json 文件(见下文),该文件一次最多使 4 条消息出队。
{
"queues": {
"maxPollingInterval": "00:00:03",
"visibilityTimeout": "00:00:30",
"batchSize": 4,
"maxDequeueCount": 5,
"newBatchThreshold": 2,
"messageEncoding": "base64"
}
}
这对于所有触发器来说都很好,除了我需要一次出队 1 条消息的触发器。
是否可以在每个触发器的基础上覆盖“batchSize”属性?我的替代方案是将此触发器拆分为它自己的函数。
根据我的研究,一些人认为这在functions.json 文件中可能是可能的。但我没有functions.json 文件,所以不知道从哪里开始。
最佳答案
如果您想为特定队列触发器使不同的消息出队,您需要创建两个具有不同批量大小的单独函数,如下所示:-
我的消息队列:-
队列 1:
队列2:
代码:
function1.cs:
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class Function1
{
[FunctionName("QueueTriggerFunction1")]
public static void Run(
[QueueTrigger("kaqueue1", Connection = "AzureWebJobsStorage")] string myQueueItem,
ILogger log)
{
log.LogInformation($"Function1 processed: {myQueueItem}");
}
}
Function1/host.json:
{
"queues": {
"maxPollingInterval": "00:00:03",
"visibilityTimeout": "00:00:30",
"batchSize": 4,
"maxDequeueCount": 5,
"newBatchThreshold": 2,
"messageEncoding": "base64"
}
}
Function2/Function2.cs:
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class Function2
{
[FunctionName("QueueTriggerFunction2")]
public static void Run(
[QueueTrigger("kaqueue2", Connection = "AzureWebJobsStorage")] string myQueueItem,
ILogger log)
{
log.LogInformation($"Function2 processed: {myQueueItem}");
}
}
Function2/host.json:
{
"queues": {
"maxPollingInterval": "00:00:03",
"visibilityTimeout": "00:00:30",
"batchSize": 1,
"maxDequeueCount": 5,
"newBatchThreshold": 2,
"messageEncoding": "base64"
}
}
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<connec_string>",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
输出:
或者,您可以在 Function.cs 中使用以下代码动态设置批量大小:
消息队列:
代码:
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class MyQueueFunction
{
[FunctionName("MyQueueFunction")]
public static void Run([QueueTrigger("kaqueue", Connection = "AzureWebJobsStorage")] string message,
int dequeueCount,
ILogger log)
{
int batchSize = 4;
{
batchSize = 1;
}
log.LogInformation($"Processing message: {message} with batch size: {batchSize}");
for (int j = 0; j < batchSize; j++)
{
}
}
}
}
输出:
关于c# - 使用 Azure Function 队列为每个触发器设置 "batchSize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77243791/
首先我将解释我是如何理解和使用 @BatchSize 的:@BatchSize是为了批量加载对象关系,减少对数据库的SQL请求。这对于 LAZY @OneToMany 关系特别有用。 然而,它甚至对
hibernate 的@BatchSize 注释允许批量获取延迟加载的实体。例如。如果我得到类似的东西: public class Product { @OneToMany(fetchType
我在一些旧代码中发现了奇怪的东西(至少对我而言)。 注解为@ManyToOne 的字段也被注解为@BatchSize。 我一直认为 @BatchSize 注释只影响在类级别或集合上注释时 (@OneT
我有一个 user_batch 集合。它包含以下文件: [{ _id: ObjectId("594baf96256597ec035df23c"), name: "Batch 1", bat
使用 Dataflow CTP(在 TPL 中) 如果当前排队或推迟的项目数量小于 BatchSize,超时后是否可以自动调用 BatchBlock.TriggerBatch? 更好的是:每次 blo
我从网上和论坛上阅读了有关 BatchSize 的相关主题,但我仍然不明白某些部分。那么让我们描述一下我理解的内容和不理解的内容。 Batch fetching: an optimization st
我是 Hibernate 新手,但我对 @Batchsize 注释的工作有疑问。我理解它是如何工作的,但我不明白它如何对实体 id 进行分组以供选择。例如 - 我有 2 个类(class):汽车和车轮
Hibernate documentation在@BatchSize 中提供了一些信息: @BatchSize specifies a "batch size" for fetching instan
如何在定义了 batchSize 的情况下迭代游标批处理文档?例如,当 batchSize 定义为等于 50 时,有没有办法迭代这 50 个子文档? var myCursor = collection
我有一个 java jpa/hibernate 应用程序需要获取大量数据才能执行其任务。我遇到了 n+1 问题,所以我决定使用 hibernate.default_batch_fetch_size (
我将分页与 hibernate spring-data-jpa 和 querydsl 一起使用,并且我使用 @BatchSize(size=10) 只进行一次数据库往返。 @Entity @Table
我正在使用 pymongo 在一次查询中获取大约 2M 文档,每个文档仅包含三个字符串字段。查询只是一个简单的 find(),没有任何 limit() 或 batchSize()。 在遍历光标时,我注
我有一个带有多个队列触发器的 .NET Azure 函数。我配置了 host.json 文件(见下文),该文件一次最多使 4 条消息出队。 { "queues": { "max
这两者之间有不兼容吗? 我有一个n + 1我尝试使用专有的 hibernate @BatchSize 注释解决这个问题。 public class Master{ @OneToMany(fet
嗨,我使用 spring 数据来映射我的实体和存储库。映射非常简单: public class Car { Set parts; } public class Part { } 我使用 Spri
我每次迭代都使用来自一个非常大的文件的批处理来更新我的参数。但在执行此操作之前,我想将整个大型数据集拆分为测试和训练集。通过交叉验证,我想做同样的事情。 我曾尝试使用 dask 拆分整个集合,然后将一
以下查询返回我的所有用户。我本来希望它能分批进行。 statics.findAllUsers = function findAllUsers(callback) { this.find({}, c
我正在使用 Hibernate 4.2,我有一个包含子实体集合的父实体(一对多,获取类型为 LAZY 并用 @BatchSize(size=100) 注释). 如果我查询并加载几个父实体并调用访问包含
MongoDB 游标对象提供了一个 BatchSize 属性 and 和 Limit 属性,但我似乎找不到任何可以正确阐明的明确信息两者的区别。 我正在使用 .Net 驱动程序,物有所值。 最佳答案
使用 TensorFlow.js 定义模型后,您可以运行 model.fit()训练它。这个函数需要一些参数,包括一个配置对象。这个对象有一个属性 batchSize . documentation
我是一名优秀的程序员,十分优秀!