/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { ConsumerInfo info = (ConsumerInfo)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeBoolean(info.isBrowser()); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); dataOut.writeInt(info.getPrefetchSize()); dataOut.writeInt(info.getMaximumPendingMessageLimit()); dataOut.writeBoolean(info.isDispatchAsync()); looseMarshalString(info.getSelector(), dataOut); looseMarshalString(info.getSubscriptionName(), dataOut); dataOut.writeBoolean(info.isNoLocal()); dataOut.writeBoolean(info.isExclusive()); dataOut.writeBoolean(info.isRetroactive()); dataOut.writeByte(info.getPriority()); looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut); dataOut.writeBoolean(info.isNetworkSubscription()); dataOut.writeBoolean(info.isOptimizedAcknowledge()); dataOut.writeBoolean(info.isNoRangeAcks()); } }
public void connectionInterruptProcessingComplete(Transport transport, ConnectionId connectionId) { ConnectionState connectionState = connectionStates.get(connectionId); if (connectionState != null) { connectionState.setConnectionInterruptProcessingComplete(true); Map<ConsumerId, ConsumerInfo> stalledConsumers = connectionState.getRecoveringPullConsumers(); for (Entry<ConsumerId, ConsumerInfo> entry: stalledConsumers.entrySet()) { ConsumerControl control = new ConsumerControl(); control.setConsumerId(entry.getKey()); control.setPrefetch(entry.getValue().getPrefetchSize()); control.setDestination(entry.getValue().getDestination()); try { if (LOG.isDebugEnabled()) { LOG.debug("restored recovering consumer: " + control.getConsumerId() + " with: " + control.getPrefetch()); } transport.oneway(control); } catch (Exception ex) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to submit control for consumer: " + control.getConsumerId() + " with: " + control.getPrefetch(), ex); } } } stalledConsumers.clear(); } }
public DurableTopicSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive) throws JMSException { super(broker, usageManager, context, info); this.pending = new StoreDurableSubscriberCursor(broker, context.getClientId(), info.getSubscriptionName(), info.getPrefetchSize(), this); this.pending.setSystemUsage(usageManager); this.pending.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); this.keepDurableSubsActive = keepDurableSubsActive; subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName()); }
if (pendingMessageLimitStrategy != null) { int value = pendingMessageLimitStrategy.getMaximumPendingMessageLimit(subscription); int consumerLimit = subscription.getInfo().getMaximumPendingMessageLimit(); if (consumerLimit > 0) { if (value < 0 || consumerLimit < value) { LOG.debug("Setting the maximumPendingMessages size to: {} for consumer: {}", value, subscription.getInfo().getConsumerId()); subscription.setMaximumPendingMessages(value); String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId(); int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize(); subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
/** * @param transport * @param sessionState * @throws IOException */ protected void restoreConsumers(Transport transport, SessionState sessionState) throws IOException { // Restore the session's consumers but possibly in pull only (prefetch 0 state) till recovery complete final ConnectionState connectionState = connectionStates.get(sessionState.getInfo().getSessionId().getParentId()); final boolean connectionInterruptionProcessingComplete = connectionState.isConnectionInterruptProcessingComplete(); for (ConsumerState consumerState : sessionState.getConsumerStates()) { ConsumerInfo infoToSend = consumerState.getInfo(); if (!connectionInterruptionProcessingComplete && infoToSend.getPrefetchSize() > 0) { infoToSend = consumerState.getInfo().copy(); connectionState.getRecoveringPullConsumers().put(infoToSend.getConsumerId(), consumerState.getInfo()); infoToSend.setPrefetchSize(0); if (LOG.isDebugEnabled()) { LOG.debug("restore consumer: " + infoToSend.getConsumerId() + " in pull mode pending recovery, overriding prefetch: " + consumerState.getInfo().getPrefetchSize()); } } if (LOG.isDebugEnabled()) { LOG.debug("consumer: " + infoToSend.getConsumerId()); } transport.oneway(infoToSend); } }
public void init(SlowConsumerDetectionListener slowConsumerDetectionListener, long nativeId) throws Exception { SimpleString selector = info.getSelector() == null ? null : new SimpleString(SelectorTranslator.convertToActiveMQFilterString(info.getSelector())); boolean preAck = false; if (info.isNoLocal()) { selector = new SimpleString(noLocalSelector); } else { selector = new SimpleString(info.getSelector() + " AND " + noLocalSelector); SimpleString queueName = createTopicSubscription(info.isDurable(), info.getClientId(), destinationName.toString(), info.getSubscriptionName(), selector, destinationName); if (addrSettings != null) { if (info.getPrefetchSize() != 0 && addrSettings.getQueuePrefetch() == 0) { cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(0); session.getConnection().dispatch(cc);
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { ConsumerInfo info = (ConsumerInfo)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeBoolean(info.isBrowser()); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); dataOut.writeInt(info.getPrefetchSize()); dataOut.writeInt(info.getMaximumPendingMessageLimit()); dataOut.writeBoolean(info.isDispatchAsync()); looseMarshalString(info.getSelector(), dataOut); looseMarshalString(info.getSubscriptionName(), dataOut); dataOut.writeBoolean(info.isNoLocal()); dataOut.writeBoolean(info.isExclusive()); dataOut.writeBoolean(info.isRetroactive()); dataOut.writeByte(info.getPriority()); looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut); dataOut.writeBoolean(info.isNetworkSubscription()); dataOut.writeBoolean(info.isOptimizedAcknowledge()); dataOut.writeBoolean(info.isNoRangeAcks()); } }
public void configure(Broker broker, SystemUsage memoryManager, TopicSubscription subscription) { int prefetch=subscription.getConsumerInfo().getPrefetchSize(); if (prefetch == ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH){ subscription.getConsumerInfo().setPrefetchSize(getTopicPrefetch()); int consumerLimit = subscription.getInfo().getMaximumPendingMessageLimit(); if (consumerLimit > 0) { if (value < 0 || consumerLimit < value) { LOG.debug("Setting the maximumPendingMessages size to: " + value + " for consumer: " + subscription.getInfo().getConsumerId()); String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId(); int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize(); subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
private void ackAdvisory(Message message) throws IOException { demandConsumerDispatched++; if (demandConsumerDispatched > (demandConsumerInfo.getPrefetchSize() * (configuration.getAdvisoryAckPercentage() / 100f))) { final MessageAck ack = new MessageAck(message, MessageAck.STANDARD_ACK_TYPE, demandConsumerDispatched); ack.setConsumerId(demandConsumerInfo.getConsumerId()); brokerService.getTaskRunnerFactory().execute(new Runnable() { @Override public void run() { try { remoteBroker.oneway(ack); } catch (IOException e) { LOG.warn("Failed to send advisory ack " + ack, e); } } }); demandConsumerDispatched = 0; } }
public void connectionInterruptProcessingComplete(Transport transport, ConnectionId connectionId) { ConnectionState connectionState = connectionStates.get(connectionId); if (connectionState != null) { connectionState.setConnectionInterruptProcessingComplete(true); Map<ConsumerId, ConsumerInfo> stalledConsumers = connectionState.getRecoveringPullConsumers(); for (Entry<ConsumerId, ConsumerInfo> entry: stalledConsumers.entrySet()) { ConsumerControl control = new ConsumerControl(); control.setConsumerId(entry.getKey()); control.setPrefetch(entry.getValue().getPrefetchSize()); control.setDestination(entry.getValue().getDestination()); try { if (LOG.isDebugEnabled()) { LOG.debug("restored recovering consumer: " + control.getConsumerId() + " with: " + control.getPrefetch()); } transport.oneway(control); } catch (Exception ex) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to submit control for consumer: " + control.getConsumerId() + " with: " + control.getPrefetch(), ex); } } } stalledConsumers.clear(); } }
public DurableTopicSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive) throws JMSException { super(broker, usageManager, context, info); this.pending = new StoreDurableSubscriberCursor(broker, context.getClientId(), info.getSubscriptionName(), info.getPrefetchSize(), this); this.pending.setSystemUsage(usageManager); this.pending.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); this.keepDurableSubsActive = keepDurableSubsActive; subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName()); }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { ConsumerInfo info = (ConsumerInfo)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeBoolean(info.isBrowser()); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); dataOut.writeInt(info.getPrefetchSize()); dataOut.writeInt(info.getMaximumPendingMessageLimit()); dataOut.writeBoolean(info.isDispatchAsync()); looseMarshalString(info.getSelector(), dataOut); looseMarshalString(info.getSubscriptionName(), dataOut); dataOut.writeBoolean(info.isNoLocal()); dataOut.writeBoolean(info.isExclusive()); dataOut.writeBoolean(info.isRetroactive()); dataOut.writeByte(info.getPriority()); looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut); dataOut.writeBoolean(info.isNetworkSubscription()); dataOut.writeBoolean(info.isOptimizedAcknowledge()); dataOut.writeBoolean(info.isNoRangeAcks()); } }
if (pendingMessageLimitStrategy != null) { int value = pendingMessageLimitStrategy.getMaximumPendingMessageLimit(subscription); int consumerLimit = subscription.getInfo().getMaximumPendingMessageLimit(); if (consumerLimit > 0) { if (value < 0 || consumerLimit < value) { LOG.debug("Setting the maximumPendingMessages size to: {} for consumer: {}", value, subscription.getInfo().getConsumerId()); subscription.setMaximumPendingMessages(value); String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId(); int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize(); subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
/** * @param transport * @param sessionState * @throws IOException */ protected void restoreConsumers(Transport transport, SessionState sessionState) throws IOException { // Restore the session's consumers but possibly in pull only (prefetch 0 state) till recovery complete final ConnectionState connectionState = connectionStates.get(sessionState.getInfo().getSessionId().getParentId()); final boolean connectionInterruptionProcessingComplete = connectionState.isConnectionInterruptProcessingComplete(); for (ConsumerState consumerState : sessionState.getConsumerStates()) { ConsumerInfo infoToSend = consumerState.getInfo(); if (!connectionInterruptionProcessingComplete && infoToSend.getPrefetchSize() > 0) { infoToSend = consumerState.getInfo().copy(); connectionState.getRecoveringPullConsumers().put(infoToSend.getConsumerId(), consumerState.getInfo()); infoToSend.setPrefetchSize(0); if (LOG.isDebugEnabled()) { LOG.debug("restore consumer: " + infoToSend.getConsumerId() + " in pull mode pending recovery, overriding prefetch: " + consumerState.getInfo().getPrefetchSize()); } } if (LOG.isDebugEnabled()) { LOG.debug("consumer: " + infoToSend.getConsumerId()); } transport.oneway(infoToSend); } }
public void connectionInterruptProcessingComplete(Transport transport, ConnectionId connectionId) { ConnectionState connectionState = connectionStates.get(connectionId); if (connectionState != null) { connectionState.setConnectionInterruptProcessingComplete(true); Map<ConsumerId, ConsumerInfo> stalledConsumers = connectionState.getRecoveringPullConsumers(); for (Entry<ConsumerId, ConsumerInfo> entry: stalledConsumers.entrySet()) { ConsumerControl control = new ConsumerControl(); control.setConsumerId(entry.getKey()); control.setPrefetch(entry.getValue().getPrefetchSize()); control.setDestination(entry.getValue().getDestination()); try { if (LOG.isDebugEnabled()) { LOG.debug("restored recovering consumer: " + control.getConsumerId() + " with: " + control.getPrefetch()); } transport.oneway(control); } catch (Exception ex) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to submit control for consumer: " + control.getConsumerId() + " with: " + control.getPrefetch(), ex); } } } stalledConsumers.clear(); } }
public DurableTopicSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive) throws JMSException { super(broker, usageManager, context, info); this.pending = new StoreDurableSubscriberCursor(broker, context.getClientId(), info.getSubscriptionName(), info.getPrefetchSize(), this); this.pending.setSystemUsage(usageManager); this.pending.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); this.keepDurableSubsActive = keepDurableSubsActive; subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName()); }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { ConsumerInfo info = (ConsumerInfo)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeBoolean(info.isBrowser()); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); dataOut.writeInt(info.getPrefetchSize()); dataOut.writeInt(info.getMaximumPendingMessageLimit()); dataOut.writeBoolean(info.isDispatchAsync()); looseMarshalString(info.getSelector(), dataOut); looseMarshalString(info.getSubscriptionName(), dataOut); dataOut.writeBoolean(info.isNoLocal()); dataOut.writeBoolean(info.isExclusive()); dataOut.writeBoolean(info.isRetroactive()); dataOut.writeByte(info.getPriority()); looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut); dataOut.writeBoolean(info.isNetworkSubscription()); dataOut.writeBoolean(info.isOptimizedAcknowledge()); dataOut.writeBoolean(info.isNoRangeAcks()); looseMarshalObjectArray(wireFormat, info.getNetworkConsumerPath(), dataOut); } }
if (pendingMessageLimitStrategy != null) { int value = pendingMessageLimitStrategy.getMaximumPendingMessageLimit(subscription); int consumerLimit = subscription.getInfo().getMaximumPendingMessageLimit(); if (consumerLimit > 0) { if (value < 0 || consumerLimit < value) { LOG.debug("Setting the maximumPendingMessages size to: {} for consumer: {}", value, subscription.getInfo().getConsumerId()); subscription.setMaximumPendingMessages(value); String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId(); int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize(); subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
/** * @param transport * @param sessionState * @throws IOException */ protected void restoreConsumers(Transport transport, SessionState sessionState) throws IOException { // Restore the session's consumers but possibly in pull only (prefetch 0 state) till recovery complete final ConnectionState connectionState = connectionStates.get(sessionState.getInfo().getSessionId().getParentId()); final boolean connectionInterruptionProcessingComplete = connectionState.isConnectionInterruptProcessingComplete(); for (ConsumerState consumerState : sessionState.getConsumerStates()) { ConsumerInfo infoToSend = consumerState.getInfo(); if (!connectionInterruptionProcessingComplete && infoToSend.getPrefetchSize() > 0) { infoToSend = consumerState.getInfo().copy(); connectionState.getRecoveringPullConsumers().put(infoToSend.getConsumerId(), consumerState.getInfo()); infoToSend.setPrefetchSize(0); if (LOG.isDebugEnabled()) { LOG.debug("restore consumer: " + infoToSend.getConsumerId() + " in pull mode pending recovery, overriding prefetch: " + consumerState.getInfo().getPrefetchSize()); } } if (LOG.isDebugEnabled()) { LOG.debug("consumer: " + infoToSend.getConsumerId()); } transport.oneway(infoToSend); } }
public void connectionInterruptProcessingComplete(Transport transport, ConnectionId connectionId) { ConnectionState connectionState = connectionStates.get(connectionId); if (connectionState != null) { connectionState.setConnectionInterruptProcessingComplete(true); Map<ConsumerId, ConsumerInfo> stalledConsumers = connectionState.getRecoveringPullConsumers(); for (Entry<ConsumerId, ConsumerInfo> entry: stalledConsumers.entrySet()) { ConsumerControl control = new ConsumerControl(); control.setConsumerId(entry.getKey()); control.setPrefetch(entry.getValue().getPrefetchSize()); control.setDestination(entry.getValue().getDestination()); try { if (LOG.isDebugEnabled()) { LOG.debug("restored recovering consumer: " + control.getConsumerId() + " with: " + control.getPrefetch()); } transport.oneway(control); } catch (Exception ex) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to submit control for consumer: " + control.getConsumerId() + " with: " + control.getPrefetch(), ex); } } } stalledConsumers.clear(); } }