use of org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection in project activemq-artemis by apache.
the class ReplicationTest method testConnectIntoNonBackup.
@Test
public void testConnectIntoNonBackup() throws Exception {
setupServer(false);
try {
ClientSessionFactory sf = createSessionFactory(locator);
manager = new ReplicationManager((CoreRemotingConnection) sf.getConnection(), sf.getServerLocator().getCallTimeout(), sf.getServerLocator().getCallTimeout(), factory);
addActiveMQComponent(manager);
manager.start();
Assert.fail("Exception was expected");
} catch (ActiveMQNotConnectedException nce) {
// ok
} catch (ActiveMQException expected) {
fail("Invalid Exception type:" + expected.getType());
}
}
use of org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection in project activemq-artemis by apache.
the class ActiveMQSessionContext method sendSessionSendContinuationMessage.
private static int sendSessionSendContinuationMessage(Channel channel, Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, SendAcknowledgementHandler messageHandler) throws ActiveMQException {
final boolean requiresResponse = lastChunk && sendBlocking;
final SessionSendContinuationMessage chunkPacket = new SessionSendContinuationMessage(msgI, chunk, !lastChunk, requiresResponse, messageBodySize, messageHandler);
final int expectedEncodeSize = chunkPacket.expectedEncodeSize();
// perform a weak form of flow control to avoid OOM on tight loops
final CoreRemotingConnection connection = channel.getConnection();
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 elapsedFlowControl = endFlowControl - startFlowControl;
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 (requiresResponse) {
// When sending it blocking, only the last chunk will be blocking.
channel.sendBlocking(chunkPacket, PacketImpl.NULL_RESPONSE);
} else {
channel.send(chunkPacket);
}
return chunkPacket.getPacketSize();
} catch (Throwable e) {
throw new ActiveMQException(e.getMessage());
}
}
use of org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection in project activemq-artemis by apache.
the class RemotingServiceImpl method freeze.
@Override
public synchronized void freeze(final String scaleDownNodeID, final CoreRemotingConnection connectionToKeepOpen) {
if (!started)
return;
failureCheckAndFlushThread.close(false);
HashMap<Object, ConnectionEntry> connectionEntries = new HashMap<>(connections);
// complete then send a disconnect packet
for (Entry<Object, ConnectionEntry> entry : connectionEntries.entrySet()) {
RemotingConnection conn = entry.getValue().connection;
if (conn.equals(connectionToKeepOpen))
continue;
if (logger.isTraceEnabled()) {
logger.trace("Sending connection.disconnection packet to " + conn);
}
if (!conn.isClient()) {
conn.disconnect(scaleDownNodeID, false);
removeConnection(entry.getKey());
}
}
}
Aggregations