【问题标题】:How delete Inactive destinations in ActiveMQ?如何删除 ActiveMQ 中的非活动目的地?
【发布时间】:2018-01-30 16:23:47
【问题描述】:

我需要配置 activemq 来删除非活动队列:

如下使用 websocket 进行配置

@Configuration
@EnableWebSocketMessageBroker 
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

      @Override
        public void configureMessageBroker(MessageBrokerRegistry config) {


          config.setApplicationDestinationPrefixes("/app")
            .setUserDestinationPrefix("/user")
            .enableStompBrokerRelay("/topic","/queue","/user")
            .setRelayHost("localhost")
            .setRelayPort(61613);


        }


        public void registerStompEndpoints(StompEndpointRegistry registry) {
            registry.addEndpoint("/websocket").withSockJS();
        }


}

如何在 spring boot 中添加以下destinationPolicy?这部分如何导入?

  <destinationPolicy>
     <policyMap>
        <policyEntries>
           <policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000"/>
        </policyEntries>
     </policyMap>
  </destinationPolicy>

</broker>

【问题讨论】:

    标签: spring-boot activemq stomp spring-websocket


    【解决方案1】:

    将此 bean 定义添加到您的配置中

    @Bean
    public BrokerService broker() throws Exception {
        BrokerService broker = new BrokerService();
        broker.setSchedulePeriodForDestinationPurge(10000);
        broker.addConnector("stomp://localhost:61613");
        PolicyMap policyMap = new PolicyMap();
        PolicyEntry policyEntry = new PolicyEntry();
        policyEntry.setGcInactiveDestinations(true);
        policyEntry.setInactiveTimeoutBeforeGC(30000);
        policyEntry.setQueue(">");
        List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
        entries.add(policyEntry);
        policyMap.setPolicyEntries(entries);
        broker.setDestinationPolicy(policyMap);
        return broker;
    }
    

    并验证您是否拥有这些依赖项

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-activemq</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-stomp</artifactId>
    </dependency>
    

    【讨论】:

    • 活动 MQ 中还有可用队列吗?行政观点?如您所知,它是嵌入式 MQ
    • JMX 与 visualvm ?默认情况下它被激活
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多