1
0
mirror of synced 2024-11-16 14:53:50 +00:00

Fixed NRE with async methods returning a message

This commit is contained in:
Mark van Renswoude 2018-12-21 10:49:30 +01:00
parent c644b0d2b4
commit f6c4ccdadc
2 changed files with 12 additions and 1 deletions

View File

@ -38,6 +38,16 @@ namespace Tapeti.Default
} }
// ReSharper disable once UnusedMember.Local - used implicitly above
private static async Task PublishGenericTaskResult<T>(IMessageContext messageContext, object value) where T : class
{
var message = await (Task<T>)value;
if (message != null)
await Reply(message, messageContext);
}
private static Task Reply(object message, IMessageContext messageContext) private static Task Reply(object message, IMessageContext messageContext)
{ {
var publisher = (IInternalPublisher)messageContext.DependencyResolver.Resolve<IPublisher>(); var publisher = (IInternalPublisher)messageContext.DependencyResolver.Resolve<IPublisher>();

View File

@ -120,9 +120,10 @@ namespace Test
* This will automatically include the correlationId in the response and * This will automatically include the correlationId in the response and
* use the replyTo header of the request if provided. * use the replyTo header of the request if provided.
*/ */
public PoloConfirmationResponseMessage PoloConfirmation(PoloConfirmationRequestMessage message) public async Task<PoloConfirmationResponseMessage> PoloConfirmation(PoloConfirmationRequestMessage message)
{ {
Console.WriteLine(">> PoloConfirmation (returning confirmation)"); Console.WriteLine(">> PoloConfirmation (returning confirmation)");
await Task.Delay(100);
return new PoloConfirmationResponseMessage return new PoloConfirmationResponseMessage
{ {