packet.setChannelID(id); final ActiveMQBuffer buffer = packet.encode(connection); if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet); while (!closed && (response == null || (response.getType() != PacketImpl.EXCEPTION && response.getType() != expectedPacket)) && toWait > 0) { try { sendCondition.await(toWait, TimeUnit.MILLISECONDS); if (response != null && response.getType() != PacketImpl.EXCEPTION && response.getType() != expectedPacket) { ActiveMQClientLogger.LOGGER.packetOutOfOrder(response, new Exception("trace")); throw ActiveMQClientMessageBundle.BUNDLE.timedOutSendingPacket(connection.getBlockingCallTimeout(), packet.getType()); if (response.getType() == PacketImpl.EXCEPTION) { final ActiveMQExceptionMessage mem = (ActiveMQExceptionMessage) response;
@Override public Packet decode(final ActiveMQBuffer in, CoreRemotingConnection connection) { final byte packetType = in.readByte(); Packet packet = decode(packetType, connection); packet.decode(in); return packet; }
private void doBufferReceived(final Packet packet) { if (ChannelImpl.invokeInterceptors(packet, incomingInterceptors, this) != null) { return; } synchronized (transferLock) { final Channel channel = channels.get(packet.getChannelID()); if (channel != null) { channel.handlePacket(packet); } } }
@Override public void confirm(final Packet packet) { if (resendCache != null && packet.isRequiresConfirmations()) { lastConfirmedCommandID.incrementAndGet(); if (logger.isTraceEnabled()) { logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::confirming packet " + packet + " last commandID=" + lastConfirmedCommandID); } receivedBytes += packet.getPacketSize(); if (receivedBytes >= confWindowSize) { receivedBytes = 0; final Packet confirmed = new PacketsConfirmedMessage(lastConfirmedCommandID.get()); confirmed.setChannelID(id); doWrite(confirmed); } } }
private void sendPacketWithoutLock(final Channel parameterChannel, final Packet packet) { packet.setChannelID(parameterChannel.getID()); Connection conn = parameterChannel.getConnection().getTransportConnection(); ActiveMQBuffer buffer = packet.encode(this.getCoreConnection()); conn.write(buffer, false, false); }
@Override public void handlePacket(final Packet packet) { if (packet.getType() == PacketImpl.PACKETS_CONFIRMED) { if (resendCache != null) { final PacketsConfirmedMessage msg = (PacketsConfirmedMessage) packet; clearUpTo(msg.getCommandID()); } if (!connection.isClient()) { handler.handlePacket(packet); } return; } else { if (packet.isResponse()) { confirm(packet); lock.lock(); try { response = packet; sendCondition.signal(); } finally { lock.unlock(); } } else if (handler != null) { handler.handlePacket(packet); } } }
packet.setChannelID(id); if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { packet.setCorrelationID(responseAsyncCache.nextCorrelationID()); ActiveMQBuffer buffer = packet.encode(connection); if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet); if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { while (!responseAsyncCache.add(packet)) { try { if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { responseAsyncCache.remove(packet.getCorrelationID());
public static boolean isMessagePacket(Packet packet) { int type = packet.getType(); return type == PacketImpl.SESS_SEND || type == PacketImpl.SESS_SEND_LARGE || type == PacketImpl.SESS_RECEIVE_LARGE_MSG || type == PacketImpl.SESS_RECEIVE_MSG; }
packet.setChannelID(id); ActiveMQBuffer buffer = packet.encode(connection); if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet);
private static Packet convertToExceptionPacket(Packet packet, ActiveMQException e) { Packet response; if (packet.isResponseAsync()) { response = new ActiveMQExceptionMessage_V2(packet.getCorrelationID(), e); } else { response = new ActiveMQExceptionMessage(e); } return response; }
@Override public synchronized void flushConfirmations() { if (resendCache != null && receivedBytes != 0) { receivedBytes = 0; final Packet confirmed = new PacketsConfirmedMessage(lastConfirmedCommandID.get()); confirmed.setChannelID(id); if (logger.isTraceEnabled()) { logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::flushConfirmation flushing confirmation " + confirmed); } doWrite(confirmed); } }
private void doWrite(final Packet packet) { final ActiveMQBuffer buffer = packet.encode(connection); connection.getTransportConnection().write(buffer, false, false); }
@Override public int sendLargeMessage(MessageReference ref, Message message, ServerConsumer consumer, long bodySize, int deliveryCount) { Packet packet = new SessionReceiveLargeMessage(consumer.getID(), message, bodySize, deliveryCount); channel.send(packet); int size = packet.getPacketSize(); return size; }
public boolean add(Packet packet) { this.store.put(packet.getCorrelationID(), packet); return true; }
public void handleAsyncResponse(Packet packet) { if (responseAsyncCache != null && packet.isResponseAsync()) { responseAsyncCache.handleResponse(packet); } }
packet.setChannelID(id); if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { packet.setCorrelationID(responseAsyncCache.nextCorrelationID()); ActiveMQBuffer buffer = packet.encode(connection); if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet); if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { while (!responseAsyncCache.add(packet)) { try { if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { responseAsyncCache.remove(packet.getCorrelationID());
@Override public void confirm(final Packet packet) { if (resendCache != null && packet.isRequiresConfirmations()) { lastConfirmedCommandID.incrementAndGet(); if (logger.isTraceEnabled()) { logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::confirming packet " + packet + " last commandID=" + lastConfirmedCommandID); } receivedBytes += packet.getPacketSize(); if (receivedBytes >= confWindowSize) { receivedBytes = 0; final Packet confirmed = new PacketsConfirmedMessage(lastConfirmedCommandID.get()); confirmed.setChannelID(id); doWrite(confirmed); } } }
@Override public void commandConfirmed(final Packet packet) { if (packet.getType() == PacketImpl.SESS_SEND) { SessionSendMessage ssm = (SessionSendMessage) packet; callSendAck(ssm.getHandler(), ssm.getMessage()); } else if (packet.getType() == PacketImpl.SESS_SEND_CONTINUATION) { SessionSendContinuationMessage scm = (SessionSendContinuationMessage) packet; if (!scm.isContinues()) { callSendAck(scm.getHandler(), scm.getMessage()); } } }
@Override public void handlePacket(final Packet packet) { if (packet.getType() == PacketImpl.PACKETS_CONFIRMED) { if (resendCache != null) { final PacketsConfirmedMessage msg = (PacketsConfirmedMessage) packet; clearUpTo(msg.getCommandID()); } if (!connection.isClient()) { handler.handlePacket(packet); } return; } else { if (packet.isResponse()) { confirm(packet); lock.lock(); try { response = packet; sendCondition.signal(); } finally { lock.unlock(); } } else if (handler != null) { handler.handlePacket(packet); } } }
packet.setChannelID(id); ActiveMQBuffer buffer = packet.encode(connection); if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet);