jms 消息存储机制

conf/activemq.xml配置文件里添加上如下配置:
<persistenceAdapter>    
<amqPersistenceAdapter directory="activemq-data" maxFileLength="32mb"/>   
 </persistenceAdapter>   


熟悉说明


property name                   default value     Comments 
 
directory                        activemq-data      存储消息文件和日志的目录 
 
useNIO                           true                使用 NIO 特性 
 
syncOnWrite                      false               同步写文件到磁盘 
 
maxFileLength                    32mb                 Message Data日志文件的最大 Size 
 
persistentIndex                  true                  持久化日志索引,如果设为 false ,则在内存中保存 
 
maxCheckpointMessageAddSize       4kb                  在自动提交前在事务中能保持的最大消息数 
 
cleanupInterval                  30000                每隔多少时间清理不再使用的消息日志(毫秒) 
 
indexBinSize                     1024                  这个值是用来提升索引的性能的,值越大,索引相对性能越好 
 
indexKeySize                     96                    index key的size,index key基于message id 
 
indexPageSize                    16kb                   索引页的size 
 
directoryArchive                 archive             消费完的Data Log存放的目录 
 
archiveDataLogs                   false              设置为true的话,消费完的Data Log就放到Archive目录,而不是删除。 
 



参考: http://www.360doc.com/content/10/0728/17/11586_42075045.shtml

为了防止丢消息,可以这样设定

<destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <virtualTopic name=">" prefix="VirtualTopicConsumers.*." selectorAware="false"/>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors>
        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" producerFlowControl="true" memoryLimit="200mb">
                  <pendingSubscriberPolicy>
                    <vmCursor />
                  </pendingSubscriberPolicy>
                </policyEntry>
                <policyEntry queue=">" producerFlowControl="true" memoryLimit="200mb">
                  <!-- Use VM cursor for better latency
                       For more information, see:
                       
                       http://activemq.apache.org/message-cursors.html
                       
                  <pendingQueuePolicy>
                    <vmQueueCursor/>
                  </pendingQueuePolicy>
                  -->
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>



注意:将topic转化为queue的方法
<destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <virtualTopic name=">" prefix="VirtualTopicConsumers.*." selectorAware="false"/>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors>


参考: http://activemq.apache.org/persistence.html
http://activemq.apache.org/virtual-destinations.html

代码体现
jms:queue:VirtualTopicConsumers.nmEncashQueue.encashend-topic

你可能感兴趣的:(jms)