I have the endpoint config settings in endpointconfig.cs file.
public class EndpointConfig : IConfigureThisEndpoint
{
public void Customize(EndpointConfiguration endpointConfiguration)
{
endpointConfiguration.UseSerialization();
log4net.Config.XmlConfigurator.Configure();
endpointConfiguration.SendFailedMessagesTo(“Error”);
endpointConfiguration.DisableFeature();
endpointConfiguration.DisableFeature();
LogManager.Use();
}
public void Init()
{
var endpointConfiguration = new EndpointConfiguration(“Radiator.ServiceBus.Inventory.Gateway”);
Customize(endpointConfiguration);
}
}
And also placed in Global.asax.cs file. But it was not considered and was giving me the NULL exception. Global.asax.cs
var endpointConfiguration = new EndpointConfiguration(“Radiator.ServiceBus.Inventory.Gateway”);
endpointConfiguration.UseSerialization();
var transport = endpointConfiguration.UseTransport();
transport.Transactions(TransportTransactionMode.None);
Finally, I placed this in my controller just before sending the object and this worked. controller.cs
public IMessageSession Bus { get; set; }
public static IMessageSession InitiliseIMessageSession()
{
var cfg = new EndpointConfiguration(“Radiator.ServiceBus.Inventory.Gateway”);
cfg.UseTransport();
cfg.UsePersistence();
cfg.PurgeOnStartup(true);
cfg.EnableInstallers();
cfg.UseSerialization();
return Endpoint.Start(cfg).GetAwaiter().GetResult();
}
public ActionResult SubmitOrder(long invoiceId, string callbackUrl)
{
Bus = InitiliseIMessageSession();
var service = new InventoryService();
string serviceName = service.ToString() + " - SubmitOrder";
var m = new OrderCommand() { InvoiceId = invoiceId, CallbackUrl = callbackUrl };
Bus.Send(m).ConfigureAwait(false);
Global.LogRoot.Info(String.Format(“ServiceControler 6”));
return Content((true).ToString());
}
With this NULL exception is gone but I am not sure whether is correct or not.
And why is it not worked with my endpointconfig.cs file and global.asax.cs?