Refine search
@Override public void onException(IOException error) { if (failed.compareAndSet(false, true)) { stopMonitorThreads(); if (sendLock.writeLock().isHeldByCurrentThread()) { sendLock.writeLock().unlock(); } transportListener.onException(error); } }
transportListener.transportInterupted(); updated.remove(failedConnectTransportURI); reconnectTask.wakeup(); } else if (!isDisposed()) {
public void onCommand(Object command) { try { getTransportListener().onCommand((Command)localWireFormat.unmarshal(remoteWireFormat.marshal(command))); } catch (IOException e) { getTransportListener().onException(e); } }
/** * @see org.apache.activemq.thread.Task#iterate() */ @Override public boolean iterate() { final TransportListener tl = transportListener; LinkedBlockingQueue<Object> mq; try { mq = getMessageQueue(); } catch (TransportDisposedIOException e) { return false; } Object command = mq.poll(); if (command != null && !disposed.get()) { try { tl.onCommand(command); } catch (Exception e) { try { peer.transportListener.onException(IOExceptionSupport.create(e)); } catch (Exception ignore) { } } return !mq.isEmpty() && !disposed.get(); } else { if(disposed.get()) { mq.clear(); } return false; } }
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(final Object o) { final Command command = (Command)o; if (!closed.get() && command != null) { try { command.visit(new CommandVisitorAdapter() { @Override public Response processMessageDispatch(MessageDispatch md) throws Exception { for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { TransportListener listener = iter.next(); listener.onCommand(command);
if (disposed.compareAndSet(false, true)) { peer.transportListener.onCommand(new ShutdownInfo()); } catch (Exception ignore) { peer.transportListener.onException(new TransportDisposedIOException("peer (" + this + ") stopped.")); } catch (Exception ignore) {
@Override public void run() { transportFailed(error); ServiceSupport.dispose(ActiveMQConnection.this.transport); brokerInfoReceived.countDown(); try { doCleanup(true); } catch (JMSException e) { LOG.warn("Exception during connection cleanup, " + e, e); } for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { TransportListener listener = iter.next(); listener.onException(error); } } });
@Override public void transportResumed() { for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { TransportListener listener = iter.next(); listener.transportResumed(); } }
@Override public void transportInterupted() { transportInterruptionProcessingComplete.set(1); for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();) { ActiveMQSession s = i.next(); s.clearMessagesInProgress(transportInterruptionProcessingComplete); } for (ActiveMQConnectionConsumer connectionConsumer : this.connectionConsumers) { connectionConsumer.clearMessagesInProgress(transportInterruptionProcessingComplete); } if (transportInterruptionProcessingComplete.decrementAndGet() > 0) { if (LOG.isDebugEnabled()) { LOG.debug("transport interrupted - processing required, dispatchers: " + transportInterruptionProcessingComplete.get()); } signalInterruptionProcessingNeeded(); } for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { TransportListener listener = iter.next(); listener.transportInterupted(); } }
transport.setTransportListener(createTransportListener(transport)); transport.start(); transportListener.transportResumed(); } else { LOG.debug("transport resumed by transport listener not set"); if (transport != null) { try { transport.stop(); transport = null; } catch (Exception ee) {
LOG.debug("tx replay producer :" + producerState.getInfo()); transport.oneway(producerState.getInfo()); LOG.debug("tx replay: " + command); transport.oneway(command); LOG.debug("tx remove replayed producer :" + producerState.getInfo()); transport.oneway(producerState.getInfo().createRemoveCommand()); response.setException(new TransactionRolledBackException("Transaction completion in doubt due to failover. Forcing rollback of " + command.getTransactionId())); response.setCorrelationId(command.getCommandId()); transport.getTransportListener().onCommand(response);
if (command.isShutdownInfo()) { if (command instanceof RemoveInfo || command.isMessageAck()) { response.setCorrelationId(command.getCommandId()); myTransportListener.onCommand(response); return; transport.oneway(command); stateTracker.trackBack(command); } catch (IOException e) {
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
protected void sendToActiveMQ(Command command, Handler<Response> handler) { command.setCommandId(generateCommandId()); if (handler != null) { command.setResponseRequired(true); responseHandlers.put(command.getCommandId(), handler); } transport.getTransportListener().onCommand(command); }
private void processCommand(Object incoming) { Command command = (Command) incoming; if (command == null) { return; } if (command.isResponse()) { Object object = null; synchronized (requestMap) { object = requestMap.remove(Integer.valueOf(((Response) command).getCorrelationId())); } if (object != null && object.getClass() == Tracked.class) { ((Tracked) object).onResponses(command); } } if (command.isConnectionControl()) { handleConnectionControl((ConnectionControl) command); } else if (command.isConsumerControl()) { ConsumerControl consumerControl = (ConsumerControl)command; if (consumerControl.isClose()) { stateTracker.processRemoveConsumer(consumerControl.getConsumerId(), RemoveInfo.LAST_DELIVERED_UNKNOWN); } } if (transportListener != null) { transportListener.onCommand(command); } }
public void onCommand(Object o) { Command command = (Command)o; if (command.isWireFormatInfo()) { WireFormatInfo info = (WireFormatInfo)command; negociate(info); } getTransportListener().onCommand(command); }
@Override public void onException(IOException error) { try { synchronized (reconnectMutex) { if (transport == null || !transport.isConnected()) { return; } LOG.debug("Transport failed, starting up reconnect task", error); ServiceSupport.dispose(transport); transport = null; connectedCount--; if (primary == this) { primary = null; } reconnectTask.wakeup(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); if (transportListener != null) { transportListener.onException(new InterruptedIOException()); } } } }
@Override @After public void tearDown() throws Exception { try { if (flowControlConnection != null) { TcpTransport t = flowControlConnection.getTransport().narrow(TcpTransport.class); try { flowControlConnection.getTransport().stop(); flowControlConnection.close(); } catch (Throwable ignored) { // sometimes the disposed up can make the test to fail // even worse I have seen this breaking every single test after this // if not caught here } t.getTransportListener().onException(new IOException("Disposed.")); } if (asyncThread != null) { asyncThread.join(); asyncThread = null; } } finally { super.tearDown(); } }