private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }
@Override public void run() { future.run(); } });
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void flushExecutor() { // Wait for any create objects runnable to complete FutureLatch future = new FutureLatch(); executor.execute(future); boolean ok = future.await(10000); if (!ok) { ActiveMQServerLogger.LOGGER.timedOutWaitingToStopBridge(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { FullHttpResponse response = (FullHttpResponse) msg; if (httpRequiresSessionId && !active) { final List<String> setCookieHeaderValues = response.headers().getAll(HttpHeaderNames.SET_COOKIE); for (String setCookieHeaderValue : setCookieHeaderValues) { final Cookie cookie = ClientCookieDecoder.LAX.decode(setCookieHeaderValue); if ("JSESSIONID".equals(cookie.name())) { this.cookie = setCookieHeaderValue; break; } } active = true; handShakeFuture.run(); } waitingGet = false; ctx.fireChannelRead(response.content()); }
private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void run() { future.run(); } });
private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void run() { future.run(); } });
private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void run() { future.run(); } });
private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }
@Override public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } } } ByteBuf buf = (ByteBuf) msg; FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf); httpRequest.headers().add(HttpHeaderNames.HOST, NettyConnector.this.host); if (cookie != null) { httpRequest.headers().add(HttpHeaderNames.COOKIE, cookie); } httpRequest.headers().add(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } }
@Override public void run() { future.run(); } });
private void waitForOnMessageToComplete(boolean waitForOnMessage) { if (handler == null) { return; } if (!waitForOnMessage || Thread.currentThread() == onMessageThread) { // If called from inside onMessage then return immediately - otherwise would block return; } FutureLatch future = new FutureLatch(); sessionExecutor.execute(future); boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS); if (!ok) { ActiveMQClientLogger.LOGGER.timeOutWaitingForProcessing(); } }