private void cleanUpChildren() throws ActiveMQException { Set<ClientConsumerInternal> consumersClone = cloneConsumers(); for (ClientConsumerInternal consumer : consumersClone) { consumer.cleanUp(); } Set<ClientProducerInternal> producersClone = cloneProducers(); for (ClientProducerInternal producer : producersClone) { producer.cleanUp(); } }
private byte getByte(final long index) { checkForPacket(index); if (fileCache != null && index < packetPosition) { return fileCache.getByteFromCache(index); } else { return currentPacket.getChunk()[(int) (index - packetPosition)]; } }
@Override public ClientSession createSession(final boolean autoCommitSends, final boolean autoCommitAcks, final int ackBatchSize) throws ActiveMQException { return createSessionInternal(null, null, false, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), ackBatchSize); }
@Override public ClientSession createSession(final boolean xa, final boolean autoCommitSends, final boolean autoCommitAcks) throws ActiveMQException { return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize()); }
/** * @param message * @throws ActiveMQException */ private void flowControlBeforeConsumption(final ClientMessageInternal message) throws ActiveMQException { // Chunk messages will execute the flow control while receiving the chunks if (message.getFlowControlSize() != 0) { // on large messages we should discount 1 on the first packets as we need continuity until the last packet flowControl(message.getFlowControlSize(), !message.isLargeMessage()); } }
@Override public synchronized void cleanUp(boolean failingOver) throws ActiveMQException { if (closed) { return; } synchronized (producerCreditManager) { producerCreditManager.close(); } cleanUpChildren(); doCleanup(failingOver); }
@Override public synchronized void handleMessage(final ClientMessageInternal message) throws Exception { if (closing) { // This is ok - we just ignore the message return; } if (message.getBooleanProperty(Message.HDR_LARGE_COMPRESSED)) { handleCompressedMessage(message); } else { handleRegularMessage(message); } }
@Override public ClientLargeMessageImpl setOutputStream(final OutputStream out) throws ActiveMQException { if (writableBuffer != null) { super.setOutputStream(out); } else { largeMessageController.setOutputStream(out); } return this; }
@Override public boolean waitOutputStreamCompletion(final long timeMilliseconds) throws ActiveMQException { if (writableBuffer != null) { return super.waitOutputStreamCompletion(timeMilliseconds); } else { return largeMessageController.waitCompletion(timeMilliseconds); } }
@Override public void handleReceiveMessage(final ConsumerContext consumerID, final ClientMessageInternal message) throws Exception { ClientConsumerInternal consumer = getConsumer(consumerID); if (consumer != null) { consumer.handleMessage(message); } }
@Override public void individualAcknowledge(ClientMessage message) throws ActiveMQException { if (lastAckedMessage != null) { flushAcks(); } session.individualAcknowledge(this, message); }
@Override public int getEncodeSize() { if (writableBuffer != null) { return super.getEncodeSize(); } else { return DataConstants.SIZE_INT + DataConstants.SIZE_INT + getHeadersAndPropertiesEncodeSize(); } }
@Override public void saveToOutputStream(final OutputStream out) throws ActiveMQException { if (writableBuffer != null) { // The body was rebuilt on the client, so we need to behave as a regular message on this case super.saveToOutputStream(out); } else { largeMessageController.saveBuffer(out); } }
@Override public void discardBody() { if (writableBuffer != null) { super.discardBody(); } else { largeMessageController.discardUnusedPackets(); } }
private ClientSessionInternal getSessionInternalFromXAResource(final XAResource xares) { if (xares == null) { return null; } if (xares instanceof ClientSessionInternal) { return (ClientSessionInternal) xares; } else if (xares instanceof ActiveMQXAResource) { return getSessionInternalFromXAResource(((ActiveMQXAResource) xares).getResource()); } return null; }
@Override public void receiveCredits(int credits) { synchronized (this) { super.receiveCredits(credits); balance += credits; callback.onCreditsFlow(balance <= 0, this); } }
@Override public ClientSession createSession(final boolean xa, final boolean autoCommitSends, final boolean autoCommitAcks, final boolean preAcknowledge) throws ActiveMQException { return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, preAcknowledge, serverLocator.getAckBatchSize()); }
@Override public void receiveFailCredits(final int credits) { super.receiveFailCredits(credits); callback.onCreditsFail(this); }
private ClientProducerCredits build(SimpleString address) { if (callback != null) { return new AsynchronousProducerCreditsImpl(session, address, windowSize, callback); } else { return new ClientProducerCreditsImpl(session, address, windowSize); } }
@Override public ClientSession createSession(final boolean autoCommitSends, final boolean autoCommitAcks) throws ActiveMQException { return createSessionInternal(null, null, false, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize()); }