copy message before resend

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@618655 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-02-05 14:05:46 +00:00
parent d0f3d4dce9
commit c128634fa6
1 changed files with 9 additions and 8 deletions

View File

@ -23,6 +23,10 @@ import org.apache.activemq.command.Message;
import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.ProducerInfo;
import org.apache.activemq.state.ProducerState; import org.apache.activemq.state.ProducerState;
/**
* Utility class for re-sending messages
*
*/
public final class BrokerSupport { public final class BrokerSupport {
private BrokerSupport() { private BrokerSupport() {
@ -30,17 +34,14 @@ public final class BrokerSupport {
/** /**
* @param context * @param context
* @param message * @param originalMessage
* @param deadLetterDestination * @param deadLetterDestination
* @throws Exception * @throws Exception
*/ */
public static void resend(final ConnectionContext context, Message message, ActiveMQDestination deadLetterDestination) throws Exception { public static void resend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination) throws Exception {
if (message.getOriginalDestination() != null) { Message message = originalMessage.copy();
message.setOriginalDestination(message.getDestination()); message.setOriginalDestination(message.getDestination());
} message.setOriginalTransactionId(message.getTransactionId());
if (message.getOriginalTransactionId() != null) {
message.setOriginalTransactionId(message.getTransactionId());
}
message.setDestination(deadLetterDestination); message.setDestination(deadLetterDestination);
message.setTransactionId(null); message.setTransactionId(null);
boolean originalFlowControl = context.isProducerFlowControl(); boolean originalFlowControl = context.isProducerFlowControl();