Azure功能中的MediaTr命令ServiceBustrigger
使用一些引用,我使用干净的体系结构创建了 azure函数应用程序
,项目结构看起来像这样:
“ nofollow noreferrer”> 。基本上,我想调用
MediaTr
命令 createProductCommand
此功能触发器内。因此,只要有消息将消息推入服务总线队列时,我就可以使用此 MediaTr
命令将其保存到SQL数据库中。 createProductCommand
具有EF核心实现。
public class SaveProductDataToDatabase
{
private readonly IMediator _mediator;
public SaveProductDataToDatabase(IMediator mediator)
{
_mediator = mediator;
}
[FunctionName("SaveProductDataToDatabase")]
public void Run([ServiceBusTrigger("product-data-dev-01", Connection = "ServiceBusConnectionString")] string myQueueItem, ILogger log)
{
log.LogInformation($"Processed message: {myQueueItem}");
}
}
我不确定如何在此功能触发器内使用 createProductCommand
。请帮忙。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在功能之上添加MediaTR命令处理程序是冗余的,因为功能本身已经是一个处理程序,并且是一小部分工作。函数通常负责将责任封装在功能代码中。除非您的功能有多个职责,否则不必要。
Adding MediatR command handler on top of a function is redundant as function is already a handler in itself and a small unit of work. A function has a single responsibility usually that responsibility is encapsulated in the function code. Unless your function has multiple responsibilities, which it shouldn’t, MediatR is unnecessary.