public void doCleanup() { long now = System.currentTimeMillis(); for (Map.Entry<SubscriptionKey, DurableTopicSubscription> entry : durableSubscriptions.entrySet()) { DurableTopicSubscription sub = entry.getValue(); if (!sub.isActive()) { long offline = sub.getOfflineTimestamp(); if (offline != -1 && now - offline >= broker.getBrokerService().getOfflineDurableSubscriberTimeout()) { LOG.info("Destroying durable subscriber due to inactivity: {}", sub); try { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(entry.getKey().getClientId()); info.setSubscriptionName(entry.getKey().getSubscriptionName()); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(entry.getKey().getClientId()); removeSubscription(context, info); } catch (Exception e) { LOG.error("Failed to remove inactive durable subscriber", e); } } } } }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setSubscriptionName(looseUnmarshalString(dataIn)); info.setClientId(looseUnmarshalString(dataIn)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setSubscriptionName(looseUnmarshalString(dataIn)); info.setClientId(looseUnmarshalString(dataIn)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setSubscriptionName(looseUnmarshalString(dataIn)); info.setClientId(looseUnmarshalString(dataIn)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setSubscriptionName(looseUnmarshalString(dataIn)); info.setClientId(looseUnmarshalString(dataIn)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setSubscriptionName(looseUnmarshalString(dataIn)); info.setClientId(looseUnmarshalString(dataIn)); }
/** * Destroys the durable subscription so that messages will no longer be * stored for this subscription */ public void destroy() throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriptionName); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
@Override public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriberName); ConnectionContext context = getConnectionContext(); context.setBroker(safeGetBroker()); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
/** * Destroys the durable subscription so that messages will no longer be * stored for this subscription */ @Override public void destroy() throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriptionInfo.getSubscriptionName()); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
private void cleanupDurableSub(final DemandSubscription ds, Iterator<DemandSubscription> i) throws IOException { if (ds != null && ds.getLocalDurableSubscriber() != null && ds.getDurableRemoteSubs().isEmpty() && ds.getForcedDurableConsumersSize() == 0) { // deactivate subscriber RemoveInfo removeInfo = new RemoveInfo(ds.getLocalInfo().getConsumerId()); localBroker.oneway(removeInfo); // remove subscriber RemoveSubscriptionInfo sending = new RemoveSubscriptionInfo(); sending.setClientId(localClientId); sending.setSubscriptionName(ds.getLocalDurableSubscriber().getSubscriptionName()); sending.setConnectionId(this.localConnectionInfo.getConnectionId()); localBroker.oneway(sending); //remove subscriber from map i.remove(); } }
/** * Unsubscribes a durable subscription that has been created by a client. * <P> * This method deletes the state being maintained on behalf of the * subscriber by its provider. * <P> * It is erroneous for a client to delete a durable subscription while there * is an active <CODE>MessageConsumer </CODE> or * <CODE>TopicSubscriber</CODE> for the subscription, or while a consumed * message is part of a pending transaction or has not been acknowledged in * the session. * * @param name the name used to identify this subscription * @throws JMSException if the session fails to unsubscribe to the durable * subscription due to some internal error. * @throws InvalidDestinationException if an invalid subscription name is * specified. * @since 1.1 */ public void unsubscribe(String name) throws InvalidDestinationException, JMSException { checkClosedOrFailed(); RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo(); rsi.setConnectionId(getConnectionInfo().getConnectionId()); rsi.setSubscriptionName(name); rsi.setClientId(getConnectionInfo().getClientId()); syncSendPacket(rsi); }
sending.setSubscriptionName(subName); sending.setConnectionId(this.localConnectionInfo.getConnectionId()); localBroker.oneway(sending);
/** * Destroys the durable subscription so that messages will no longer be * stored for this subscription */ public void destroy() throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriptionName); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
@Override public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriberName); ConnectionContext context = getConnectionContext(); context.setBroker(safeGetBroker()); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }
@Override public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(clientId); info.setSubscriptionName(subscriberName); ConnectionContext context = getConnectionContext(); context.setBroker(safeGetBroker()); context.setClientId(clientId); brokerService.getBroker().removeSubscription(context, info); }