Search in sources :

Example 6 with ProducerAck

use of org.apache.activemq.command.ProducerAck in project activemq-artemis by apache.

the class ProducerAckTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ProducerAck info = (ProducerAck) object;
    info.setProducerId(createProducerId("ProducerId:1"));
    info.setSize(1);
}
Also used : ProducerAck(org.apache.activemq.command.ProducerAck)

Example 7 with ProducerAck

use of org.apache.activemq.command.ProducerAck in project activemq-artemis by apache.

the class ProducerAckTest method createObject.

@Override
public Object createObject() throws Exception {
    ProducerAck info = new ProducerAck();
    populateObject(info);
    return info;
}
Also used : ProducerAck(org.apache.activemq.command.ProducerAck)

Example 8 with ProducerAck

use of org.apache.activemq.command.ProducerAck in project activemq-artemis by apache.

the class ProducerAckTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ProducerAck info = (ProducerAck) object;
    info.setProducerId(createProducerId("ProducerId:1"));
    info.setSize(1);
}
Also used : ProducerAck(org.apache.activemq.command.ProducerAck)

Example 9 with ProducerAck

use of org.apache.activemq.command.ProducerAck in project activemq-artemis by apache.

the class AMQSession method sendShouldBlockProducer.

private void sendShouldBlockProducer(final ProducerInfo producerInfo, final Message messageSend, final boolean sendProducerAck, final PagingStore store, final ActiveMQDestination dest, final AtomicInteger count, final org.apache.activemq.artemis.api.core.Message coreMsg, final SimpleString address) throws ResourceAllocationException {
    if (!store.checkMemory(() -> {
        Exception exceptionToSend = null;
        try {
            getCoreSession().send(coreMsg, false, dest.isTemporary());
        } catch (Exception e) {
            logger.warn(e.getMessage(), e);
            exceptionToSend = e;
        }
        connection.enableTtl();
        if (count == null || count.decrementAndGet() == 0) {
            if (exceptionToSend != null) {
                this.connection.getContext().setDontSendReponse(false);
                connection.sendException(exceptionToSend);
            } else {
                server.getStorageManager().afterCompleteOperations(new IOCallback() {

                    @Override
                    public void done() {
                        if (sendProducerAck) {
                            try {
                                ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
                                connection.dispatchAsync(ack);
                            } catch (Exception e) {
                                connection.getContext().setDontSendReponse(false);
                                ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
                                connection.sendException(e);
                            }
                        } else {
                            connection.getContext().setDontSendReponse(false);
                            try {
                                Response response = new Response();
                                response.setCorrelationId(messageSend.getCommandId());
                                connection.dispatchAsync(response);
                            } catch (Exception e) {
                                ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
                                connection.sendException(e);
                            }
                        }
                    }

                    @Override
                    public void onError(int errorCode, String errorMessage) {
                        try {
                            final IOException e = new IOException(errorMessage);
                            ActiveMQServerLogger.LOGGER.warn(errorMessage);
                            connection.serviceException(e);
                        } catch (Exception ex) {
                            ActiveMQServerLogger.LOGGER.debug(ex);
                        }
                    }
                });
            }
        }
    })) {
        this.connection.getContext().setDontSendReponse(false);
        connection.enableTtl();
        throw new ResourceAllocationException("Queue is full " + address);
    }
}
Also used : Response(org.apache.activemq.command.Response) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) IOException(java.io.IOException) ResourceAllocationException(javax.jms.ResourceAllocationException) IOCallback(org.apache.activemq.artemis.core.io.IOCallback) ProducerAck(org.apache.activemq.command.ProducerAck) InvalidDestinationException(javax.jms.InvalidDestinationException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) IOException(java.io.IOException) ResourceAllocationException(javax.jms.ResourceAllocationException)

Example 10 with ProducerAck

use of org.apache.activemq.command.ProducerAck in project activemq-artemis by apache.

the class ProducerAckTest method createObject.

@Override
public Object createObject() throws Exception {
    ProducerAck info = new ProducerAck();
    populateObject(info);
    return info;
}
Also used : ProducerAck(org.apache.activemq.command.ProducerAck)

Aggregations

ProducerAck (org.apache.activemq.command.ProducerAck)16 ResourceAllocationException (javax.jms.ResourceAllocationException)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 IOException (java.io.IOException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 InvalidDestinationException (javax.jms.InvalidDestinationException)1 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)1 IOCallback (org.apache.activemq.artemis.core.io.IOCallback)1 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)1 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)1 Response (org.apache.activemq.command.Response)1