MQTT在ArtemisActiveMQ消息代理上保留消息

问题描述

我在Artemis broker中保留主题/消息时遇到问题。为了提高可用性,我想设置一个群集(热备用或其他功能)。为此,需要打开持久性。问题就出在这里:MQTT保留主题意味着代理保留每个主题的最后一条消息并交付给新的订阅客户端。仅最后一条消息是相关的。这是应该在节点之间的Artemis群集中同步的部分。

如何配置Artemis,使其保留(并保持同步),仅当主题中带有保留标记的最后一条消息存在时才保留。保留标志来自消息的发布者/生产者。

有一些配置开关,但主要是缓冲区大小,处理重新连接或丢弃消息和客户端

这是我的构想,希望是正确的部分:

<configuration xmlns="urn:activemq"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xi="http://www.w3.org/2001/XInclude"
           xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="urn:activemq:core ">
  <name>0.0.0.0</name>
  <persistence-enabled>true</persistence-enabled>
  <journal-type>ASYNCIO</journal-type>
  <journal-datasync>true</journal-datasync>
  <journal-min-files>100</journal-min-files>
  <journal-pool-files>1000</journal-pool-files>
  <journal-file-size>10M</journal-file-size>
  <journal-buffer-timeout>444000</journal-buffer-timeout>
  <journal-max-io>4096</journal-max-io>
  <disk-scan-period>10000</disk-scan-period>
  <max-disk-usage>95</max-disk-usage>
  <critical-analyzer>true</critical-analyzer>
  <critical-analyzer-timeout>120000</critical-analyzer-timeout>
  <critical-analyzer-check-period>60000</critical-analyzer-check-period>
  <critical-analyzer-policy>HALT</critical-analyzer-policy>
  <global-max-size>3221225472</global-max-size>  
  <acceptors>
    <acceptor name="mf1-netty-acceptor">tcp://0.0.0.0:18884?confirmationWindowSize=-1;clientFailureCheckPeriod=30000;consumerWindowSize=524288;tcpsendBufferSize=2097152;tcpReceiveBufferSize=2097152;protocols=MQTT;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor> 
    <acceptor name="ssl-acceptor">tcp://0.0.0.0:{{ ca_port }}?confirmationWindowSize=-1;clientFailureCheckPeriod=30000;consumerWindowSize=524288;tcpsendBufferSize=2097152;tcpReceiveBufferSize=2097152;sslEnabled=true;enabledProtocols=TLSv1,TLSv1.1,TLSv1.2;needClientAuth=true;keyStorePath={{ keystore_path }};keyStorePassword={{ key_trusstore_pw }};trustStorePath={{ truststore_path }};trustStorePassword={{ trusstore_pw }};protocols=MQTT</acceptor>
    <acceptor name="sync-acceptor">tcp://0.0.0.0:{{ sync_port }}?confirmationWindowSize=-1;clientFailureCheckPeriod=30000;consumerWindowSize=524288;tcpsendBufferSize=2097152;tcpReceiveBufferSize=2097152;protocols=CORE,AMQP,STOMP,hornetq,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
  </acceptors>
  <populate-validated-user>true</populate-validated-user>
  <security-settings>
     <security-setting match="#">
        <permission type="createNonDurableQueue" roles="admin"/>
        <permission type="deleteNonDurableQueue" roles="admin"/>
        <permission type="createDurableQueue" roles="admin"/>
        <permission type="deleteDurableQueue" roles="admin"/>
        <permission type="createAddress" roles="admin"/>
        <permission type="deleteAddress" roles="admin"/>
        <permission type="consume" roles="admin"/>
        <permission type="browse" roles="admin"/>
        <permission type="send" roles="admin"/>            
        <permission type="manage" roles="admin"/>
     </security-setting>
 </security-settings>
 <address-settings>         
     <address-setting match="activemq.management#">
        <dead-letter-address>DLQ</dead-letter-address>
        <expiry-address>ExpiryQueue</expiry-address>
        <redelivery-delay>0</redelivery-delay>
        <!-- with -1 only the global-max-size is in use for limiting 
        <max-size-bytes>-1</max-size-bytes> -->
        <message-counter-history-day-limit>10</message-counter-history-day-limit>
        <address-full-policy>PAGE</address-full-policy>
        <auto-create-queues>true</auto-create-queues>
        <auto-create-addresses>true</auto-create-addresses>
        <auto-create-jms-queues>true</auto-create-jms-queues>
        <auto-create-jms-topics>true</auto-create-jms-topics>            
        <redistribution-delay>0</redistribution-delay>                  
        <default-consumer-window-size>524288</default-consumer-window-size> 
        <auto-delete-addresses>true</auto-delete-addresses>
        <auto-delete-queues-message-count>-1</auto-delete-queues-message-count>
        <auto-delete-queues-delay>0</auto-delete-queues-delay>
        <auto-delete-created-queues>true</auto-delete-created-queues>
        <default-purge-on-no-consumers>true</default-purge-on-no-consumers>
        <max-size-bytes>10485760</max-size-bytes>  <!-- 10MB -->
        <page-size-bytes>1048576</page-size-bytes> <!-- 1MB -->
        <page-max-cache-size>2</page-max-cache-size> 
     </address-setting>
     <!--default for catch all-->
     <address-setting match="#">
        <dead-letter-address>DLQ</dead-letter-address>
        <expiry-address>ExpiryQueue</expiry-address>
        <redelivery-delay>0</redelivery-delay>
        <!-- with -1 only the global-max-size is in use for limiting 
        <max-size-bytes>-1</max-size-bytes> -->
        <message-counter-history-day-limit>10</message-counter-history-day-limit>
        <address-full-policy>PAGE</address-full-policy>
        <auto-create-queues>true</auto-create-queues>
        <auto-create-addresses>true</auto-create-addresses>
        <auto-create-jms-queues>true</auto-create-jms-queues>
        <auto-create-jms-topics>true</auto-create-jms-topics>            
        <redistribution-delay>0</redistribution-delay>
        <default-last-value-queue>true</default-last-value-queue> 
        <last-value-queue>true</last-value-queue> 
        <default-consumer-window-size>524288</default-consumer-window-size>  
        <auto-delete-addresses>true</auto-delete-addresses>                 
        <auto-delete-queues-message-count>-1</auto-delete-queues-message-count>
        <auto-delete-queues-delay>0</auto-delete-queues-delay>
        <auto-delete-created-queues>true</auto-delete-created-queues>
        <default-purge-on-no-consumers>true</default-purge-on-no-consumers>
        <max-size-bytes>10485760</max-size-bytes>  <!-- 10MB -->
        <page-size-bytes>1048576</page-size-bytes> <!-- 1MB -->
        <page-max-cache-size>2</page-max-cache-size> 
     </address-setting>
  </address-settings>     
  <addresses>
     <address name="#">
        <multicast>
            <queue name="." purge-on-no-consumers="true">
                <durable>false</durable>
            </queue>
        </multicast>
     </address>
     <address name="DLQ">
        <anycast>
           <queue name="DLQ" />
        </anycast>
     </address>
     <address name="ExpiryQueue">
        <anycast>
           <queue name="ExpiryQueue" />
        </anycast>
     </address>
  </addresses>
</core>
</configuration>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)