private Channel getCreateChannel() { return getCoreConnection().getChannel(1, -1); }
final long blockingCallTimeoutMillis = Math.max(0, connection.getBlockingCallTimeout()); final long startFlowControl = System.nanoTime(); try { final boolean isWritable = connection.blockUntilWritable(expectedEncodeSize, blockingCallTimeoutMillis); if (!isWritable) { final long endFlowControl = System.nanoTime(); final long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(elapsedFlowControl); ActiveMQClientLogger.LOGGER.timeoutStreamingLargeMessage(); logger.debug("try to write " + expectedEncodeSize + " bytes after blocked " + elapsedMillis + " ms on a not writable connection: [" + connection.getID() + "]");
if (oldConnection != null && oldConnection instanceof CoreRemotingConnection) { ((CoreRemotingConnection)connection).setChannelVersion(((CoreRemotingConnection)oldConnection).getChannelVersion());
logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending packet nonblocking " + packet + " on channelID=" + id); waitForFailOver("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " timed-out waiting for fail-over condition on non-blocking send"); logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Writing buffer for channelID=" + id); connection.getTransportConnection().write(buffer, flush, batch); return true;
final boolean requiresResponse = lastChunk && sendBlocking; final SessionSendContinuationMessage chunkPacket; if (sessionChannel.getConnection().isVersionBeforeAsyncResponseChange()) { chunkPacket = new SessionSendContinuationMessage(msgI, chunk, !lastChunk, requiresResponse, messageBodySize, messageHandler); } else { final long blockingCallTimeoutMillis = Math.max(0, connection.getBlockingCallTimeout()); final long startFlowControl = System.nanoTime(); try { final boolean isWritable = connection.blockUntilWritable(expectedEncodeSize, blockingCallTimeoutMillis); if (!isWritable) { final long endFlowControl = System.nanoTime(); final long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(elapsedFlowControl); ActiveMQClientLogger.LOGGER.timeoutStreamingLargeMessage(); logger.debug("try to write " + expectedEncodeSize + " bytes after blocked " + elapsedMillis + " ms on a not writable connection: [" + connection.getID() + "]");
((CoreRemotingConnection) connection).syncIDGeneratorSequence(((CoreRemotingConnection) oldConnection).getIDGeneratorSequence());
List<CloseListener> closeListeners = remotingConnection.removeCloseListeners(); List<FailureListener> failureListeners = remotingConnection.removeFailureListeners(); newConnection.syncIDGeneratorSequence(remotingConnection.getIDGeneratorSequence()); Connection oldTransportConnection = remotingConnection.getTransportConnection(); remotingConnection.setCloseListeners(closeListeners); remotingConnection.setFailureListeners(failureListeners);
@Override public void createAddress(SimpleString address, EnumSet<RoutingType> routingTypes, final boolean autoCreated) throws ActiveMQException { CreateAddressMessage request = new CreateAddressMessage(address, routingTypes, autoCreated, true); if (!sessionChannel.getConnection().isVersionBeforeAddressChange()) { sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE); } }
default boolean isVersionBeforeAddressChange() { int version = getChannelVersion(); return (version > 0 && version < PacketImpl.ADDRESSING_CHANGE_VERSION); }
logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " interceptionResult=" + interceptionResult); logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " closed."); if (connection.getBlockingCallTimeout() == -1) { if (logger.isTraceEnabled()) { logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Cannot do a blocking call timeout on a server side connection"); waitForFailOver("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " timed-out waiting for fail-over condition on blocking send"); logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending blocking " + packet); connection.getTransportConnection().write(buffer, false, false); long toWait = connection.getBlockingCallTimeout(); throw ActiveMQClientMessageBundle.BUNDLE.timedOutSendingPacket(connection.getBlockingCallTimeout(), packet.getType());
private void doWrite(final Packet packet) { final ActiveMQBuffer buffer = packet.encode(connection); connection.getTransportConnection().write(buffer, false, false); }
if (connection.getChannelVersion() == 0) { connection.setChannelVersion(request.getVersion()); } else if (connection.getChannelVersion() != request.getVersion()) { ActiveMQServerLogger.LOGGER.incompatibleVersionAfterConnect(request.getVersion(), connection.getChannelVersion()); Channel channel = connection.getChannel(request.getSessionChannelID(), request.getWindowSize()); activeMQPrincipal = connection.getDefaultActiveMQPrincipal();
sessionChannel.getConnection().setChannelVersion(response.getServerVersion()); return newSessionContext(name, confirmationWindowSize, sessionChannel, response);
protected ActiveMQBuffer createPacket(CoreRemotingConnection connection) { int size = expectedEncodeSize(); if (connection == null) { return new ChannelBufferWrapper(Unpooled.buffer(size)); } else { return connection.createTransportBuffer(size); } }
/** * @param timeoutMsg message to log on blocking call failover timeout */ private void waitForFailOver(String timeoutMsg) { try { if (connection.getBlockingCallFailoverTimeout() < 0) { while (failingOver) { failoverCondition.await(); } } else if (!ConcurrentUtil.await(failoverCondition, connection.getBlockingCallFailoverTimeout())) { logger.debug(timeoutMsg); } } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } }
private SessionSendMessage decodeSessionSendMessage(final ActiveMQBuffer in, CoreRemotingConnection connection) { final SessionSendMessage sendMessage; if (connection.isVersionBeforeAddressChange()) { sendMessage = new SessionSendMessage_1X(new CoreMessage(this.coreMessageObjectPools)); } else if (connection.isVersionBeforeAsyncResponseChange()) { sendMessage = new SessionSendMessage(new CoreMessage(this.coreMessageObjectPools)); } else { sendMessage = new SessionSendMessage_V2(new CoreMessage(this.coreMessageObjectPools)); } sendMessage.decode(in); return sendMessage; }
channel0.getConnection().setChannelVersion(((SubscribeClusterTopologyUpdatesMessageV2) msg).getClientVersion()); acceptorUsed.getClusterConnection().addClusterTopologyListener(listener); rc.addCloseListener(new CloseListener() { @Override public void connectionClosed() {
/** * This was written as a refactoring of sendReplicatePacket. * In case you refactor this in any way, this method must hold a lock on replication lock. . */ private boolean flowControl(int size) { boolean flowWorked = replicatingChannel.getConnection().blockUntilWritable(size, timeout); if (!flowWorked) { try { ActiveMQServerLogger.LOGGER.slowReplicationResponse(); stop(); } catch (Exception e) { logger.warn(e.getMessage(), e); } } return flowWorked; }
final boolean requiresResponse = lastChunk && sendBlocking; final SessionSendContinuationMessage chunkPacket; if (sessionChannel.getConnection().isVersionBeforeAsyncResponseChange()) { chunkPacket = new SessionSendContinuationMessage(msgI, chunk, !lastChunk, requiresResponse, messageBodySize, messageHandler); } else { final long blockingCallTimeoutMillis = Math.max(0, connection.getBlockingCallTimeout()); final long startFlowControl = System.nanoTime(); try { final boolean isWritable = connection.blockUntilWritable(expectedEncodeSize, blockingCallTimeoutMillis); if (!isWritable) { final long endFlowControl = System.nanoTime(); final long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(elapsedFlowControl); ActiveMQClientLogger.LOGGER.timeoutStreamingLargeMessage(); logger.debug("try to write " + expectedEncodeSize + " bytes after blocked " + elapsedMillis + " ms on a not writable connection: [" + connection.getID() + "]");
((CoreRemotingConnection) connection).syncIDGeneratorSequence(((CoreRemotingConnection) oldConnection).getIDGeneratorSequence());