public synchronized TransportConnectionState lookupConnectionState(SessionId id) { TransportConnectionState cs = connectionState; if (cs == null) { throw new IllegalStateException( "Cannot lookup a session from a connection that had not been registered: " + id.getParentId()); } return cs; }
public synchronized TransportConnectionState lookupConnectionState(ProducerId id) { TransportConnectionState cs = connectionState; if (cs == null) { throw new IllegalStateException( "Cannot lookup a producer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
@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; }
public synchronized TransportConnectionState lookupConnectionState(ConsumerId id) { TransportConnectionState cs = connectionState; if (cs == null) { throw new IllegalStateException( "Cannot lookup a consumer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
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; }
@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(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; }
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; }
@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; }
@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; }
@Override public Response processRemoveProducer(ProducerId id) throws Exception { SessionId sessionId = id.getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); SessionState ss = cs.getSessionState(sessionId); if (ss == null) { throw new IllegalStateException("Cannot remove a producer from a session that had not been registered: " + sessionId); } ProducerState ps = ss.removeProducer(id); if (ps == null) { throw new IllegalStateException("Cannot remove a producer that had not been registered: " + id); } removeProducerBrokerExchange(id); broker.removeProducer(cs.getContext(), ps.getInfo()); return null; }
@Override public Response processAddSession(SessionInfo info) throws Exception { ConnectionId connectionId = info.getSessionId().getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); // Avoid replaying dup commands if (cs != null && !cs.getSessionIds().contains(info.getSessionId())) { broker.addSession(cs.getContext(), info); try { cs.addSession(info); } catch (IllegalStateException e) { LOG.warn("Failed to add session: {}", info.getSessionId(), e); broker.removeSession(cs.getContext(), info); } } return null; }
@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; }
@Override public Response processRemoveSession(SessionId id, long lastDeliveredSequenceId) throws Exception { ConnectionId connectionId = id.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) {
/** * @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); } }
@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; }
@Override public Response processAddProducer(ProducerInfo info) { if (info != null && info.getProducerId() != null) { SessionId sessionId = info.getProducerId().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.addProducer(info); if (info.isResponseRequired()) { return new Tracked(new ExceptionResponseCheckAction(info)); } } } } } } return TRACKED_RESPONSE_MARKER; }
@Override public Response processMessage(Message send) throws Exception { if (send != null) { if (trackTransactions && send.getTransactionId() != null) { ProducerId producerId = send.getProducerId(); ConnectionId connectionId = producerId.getParentId().getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { TransactionState transactionState = cs.getTransactionState(send.getTransactionId()); if (transactionState != null) { transactionState.addCommand(send); if (trackTransactionProducers) { // for jmstemplate, track the producer in case it is closed before commit // and needs to be replayed SessionState ss = cs.getSessionState(producerId.getParentId()); ProducerState producerState = ss.getProducerState(producerId); producerState.setTransactionState(transactionState); } } } } return TRACKED_RESPONSE_MARKER; }else if (trackMessages) { messageCache.put(send.getMessageId(), send); } } return null; }
@Override public Response processAddProducer(ProducerInfo info) throws Exception { SessionId sessionId = info.getProducerId().getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) {
@Override public Response processAddConsumer(ConsumerInfo info) throws Exception { SessionId sessionId = info.getConsumerId().getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) {