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();
}
}
}
}
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;
}
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);
}
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;
}
}
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);
}
Aggregations