protected ProducerId createProducerId() { String id = idGenerator.generateId(); ConnectionId connectionId = new ConnectionId(id); SessionId sessionId = new SessionId(connectionId, 1); return new ProducerId(sessionId, 1); } }
public ProducerId(SessionId sessionId, long producerId) { this.connectionId = sessionId.getConnectionId(); this.sessionId = sessionId.getValue(); this.value = producerId; }
@Override public Response processAddSession(SessionInfo info) { if (info != null) { ConnectionId connectionId = info.getSessionId().getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { cs.addSession(info); } } } return TRACKED_RESPONSE_MARKER; }
public TransportConnectionState lookupConnectionState(SessionId id) { TransportConnectionState cs = lookupConnectionState(id.getConnectionId()); if (cs == null) { throw new IllegalStateException( "Cannot lookup a session from a connection that had not been registered: " + id.getParentId()); } return cs; }
/** * 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); SessionId info = (SessionId)o; info.setConnectionId(tightUnmarshalString(dataIn, bs)); info.setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); }
@Override public Response processAddConsumer(ConsumerInfo info) { if (info != null) { SessionId sessionId = info.getConsumerId().getParentId(); if (sessionId != null) { ConnectionId connectionId = sessionId.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { SessionState ss = cs.getSessionState(sessionId); if (ss != null) { ss.addConsumer(info); if (info.isResponseRequired()) { return new Tracked(new ExceptionResponseCheckAction(info)); } } } } } } return TRACKED_RESPONSE_MARKER; }
if (brokerConsumerDests.get(pair) == null) { ConnectionId connectionId = new ConnectionId(connectionIdGenerator.generateId()); SessionId sessionId = new SessionId(connectionId, sessionIdGenerator.getNextSequenceId()); ConsumerId consumerId = new ConsumerId(sessionId, consumerIdGenerator.getNextSequenceId()); info = new ConsumerInfo(consumerId); if(brokerConsumerDests.putIfAbsent(pair, info) == null) { LOG.debug("Virtual consumer pair added: {} for consumer: {} ", pair, info); setConsumerInfoVirtualDest(info, virtualDestination, activeMQDest); ActiveMQTopic topic = AdvisorySupport.getVirtualDestinationConsumerAdvisoryTopic(info.getDestination()); if (virtualDestinationConsumers.putIfAbsent(info, virtualDestination) == null) { LOG.debug("Virtual consumer added: {}, for virtual destination: {}", info, virtualDestination); fireConsumerAdvisory(context, info.getDestination(), topic, info);
@Override public Response processRemoveProducer(ProducerId id) { if (id != null) { SessionId sessionId = id.getParentId(); if (sessionId != null) { ConnectionId connectionId = sessionId.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { SessionState ss = cs.getSessionState(sessionId); if (ss != null) { ss.removeProducer(id); } } } } } return TRACKED_RESPONSE_MARKER; }
DurableTopicSubscription sub = durableSubscriptions.get(key); ConsumerInfo consumerInfo = createInactiveConsumerInfo(info); if (sub == null) { c.setBroker(context.getBroker()); c.setClientId(key.getClientId()); c.setConnectionId(consumerInfo.getConsumerId().getParentId().getParentId()); sub = (DurableTopicSubscription)createSubscription(c, consumerInfo); sub.setOfflineTimestamp(System.currentTimeMillis()); durableSubscriptions.values(); for (DurableTopicSubscription sub : durableSubscriptions.values()) {
@Override public Response processRemoveSession(SessionId id, long lastDeliveredSequenceId) { if (id != null) { ConnectionId connectionId = id.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { cs.removeSession(id); } } } return TRACKED_RESPONSE_MARKER; }
@Override public Response processRemoveConsumer(ConsumerId id, long lastDeliveredSequenceId) { if (id != null) { SessionId sessionId = id.getParentId(); if (sessionId != null) { ConnectionId connectionId = sessionId.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { SessionState ss = cs.getSessionState(sessionId); if (ss != null) { ss.removeConsumer(id); } cs.getRecoveringPullConsumers().remove(id); } } } } return TRACKED_RESPONSE_MARKER; }
/** * @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); } }
BrokerId[] path = info.getBrokerPath(); if (info.isBrowser()) { LOG.debug("{} Ignoring sub from {}, browsers explicitly suppressed", configuration.getBrokerName(), remoteBrokerName); return; if (!isPermissableDestination(info.getDestination())) { tempDest.setConnectionId(localSessionInfo.getSessionId().getConnectionId()); for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) { DemandSubscription ds = i.next(); boolean removed = ds.removeForcedDurableConsumer(id); final boolean proxyBridgeSub = isProxyBridgeSubscription(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) { DemandSubscription ds = i.next(); boolean removed = ds.getDurableRemoteSubs().remove(subscriptionInfo);
SessionId sessionId = new SessionId(info.getConnectionId(), -1); ConsumerInfo info = new ConsumerInfo(new ConsumerId(sessionId, consumerIdGenerator.getNextSequenceId())); info.setDestination(ActiveMQMessageTransformation.transformDestination(topic)); info.setSubscriptionName(subscriptionName); info.setSelector(messageSelector); info.setPrefetchSize(maxMessages);
@Override public Response processAddConsumer(ConsumerInfo info) throws Exception { SessionId sessionId = info.getConsumerId().getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) { if (!ss.getConsumerIds().contains(info.getConsumerId())) { ActiveMQDestination destination = info.getDestination(); if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) { if (getConsumerCount(connectionId) >= connector.getMaximumConsumersAllowedPerConnection()){
public TransportConnectionState lookupConnectionState(ConsumerId id) { TransportConnectionState cs = lookupConnectionState(id.getConnectionId()); if (cs == null) { throw new IllegalStateException( "Cannot lookup a consumer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
@Override public Response processRemoveConsumer(ConsumerId id, long lastDeliveredSequenceId) throws Exception { SessionId sessionId = id.getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) { throw new IllegalStateException("Cannot remove a consumer from a connection that had not been registered: " + connectionId); } SessionState ss = cs.getSessionState(sessionId); if (ss == null) { throw new IllegalStateException("Cannot remove a consumer from a session that had not been registered: " + sessionId); } ConsumerState consumerState = ss.removeConsumer(id); if (consumerState == null) { throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id); } ConsumerInfo info = consumerState.getInfo(); info.setLastDeliveredSequenceId(lastDeliveredSequenceId); broker.removeConsumer(cs.getContext(), consumerState.getInfo()); removeConsumerBrokerExchange(id); return null; }
public Response processAddConsumer(ConsumerInfo info) { if (info != null) { SessionId sessionId = info.getConsumerId().getParentId(); if (sessionId != null) { ConnectionId connectionId = sessionId.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { SessionState ss = cs.getSessionState(sessionId); if (ss != null) { ss.addConsumer(info); } } } } } return TRACKED_RESPONSE_MARKER; }
public TransportConnectionState lookupConnectionState(ProducerId id) { TransportConnectionState cs = lookupConnectionState(id.getConnectionId()); if (cs == null) { throw new IllegalStateException( "Cannot lookup a producer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
/** * Returns the SessionInfo bean. * * @return info - SessionInfo bean. * @throws JMSException */ protected SessionInfo getSessionInfo() throws JMSException { SessionInfo info = new SessionInfo(connection.getConnectionInfo(), getSessionId().getValue()); return info; }