public MessageAck(MessageDispatch md, byte ackType, int messageCount) { this.ackType = ackType; this.consumerId = md.getConsumerId(); this.destination = md.getDestination(); this.lastMessageId = md.getMessage().getMessageId(); this.messageCount = messageCount; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
m = ((MessageDispatch)bc).getMessage(); sb.append(((MessageDispatch)bc).getConsumerId());
@Override public Response processMessageDispatch(MessageDispatch md) throws Exception { waitForTransportInterruptionProcessingToComplete(); ActiveMQDispatcher dispatcher = dispatchers.get(md.getConsumerId()); if (dispatcher != null) { // Copy in case a embedded broker is dispatching via // vm:// // md.getMessage() == null to signal end of queue // browse. Message msg = md.getMessage(); if (msg != null) { msg = msg.copy(); msg.setReadOnlyBody(true); msg.setReadOnlyProperties(true); msg.setRedeliveryCounter(md.getRedeliveryCounter()); msg.setConnection(ActiveMQConnection.this); msg.setMemoryUsage(null); md.setMessage(msg); } dispatcher.dispatch(md); } else { LOG.debug("{} no dispatcher for {} in {}", this, md, dispatchers); } return null; }
private boolean redeliveryExceeded(MessageDispatch md) { try { return session.getTransacted() && redeliveryPolicy != null && redeliveryPolicy.isPreDispatchCheck() && redeliveryPolicy.getMaximumRedeliveries() != RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES && md.getRedeliveryCounter() > redeliveryPolicy.getMaximumRedeliveries() // redeliveryCounter > x expected after resend via brokerRedeliveryPlugin && md.getMessage().getProperty("redeliveryDelay") == null; } catch (Exception ignored) { return false; } }
private boolean suppressMessageDispatch(MessageDispatch md, DemandSubscription sub) throws Exception { boolean suppress = false; // for durable subs, suppression via filter leaves dangling acks so we // need to check here and allow the ack irrespective if (sub.getLocalInfo().isDurable()) { NonCachedMessageEvaluationContext messageEvalContext = new NonCachedMessageEvaluationContext(); messageEvalContext.setMessageReference(md.getMessage()); messageEvalContext.setDestination(md.getDestination()); suppress = !sub.getNetworkBridgeFilter().matches(messageEvalContext); } return suppress; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageDispatch info = (MessageDispatch)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); return rc + 4; }
} else if (md.getMessage() == null) { return null; } else if (consumeExpiredMessage(md)) { } else if (redeliveryExceeded(md)) { LOG.debug("{} received with excessive redelivered: {}", getConsumerId(), md); posionAck(md, "Dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); if (timeout > 0) { timeout = Math.max(deadline - System.currentTimeMillis(), 0);
protected Message configureMessage(MessageDispatch md) throws IOException { Message message = md.getMessage().copy(); // Update the packet to show where it came from. message.setBrokerPath(appendToBrokerPath(message.getBrokerPath(), localBrokerPath)); message.setProducerId(producerInfo.getProducerId()); message.setDestination(md.getDestination()); message.setMemoryUsage(null); if (message.getOriginalTransactionId() == null) { message.setOriginalTransactionId(message.getTransactionId()); } message.setTransactionId(null); if (configuration.isUseCompression()) { message.compress(); } return message; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageDispatch info = (MessageDispatch)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); return rc + 4; }
synchronized (unconsumedMessages.getMutex()) { if (!unconsumedMessages.isClosed()) { if (this.info.isBrowser() || !session.connection.isDuplicate(this, md.getMessage())) { if (listener != null && unconsumedMessages.isRunning()) { if (redeliveryExceeded(md)) { posionAck(md, "listener dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); return; LOG.error("{} Exception while processing message: {}", getConsumerId(), md.getMessage().getMessageId(), e); md.setRollbackCause(e); if (isAutoAcknowledgeBatch() || isAutoAcknowledgeEach() || session.isIndividualAcknowledge()) { if (!unconsumedMessages.isRunning()) { session.connection.rollbackDuplicate(this, md.getMessage()); if (md.getMessage() == null) { LOG.debug("{} tracking transacted redelivery {}", getConsumerId(), md.getMessage()); if (transactedIndividualAck) { immediateIndividualTransactedAck(md); LOG.warn("{} delivering duplicate {}, pending transaction completion on {} will rollback", getConsumerId(), md.getMessage(), consumerWithPendingTransaction); session.getConnection().rollbackDuplicate(this, md.getMessage()); dispatch(md); } else {
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageDispatch info = (MessageDispatch)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); return rc + 4; }
private boolean redeliveryExceeded(MessageDispatch md) { try { return session.getTransacted() && redeliveryPolicy != null && redeliveryPolicy.isPreDispatchCheck() && redeliveryPolicy.getMaximumRedeliveries() != RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES && md.getRedeliveryCounter() > redeliveryPolicy.getMaximumRedeliveries() // redeliveryCounter > x expected after resend via brokerRedeliveryPlugin && md.getMessage().getProperty("redeliveryDelay") == null; } catch (Exception ignored) { return false; } }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageDispatch info = (MessageDispatch)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); return rc + 4; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageDispatch info = (MessageDispatch)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessage(), dataOut); dataOut.writeInt(info.getRedeliveryCounter()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageDispatch info = (MessageDispatch)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessage(), bs); return rc + 4; }