如何从持久主题订阅退订 [英] How to unsubscribe from durable topic subscription

查看:835
本文介绍了如何从持久主题订阅退订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用践踏的WebSockets连接到服务器的ActiveMQ,我extjs5浏览器的Web应用程序有许多主题订阅范围,以面板。

Using Stomp WebSockets to connect to an ActiveMQ server, my extjs5 browser webapp has numerous topic subscriptions scoped to panels.

下面是一个主题订阅与头部的例子:

Here is an example of a topic subscription with headers:

var sub = this.mqClient.subscribe('/topic/Status', this.onStatusMsg, 
{"ack":"auto","persistent":true,"activemq.retroactive":true,"selector":"TaskId = 1531","activemq.subscriptionName":"status-1531"} );

当用户与一个主题订阅完成,她将关闭其触发this.mqClient.unsubscribe(分)呼叫面板

When the user is done with a topic subscription, she closes the panel which triggers an this.mqClient.unsubscribe( sub ) call.

重新打开面板创建了一个相同的activemq.subscriptionName触发这个错误响应订阅:

Reopening that panel creates a subscription with an identical activemq.subscriptionName which triggers this error response:

javax.jms.JMSException: Durable consumer is in use for client: 2015-05-28 15:29:32-0700.0.9276173142716289 and subscriptionName: status-1531
    at org.apache.activemq.broker.region.TopicRegion.addConsumer(TopicRegion.java:127)
    at org.apache.activemq.broker.region.RegionBroker.addConsumer(RegionBroker.java:427)
    at org.apache.activemq.broker.jmx.ManagedRegionBroker.addConsumer(ManagedRegionBroker.java:244)
    at org.apache.activemq.broker.BrokerFilter.addConsumer(BrokerFilter.java:102)
    at org.apache.activemq.advisory.AdvisoryBroker.addConsumer(AdvisoryBroker.java:104)
    at org.apache.activemq.broker.BrokerFilter.addConsumer(BrokerFilter.java:102)
    at org.apache.activemq.broker.BrokerFilter.addConsumer(BrokerFilter.java:102)
    at org.apache.activemq.broker.MutableBrokerFilter.addConsumer(MutableBrokerFilter.java:107)
    at org.apache.activemq.broker.TransportConnection.processAddConsumer(TransportConnection.java:667)
    at org.apache.activemq.command.ConsumerInfo.visit(ConsumerInfo.java:348)
    at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:335)
    at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:189)
    at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:270)
    at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
    at org.apache.activemq.transport.ws.jetty8.StompSocket.sendToActiveMQ(StompSocket.java:125)
    at org.apache.activemq.transport.stomp.ProtocolConverter.sendToActiveMQ(ProtocolConverter.java:199)
    at org.apache.activemq.transport.stomp.ProtocolConverter.onStompSubscribe(ProtocolConverter.java:663)
    at org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:257)
    at org.apache.activemq.transport.ws.jetty8.StompSocket.onMessage(StompSocket.java:82)
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameHandler.onFrame(WebSocketConnectionRFC6455.java:850)
    at org.eclipse.jetty.websocket.WebSocketParserRFC6455.parseNext(WebSocketParserRFC6455.java:349)
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455.handle(WebSocketConnectionRFC6455.java:225)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:745)

如何关闭持久主题订阅?

How do I close a durable topic subscription?

推荐答案

在STOMP删除长期订阅是一个两步的过程,如果订阅是当前活动(即用户连接,目前认购)。

Removing a durable subscription in STOMP is a two step process if the subscription is currently active (meaning the subscriber is connected and subscribed currently).

首先,客户端必须取消,这样的认购变为无效:

First the client must unsubscribe so that the subscription becomes inactive:

String frame = "UNSUBSCRIBE\n" + "destination:/topic/MyTopic" + "\n\n" + Stomp.NULL;

现在,认购无效它可以永久如下发出带有最初用于创建它的订阅名称退订被删除:

Now that the subscription is inactive it can be removed permanently by issuing an unsubscribe with the subscription name originally used to create it as follows:

String frame = "UNSUBSCRIBE\n" + "destination:/topic/MyTopic" + "\n" + "activemq.subscriptionName:MySubscriptionName\n\n" + Stomp.NULL;

这将删除订阅和所有存储它从ActiveMQ消息店举行的消息。

This will remove the subscription and all stored messages that it held from the ActiveMQ message store.

这篇关于如何从持久主题订阅退订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆