Skip to content

Commit

Permalink
Merge pull request #389 from Particular/backport-4.2.1
Browse files Browse the repository at this point in the history
* Force transaction mode to receive only to allow outbox to be used

* Add acceptance test
  • Loading branch information
andreasohlund committed Sep 21, 2023
2 parents 179a9e3 + 40c135b commit 92ace54
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ManualTests.HostV4/ManualTests.HostV4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.14.1" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.14.1" />
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="3.2.1" />
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="3.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/ManualTests.HostV4/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static void Main()
.ConfigureFunctionsWorkerDefaults()
.UseNServiceBus(c =>
{
//c.AdvancedConfiguration.SendOnly();
c.Routing.RouteToEndpoint(typeof(TriggerMessage), "some-queue");
c.AdvancedConfiguration.EnableInstallers();
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace ServiceBus.Tests
{
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
using NUnit.Framework;

public class When_outbox_is_enabled
{
[Test]
public async Task Should_work()
{
var context = await Scenario.Define<Context>()
.WithComponent(new OutboxEnabledFunction(new SomeMessage()))
.Done(c => c.GotTheMessage)
.Run();

Assert.True(context.GotTheMessage);
}

public class Context : ScenarioContext
{
public bool GotTheMessage { get; set; }
}

class OutboxEnabledFunction : FunctionEndpointComponent
{
public OutboxEnabledFunction(object triggerMessage)
{
CustomizeConfiguration = configuration =>
{
configuration.AdvancedConfiguration.UsePersistence<AcceptanceTestingPersistence>();
configuration.AdvancedConfiguration.EnableOutbox();
};
AddTestMessage(triggerMessage);
}

public class SomeMessageHandler : IHandleMessages<SomeMessage>
{
Context testContext;

public SomeMessageHandler(Context testContext)
{
this.testContext = testContext;
}

public Task Handle(SomeMessage message, IMessageHandlerContext context)
{
testContext.GotTheMessage = true;
return Task.CompletedTask;
}
}
}

class SomeMessage : IMessage
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ServerlessTransport : TransportDefinition
public IMessageProcessor MessageProcessor { get; private set; }

public ServerlessTransport(TransportDefinition baseTransport) : base(
baseTransport.TransportTransactionMode,
TransportTransactionMode.ReceiveOnly,
baseTransport.SupportsDelayedDelivery,
baseTransport.SupportsPublishSubscribe,
baseTransport.SupportsTTBR)
Expand Down

0 comments on commit 92ace54

Please sign in to comment.