Last active
June 3, 2019 19:48
-
-
Save ramonsmits/18c7bd18f1eef804641c88ecc63d64e7 to your computer and use it in GitHub Desktop.
NServiceBus 5 - Fake gateway deduplication persistence if dedupe in the gateway is not needed
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using NServiceBus.Features; | |
using NServiceBus.Gateway.Deduplication; | |
// Usage: | |
// | |
// busConfiguration.UsePersistence<NoGatewayDeduplicationPersistence, StorageType.GatewayDeduplication>(); | |
// | |
using System.Diagnostics; | |
using NServiceBus.Logging; | |
class NoGatewayDeduplication : IDeduplicateMessages | |
{ | |
public bool DeduplicateMessage(string clientId, DateTime timeReceived) | |
{ | |
return true;// Fake that it does not exists. | |
} | |
} | |
public class NoGatewayDeduplicationPersistence : PersistenceDefinition | |
{ | |
internal NoGatewayDeduplicationPersistence() | |
{ | |
Supports<StorageType.GatewayDeduplication>(s => s.EnableFeatureByDefault<NoGatewayDeduplicationPersistence>()); | |
} | |
} | |
public class NoGatewayPersistence : Feature | |
{ | |
internal NoGatewayPersistence() | |
{ | |
DependsOn("Gateway"); | |
} | |
/// <summary> | |
/// See <see cref="Feature.Setup"/> | |
/// </summary> | |
protected override void Setup(FeatureConfigurationContext context) | |
{ | |
context.Container.ConfigureComponent<NoGatewayDeduplication>(DependencyLifecycle.SingleInstance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment