Search in sources :

Example 1 with MessageDispatch

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

the class OpenWireConnection method processDispatch.

protected void processDispatch(Command command) throws IOException {
    MessageDispatch messageDispatch = (MessageDispatch) (command.isMessageDispatch() ? command : null);
    try {
        if (!stopping.get()) {
            if (messageDispatch != null) {
                protocolManager.preProcessDispatch(messageDispatch);
            }
            dispatch(command);
        }
    } catch (IOException e) {
        if (messageDispatch != null) {
            TransmitCallback sub = messageDispatch.getTransmitCallback();
            protocolManager.postProcessDispatch(messageDispatch);
            if (sub != null) {
                sub.onFailure();
            }
            messageDispatch = null;
            throw e;
        }
    } finally {
        if (messageDispatch != null) {
            TransmitCallback sub = messageDispatch.getTransmitCallback();
            protocolManager.postProcessDispatch(messageDispatch);
            if (sub != null) {
                sub.onSuccess();
            }
        }
    }
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) TransmitCallback(org.apache.activemq.transport.TransmitCallback) IOException(java.io.IOException)

Example 2 with MessageDispatch

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

the class OpenWireMessageConverter method createMessageDispatch.

public static MessageDispatch createMessageDispatch(MessageReference reference, ICoreMessage message, WireFormat marshaller, AMQConsumer consumer) throws IOException {
    ActiveMQMessage amqMessage = toAMQMessage(reference, message, marshaller, consumer);
    // we can use core message id for sequenceId
    amqMessage.getMessageId().setBrokerSequenceId(message.getMessageID());
    MessageDispatch md = new MessageDispatch();
    md.setConsumerId(consumer.getId());
    md.setRedeliveryCounter(reference.getDeliveryCount() - 1);
    md.setDeliverySequenceId(amqMessage.getMessageId().getBrokerSequenceId());
    md.setMessage(amqMessage);
    ActiveMQDestination destination = amqMessage.getDestination();
    md.setDestination(destination);
    return md;
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 3 with MessageDispatch

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

the class AMQConsumer method browseFinished.

public void browseFinished() {
    MessageDispatch md = new MessageDispatch();
    md.setConsumerId(info.getConsumerId());
    md.setMessage(null);
    md.setDestination(null);
    session.deliverMessage(md);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 4 with MessageDispatch

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

the class AMQConsumer method handleDeliver.

public int handleDeliver(MessageReference reference, ICoreMessage message, int deliveryCount) {
    MessageDispatch dispatch;
    try {
        if (messagePullHandler != null && !messagePullHandler.checkForcedConsumer(message)) {
            return 0;
        }
        if (session.getConnection().isNoLocal() || session.isInternal()) {
            // internal session always delivers messages to noLocal advisory consumers
            // so we need to remove this property too.
            message.removeProperty(MessageUtil.CONNECTION_ID_PROPERTY_NAME);
        }
        // handleDeliver is performed by an executor (see JBPAPP-6030): any AMQConsumer can share the session.wireFormat()
        dispatch = OpenWireMessageConverter.createMessageDispatch(reference, message, session.wireFormat(), this);
        int size = dispatch.getMessage().getSize();
        reference.setProtocolData(dispatch.getMessage().getMessageId());
        session.deliverMessage(dispatch);
        currentWindow.decrementAndGet();
        return size;
    } catch (IOException e) {
        ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", e);
        return 0;
    } catch (Throwable t) {
        ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", t);
        return 0;
    }
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) IOException(java.io.IOException)

Example 5 with MessageDispatch

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

the class AMQConsumer method handleDeliverNullDispatch.

public void handleDeliverNullDispatch() {
    MessageDispatch md = new MessageDispatch();
    md.setConsumerId(getId());
    md.setDestination(openwireDestination);
    session.deliverMessage(md);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Aggregations

MessageDispatch (org.apache.activemq.command.MessageDispatch)34 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)6 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)4 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)3 Transport (org.apache.activemq.transport.Transport)3 IOException (java.io.IOException)2 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 BrokerService (org.apache.activemq.broker.BrokerService)2 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)2 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)1 Socket (java.net.Socket)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Destination (javax.jms.Destination)1 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)1 Broker (org.apache.activemq.broker.Broker)1 BrokerFilter (org.apache.activemq.broker.BrokerFilter)1 BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)1