Skip to content

Instantly share code, notes, and snippets.

@ramonsmits
Last active June 3, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramonsmits/18c7bd18f1eef804641c88ecc63d64e7 to your computer and use it in GitHub Desktop.
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
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