@SuppressWarnings("unchecked") protected synchronized void trySendingMessages(ChannelHandlerContext ctx) { while (queue.size() > 0) { // Get the RequestItem that is up next in the queue. PlcRequestContainer currentItem = (PlcRequestContainer) queue.current(); InternalPlcRequest request = currentItem.getRequest(); // Send the TPDU. try { ChannelFuture channelFuture = queue.removeAndWrite(); ctx.flush(); if (channelFuture == null) { break; } } catch (Exception e) { LOGGER.error("Error sending more queues messages", e); ctx.fireExceptionCaught(e); } if (request instanceof CorrelatedPlcRequest) { CorrelatedPlcRequest correlatedPlcRequest = (CorrelatedPlcRequest) request; // Add it to the list of sentButUnacknowledgedSubContainer. sentButUnacknowledgedSubContainer.put(correlatedPlcRequest.getTdpu(), currentItem); LOGGER.debug("container with id {} sent: ", correlatedPlcRequest.getTdpu(), currentItem); } } ctx.flush(); }
private synchronized void trySendingMessages(ChannelHandlerContext ctx) { while(sentButUnacknowledgedTpdus.size() < maxAmqCaller) { DataTpdu curTpdu = (DataTpdu) queue.current();