-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow V3.0.1 to be compatible with V2.6 Return messages.
Closes #236
- Loading branch information
Showing
8 changed files
with
95 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/unicast/NServiceBus.Unicast.BackwardCompatibility/CompletionMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/unicast/NServiceBus.Unicast.BackwardCompatibility/IncomingReturnMessageMutator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Globalization; | ||
using Common.Logging; | ||
using NServiceBus.Config; | ||
using NServiceBus.MessageMutator; | ||
using NServiceBus.Unicast.Transport; | ||
|
||
namespace NServiceBus.Unicast.BackwardCompatibility | ||
{ | ||
/// <summary> | ||
/// If this is a V26 message, extract completion message return error code and place it in the transport headers | ||
/// </summary> | ||
public class IncomingReturnMessageMutator : IMutateIncomingMessages, INeedInitialization | ||
{ | ||
/// <summary> | ||
/// Reference to the BUS to get a hold of the current TransportMessage | ||
/// </summary> | ||
public IBus Bus { get; set; } | ||
|
||
/// <summary> | ||
/// If this is a completion message from a 2.6 sender, copy the error code. | ||
/// </summary> | ||
/// <param name="message">Message to copy ErrorCode from.</param> | ||
/// <returns>Same message as received.</returns> | ||
public object MutateIncoming(object message) | ||
{ | ||
var completionMessage = message as CompletionMessage; | ||
if (completionMessage == null) | ||
return message; | ||
|
||
if(!Bus.CurrentMessageContext.Headers.ContainsKey(Headers.ReturnMessageErrorCodeHeader)) | ||
Bus.CurrentMessageContext.Headers.Add(Headers.ReturnMessageErrorCodeHeader, | ||
completionMessage.ErrorCode.ToString(CultureInfo.InvariantCulture)); | ||
|
||
//Change to Transport to be a Control Message so no need to find a handler for that. | ||
if(!Bus.CurrentMessageContext.Headers.ContainsKey(Headers.ControlMessageHeader)) | ||
Bus.CurrentMessageContext.Headers.Add(Headers.ControlMessageHeader, true.ToString(CultureInfo.InvariantCulture)); | ||
|
||
return message; | ||
} | ||
|
||
/// <summary> | ||
/// Register the IncomingReturnMessageMutator | ||
/// </summary> | ||
public void Init() | ||
{ | ||
Configure.Instance.Configurer.ConfigureComponent<IncomingReturnMessageMutator>(DependencyLifecycle.InstancePerCall); | ||
Log.Debug("Configured IncomingReturnMessageMutator"); | ||
} | ||
|
||
private readonly static ILog Log = LogManager.GetLogger(typeof(IncomingSubscriptionMessageMutator)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters