I’m using the AzureServiceBus plugin and attempting to run the following example .net core 2 code.
public class HelloService : Service
{
public object Any(SendEmail request)
{
Console.WriteLine(request.Name);
return new SendEmailResponse() { Email = "Sent!" };
}
}
//Define the Web Services AppHost
public class AppHost : AppSelfHostBase
{
public AppHost()
: base("HttpListener Self-Host", typeof(HelloService).Assembly) { }
public override void Configure(Funq.Container container)
{
var servicebus = new ServiceBusMqServer(KEY HERE);
servicebus.RegisterHandler<SendEmail>(ExecuteMessage);
servicebus.Start();
//try
//{
// using (var mqClient = servicebus.CreateMessageQueueClient())
// {
// mqClient.Publish(new SendEmail { Name = "From .net 4.7.1" });
// }
//}
//catch (Exception e)
//{
// Console.WriteLine(e.Message);
//}
}
}
static void Main(string[] args)
{
var listeningOn = args.Length == 0 ? "http://*:1339/" : args[0];
var appHost = new AppHost()
.Init()
.Start(listeningOn);
var servicebus = new ServiceBusMqServer(KEY HERE);
using (var mqClient = servicebus.CreateMessageQueueClient())
{
mqClient.Publish(new SendEmail { Name = "FromCore" });
var qname = QueueNames<SendEmailResponse>.In;
////Block until the Response is Received:
var responseMsg = mqClient.Get<SendEmailResponse>(qname);
mqClient.Ack(responseMsg); //Acknowledge the message was received
Console.WriteLine(responseMsg.GetBody().Email);
}
Console.ReadKey();
}
A NullReferenceException is thrown when attempting to read the response of the message sent.
I’ve traced it to - ServiceStack.Azure.Messaging.QueueClientExtensions where the following line static readonly System.Reflection.PropertyInfo innerReceiverProperty = typeof(Microsoft.Azure.ServiceBus.QueueClient).GetProperty(“InnerReceiver”);
is always null.
Am I missing some steps when setting up the service?