mirror of https://github.com/apache/activemq.git
ensure exception is logged if one is raised sending a message to a dead letter queue
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@569270 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a5056e73b
commit
3cd1e6c73f
|
@ -636,36 +636,46 @@ public class RegionBroker implements Broker {
|
||||||
getRoot().sendToDeadLetterQueue(context, node);
|
getRoot().sendToDeadLetterQueue(context, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToDeadLetterQueue(ConnectionContext context, MessageReference node) {
|
public void sendToDeadLetterQueue(ConnectionContext context,
|
||||||
|
MessageReference node){
|
||||||
try{
|
try{
|
||||||
|
boolean sent=false;
|
||||||
if(node!=null){
|
if(node!=null){
|
||||||
Message message=node.getMessage();
|
Message message=node.getMessage();
|
||||||
if (message != null) {
|
if(message!=null&&node.getRegionDestination()!=null){
|
||||||
DeadLetterStrategy deadLetterStrategy = node.getRegionDestination().getDeadLetterStrategy();
|
DeadLetterStrategy deadLetterStrategy=node
|
||||||
|
.getRegionDestination().getDeadLetterStrategy();
|
||||||
if(deadLetterStrategy!=null){
|
if(deadLetterStrategy!=null){
|
||||||
if(deadLetterStrategy.isSendToDeadLetterQueue(message)){
|
if(deadLetterStrategy.isSendToDeadLetterQueue(message)){
|
||||||
long expiration=message.getExpiration();
|
long expiration=message.getExpiration();
|
||||||
message.setExpiration(0);
|
message.setExpiration(0);
|
||||||
message.setProperty("originalExpiration", new Long(expiration));
|
message.setProperty("originalExpiration",new Long(
|
||||||
|
expiration));
|
||||||
if(!message.isPersistent()){
|
if(!message.isPersistent()){
|
||||||
message.setPersistent(true);
|
message.setPersistent(true);
|
||||||
message.setProperty("originalDeliveryMode", "NON_PERSISTENT");
|
message.setProperty("originalDeliveryMode",
|
||||||
|
"NON_PERSISTENT");
|
||||||
}
|
}
|
||||||
// The original destination and transaction id do
|
// The original destination and transaction id do
|
||||||
// not get filled when the message is first
|
// not get filled when the message is first
|
||||||
// sent,
|
// sent,
|
||||||
// it is only populated if the message is routed to
|
// it is only populated if the message is routed to
|
||||||
// another destination like the DLQ
|
// another destination like the DLQ
|
||||||
ActiveMQDestination deadLetterDestination = deadLetterStrategy.getDeadLetterQueueFor(message.getDestination());
|
ActiveMQDestination deadLetterDestination=deadLetterStrategy
|
||||||
BrokerSupport.resend(context, message, deadLetterDestination);
|
.getDeadLetterQueueFor(message
|
||||||
|
.getDestination());
|
||||||
|
BrokerSupport.resend(context,message,
|
||||||
|
deadLetterDestination);
|
||||||
|
sent=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
LOG.warn("Null message for node: " + node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(sent==false){
|
||||||
|
LOG.warn("Failed to send "+node+" to dead letter queue");
|
||||||
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
LOG.warn("Failed to pass expired message to dead letter queue");
|
LOG.warn("Failed to pass expired message to dead letter queue",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue