use of org.apache.activemq.artemis.spi.core.remoting.Connection in project activemq-artemis by apache.
the class ClientSessionFactoryImpl method establishNewConnection.
protected RemotingConnection establishNewConnection() {
Connection transportConnection = createTransportConnection();
if (transportConnection == null) {
if (ClientSessionFactoryImpl.logger.isTraceEnabled()) {
logger.trace("Neither backup or live were active, will just give up now");
}
return null;
}
RemotingConnection newConnection = clientProtocolManager.connect(transportConnection, callTimeout, callFailoverTimeout, incomingInterceptors, outgoingInterceptors, new SessionFactoryTopologyHandler());
newConnection.addFailureListener(new DelegatingFailureListener(newConnection.getID()));
schedulePing();
if (logger.isTraceEnabled()) {
logger.trace("returning " + newConnection);
}
return newConnection;
}
use of org.apache.activemq.artemis.spi.core.remoting.Connection in project activemq-artemis by apache.
the class NettyConnector method close.
@Override
public synchronized void close() {
if (channelClazz == null) {
return;
}
if (batchFlusherFuture != null) {
batchFlusherFuture.cancel(false);
flusher.cancel();
flusher = null;
batchFlusherFuture = null;
}
bootstrap = null;
channelGroup.close().awaitUninterruptibly();
// Shutdown the EventLoopGroup if no new task was added for 100ms or if
// 3000ms elapsed.
group.shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS);
channelClazz = null;
for (Connection connection : connections.values()) {
listener.connectionDestroyed(connection.getID());
}
connections.clear();
}
use of org.apache.activemq.artemis.spi.core.remoting.Connection in project activemq-artemis by apache.
the class CertificateUtil method getPeerPrincipalFromConnection.
public static Principal getPeerPrincipalFromConnection(RemotingConnection remotingConnection) {
Principal result = null;
if (remotingConnection != null) {
Connection transportConnection = remotingConnection.getTransportConnection();
if (transportConnection instanceof NettyConnection) {
NettyConnection nettyConnection = (NettyConnection) transportConnection;
ChannelHandler channelHandler = nettyConnection.getChannel().pipeline().get("ssl");
if (channelHandler != null && channelHandler instanceof SslHandler) {
SslHandler sslHandler = (SslHandler) channelHandler;
try {
result = sslHandler.engine().getSession().getPeerPrincipal();
} catch (SSLPeerUnverifiedException ignored) {
}
}
}
}
return result;
}
use of org.apache.activemq.artemis.spi.core.remoting.Connection in project activemq-artemis by apache.
the class NettyAcceptor method stop.
@Override
public synchronized void stop() {
if (channelClazz == null) {
return;
}
if (protocolHandler != null) {
protocolHandler.close();
}
if (batchFlusherFuture != null) {
batchFlusherFuture.cancel(false);
flusher.cancel();
flusher = null;
batchFlusherFuture = null;
}
// serverChannelGroup has been unbound in pause()
if (serverChannelGroup != null) {
serverChannelGroup.close().awaitUninterruptibly();
}
if (channelGroup != null) {
ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly();
if (!future.isSuccess()) {
ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
for (Channel channel : future.group()) {
if (channel.isActive()) {
ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress());
}
}
}
}
// Shutdown the EventLoopGroup if no new task was added for 100ms or if
// 3000ms elapsed.
eventLoopGroup.shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS);
eventLoopGroup = null;
channelClazz = null;
for (Connection connection : connections.values()) {
listener.connectionDestroyed(connection.getID());
}
connections.clear();
if (notificationService != null) {
TypedProperties props = new TypedProperties();
props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host));
props.putIntProperty(new SimpleString("port"), port);
Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props);
try {
notificationService.sendNotification(notification);
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.failedToSendNotification(e);
}
}
paused = false;
}
use of org.apache.activemq.artemis.spi.core.remoting.Connection in project activemq-artemis by apache.
the class InVMAcceptor method stop.
@Override
public synchronized void stop() {
if (!started) {
return;
}
if (!paused) {
InVMRegistry.instance.unregisterAcceptor(id);
}
for (Connection connection : connections.values()) {
listener.connectionDestroyed(connection.getID());
}
connections.clear();
if (notificationService != null) {
TypedProperties props = new TypedProperties();
props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(InVMAcceptorFactory.class.getName()));
props.putIntProperty(new SimpleString("id"), id);
Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props);
try {
notificationService.sendNotification(notification);
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.failedToSendNotification(e);
}
}
started = false;
paused = false;
}
Aggregations