Skip to content

Commit

Permalink
Merge pull request #199 from Particular/backport-throw
Browse files Browse the repository at this point in the history
Throw if endpoint configured for message-driven pub/sub
  • Loading branch information
adamralph authored Jul 29, 2021
2 parents f8da320 + fb937f2 commit 1591c17
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Particular.Packaging" Version="1.2.1" PrivateAssets="All" />
<PackageReference Include="NServiceBus" Version="[7.1.10, 8.0.0)" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="[3.15.0, 4)" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="[3.20.1, 4)" />
</ItemGroup>

</Project>
</Project>
2 changes: 2 additions & 0 deletions src/NServiceBus.Persistence.CosmosDB/Outbox/OutboxStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class OutboxStorage : Feature

protected override void Setup(FeatureConfigurationContext context)
{
NonNativePubSubCheck.ThrowIfMessageDrivenPubSubInUse(context);

var serializer = new JsonSerializer { ContractResolver = new UpperCaseIdIntoLowerCaseIdContractResolver() };

var ttlInSeconds = context.Settings.Get<int>(SettingsKeys.OutboxTimeToLiveInSeconds);
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.Persistence.CosmosDB/Saga/SagaPersistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ internal CosmosDbSagaPersistence()

protected override void Setup(FeatureConfigurationContext context)
{
NonNativePubSubCheck.ThrowIfMessageDrivenPubSubInUse(context);

var serializer = new JsonSerializer { ContractResolver = new UpperCaseIdIntoLowerCaseIdContractResolver() };

var migrationModeEnabled = context.Settings.GetOrDefault<bool>(SettingsKeys.EnableMigrationMode);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace NServiceBus.Persistence.CosmosDB
{
using System;
using NServiceBus.Features;

class NonNativePubSubCheck
{
public static void ThrowIfMessageDrivenPubSubInUse(FeatureConfigurationContext context)
{
if (context.Settings.IsFeatureEnabled(typeof(MessageDrivenSubscriptions)) || context.Settings.IsFeatureActive(typeof(MessageDrivenSubscriptions)))
{
throw new Exception("NServiceBus.Persistence.CosmosDB must be used with a transport that provides native publish/subscribe capabilities, and cannot be used with message-driven publish/subscribe.");
}
}
}
}

0 comments on commit 1591c17

Please sign in to comment.