How to create a durable consumer (subscriber) in Masstransit using ActiveMQ as transport?

huangapple go评论51阅读模式
英文:

How to create a durable consumer (subscriber) in Masstransit using ActiveMQ as transport?

问题

I've translated the code-related part for you:

我正在为一个更大的应用程序建立基础,并希望确保设置正确。我习惯于使用Azure Service Bus和一些RabbitMQ,但不熟悉ActiveMQ和Masstransit。尽管看起来是一个不错的组合,但是相关的文档和示例项目似乎并不多。

您是否有关于如何使接收端持久化,以便在从主题发布时将消息存储在磁盘上的提示/建议?

我已经在接收端附近并接近传输配置(ActiveMQ Artemis)上进行了一些尝试:

services.AddMassTransit(busConfigurator =>
{
//var entryAssembly = Assembly.GetExecutingAssembly();
//busConfigurator.AddConsumers(entryAssembly);

busConfigurator.AddConsumer<JournalHasBeenViewedMessageConsumer>(typeof(JournalHasBeenViewedMessageConsumer), (consumeConfig) =>
{
});

busConfigurator.UsingActiveMq((context, cfg) =>
{
    cfg.Host("localhost", 61616, h =>
    {
        h.Username("admin");
        h.Password("admin");
    });

    cfg.EnableArtemisCompatibility();

    // 这里是正确的地方吗?

    cfg.ConfigureEndpoints(context);
});

});

上面的代码中,我注册了一个消费者。如何使其持久化?根据[MassTransit文档][1],它应该在某个地方:

> MassTransit包括多个接收端级别的配置选项,控制接收端的行为...
>
>| 属性    | 类型  | 描述                                       |
>| ------- | ----- | ------------------------------------------ |
>| Durable | bool  | 如果为true,则在确认之前将消息持久化到磁盘(默认值:true) |

[1]: https://masstransit.io/documentation/configuration/transports/activemq

This translation focuses on the code and relevant technical details.

英文:

I'm setting up the foundation for a larger application and want to make the setup correct. I am used to Azure Service Bus and some RabbitMQ but not ActiveMQ and Masstransit. Seems like a good combo though, BUT not that much documentation or example projects out there.

Do you have a hint/ tips on how to make receiving endpoints durable so that message are stored on disc when published from Topic.

I have somehow figured out that it should be configured on receiving end and close to Transport configuration (ActiveMQ Artemis):

services.AddMassTransit(busConfigurator =&gt;
{
    //var entryAssembly = Assembly.GetExecutingAssembly();
    //busConfigurator.AddConsumers(entryAssembly);

    busConfigurator.AddConsumer&lt;JournalHasBeenViewedMessageConsumer&gt;(typeof(JournalHasBeenViewedMessageConsumer), (consumeConfig) =&gt;
    {
    });

    busConfigurator.UsingActiveMq((context, cfg) =&gt;
    {
        cfg.Host(&quot;localhost&quot;, 61616, h =&gt;
        {
            h.Username(&quot;admin&quot;);
            h.Password(&quot;admin&quot;);
        });

        cfg.EnableArtemisCompatibility();

        // Here right?

        cfg.ConfigureEndpoints(context);
    });
});

Above code that I register one of the consumers. How do I make this durable? According to MassTransit docs it should be somewhere:

> MassTransit includes several receive endpoint level configuration options that control receive endpoint behavior...
>
>| Property | Type | Description |
>| -------- | -------------- | ------ |
>| Durable | bool | If true, messages are persisted to disk before being acknowledged (default: true) |

答案1

得分: 1

MassTransit在ActiveMQ上的接收端点默认是持久的,不需要额外操作。

英文:

MassTransit receive endpoints on ActiveMQ are durable by default, nothing special needs to be done.

huangapple
  • 本文由 发表于 2023年6月27日 20:50:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76565042.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定