Skip to content

Commit 1df2f4d

Browse files
timbussmannjpalac
authored andcommitted
move wrapper
1 parent cf7c7b6 commit 1df2f4d

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace NServiceBus.AzureFunctions.InProcess.ServiceBus
2+
{
3+
using System;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using Transport;
7+
8+
class SendOnlyReceiver : IMessageReceiver
9+
{
10+
static readonly InvalidOperationException SendOnlyEndpointException = new($"This endpoint cannot process messages because it is configured in send-only mode. Remove the '{nameof(EndpointConfiguration)}.{nameof(EndpointConfiguration.SendOnly)}' configuration or do not call '{nameof(IFunctionEndpoint)}.{nameof(IFunctionEndpoint.ProcessAtomic)}/{nameof(IFunctionEndpoint.ProcessNonAtomic)}'");
11+
12+
public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnError onError,
13+
CancellationToken cancellationToken = new CancellationToken()) =>
14+
throw SendOnlyEndpointException;
15+
16+
public Task StartReceive(CancellationToken cancellationToken = new CancellationToken()) => throw SendOnlyEndpointException;
17+
18+
public Task ChangeConcurrency(PushRuntimeSettings limitations, CancellationToken cancellationToken = new CancellationToken()) => throw SendOnlyEndpointException;
19+
20+
public Task StopReceive(CancellationToken cancellationToken = new CancellationToken()) => throw SendOnlyEndpointException;
21+
22+
public ISubscriptionManager Subscriptions => throw SendOnlyEndpointException;
23+
public string Id => throw SendOnlyEndpointException;
24+
public string ReceiveAddress => throw SendOnlyEndpointException;
25+
}
26+
}

src/NServiceBus.AzureFunctions.InProcess.ServiceBus/Serverless/TransportWrapper/ServerlessTransport.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
3434

3535
PipelineInvoker = receivers.Length > 0
3636
? (PipelineInvoker)serverlessTransportInfrastructure.Receivers[MainReceiverId]
37-
: new PipelineInvoker(new NullReceiver()); // send-only endpoint
37+
: new PipelineInvoker(new SendOnlyReceiver()); // send-only endpoint
3838

3939
return serverlessTransportInfrastructure;
4040
}
@@ -57,21 +57,4 @@ public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransa
5757
TransportTransactionMode.SendsAtomicWithReceive
5858
};
5959
}
60-
61-
class NullReceiver : IMessageReceiver
62-
{
63-
public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnError onError,
64-
CancellationToken cancellationToken = new CancellationToken()) =>
65-
throw new System.NotImplementedException();
66-
67-
public Task StartReceive(CancellationToken cancellationToken = new CancellationToken()) => throw new System.NotImplementedException();
68-
69-
public Task ChangeConcurrency(PushRuntimeSettings limitations, CancellationToken cancellationToken = new CancellationToken()) => throw new System.NotImplementedException();
70-
71-
public Task StopReceive(CancellationToken cancellationToken = new CancellationToken()) => throw new System.NotImplementedException();
72-
73-
public ISubscriptionManager Subscriptions { get; }
74-
public string Id { get; }
75-
public string ReceiveAddress { get; }
76-
}
7760
}

0 commit comments

Comments
 (0)