Using Service Bus for Asp.net Web API - asp.net-mvc

I am developing Services using ASP.NET Web API and have plan to use Service Bus for message exhanging. Is it possible to use Service Bus along with ASP.NET Web API?
And what are the Microsoft's Answer for Service Bus other than Windows Azure service bus?

There is absolutely nothing stopping you from using a service bus with ASP.NET Web API.
I am doing exactly this (web api) in a project I am implementing where a user registers and I need to send an activation e-mail. The e-mail sending is handled from a service bus endpoint so that the registration from the web api returns immediately.
I have also implemented my service bus in a production system although it is MVC 3 (4 web servers).
Although any service bus should do the trick (NServiceBus, MassTransit, etc.) you may want to have a look at my FOSS Shuttle ESB project: http://shuttle.codeplex.com/

Have you looked at Microsoft Service Bus 1.0?
http://msdn.microsoft.com/en-us/library/windowsazure/jj193022(v=azure.10).aspx
(it includes messaging and queuing features from the Azure Service Bus)
For distributed caching (i.e. Caching Service in Azure)
AppFabric 1.1 for Windows Server has as lot of features
http://www.microsoft.com/en-us/download/details.aspx?id=27115
You can absolutely use the Caching Service in the ASP.NET Web API. I have not tried the Microsoft Service Bus 1.0 for messaging/queuing on Web API.

Related

SignalR Scale out with Azure Service Bus Topic

I started learning SignalR. And having some requirement to implement SignalR with Service Bus backplane.
I just try to create very simple demo.
Where there is one API application running on azure connected with service bus topic using signalr.
And there is multiple instance of MVC application is open which is also hosted on Azure.
I want to broadcast message using signalr to all receivers.
I checked many documents. Following are the links.
SignalR Scaleout with Azure Service Bus
Also tried to create simple console application in which one aaplication will send message to service bus and all other console application will able to receive that message.
Is this architechture complex?
Can anybody provide simple demo and clear understading of how Hub is supposed to work?
And how i can implement this functionality?

Why is it not recommended to host receive endpoints in a web application using MassTransit?

I am working on an ASP.NET MVC 5 application (based on nopCommerce). I want to use MassTransit to communicate with another application that is used for inventory management, billing, etc. It would be easier if I could add receive endpoints directly into the web application and not have to create a Windows service for that. But the MassTransit documentation says it is not recommended and there is no explanation as to why that is.
MassTransit in a web application
Configuring a bus in a web site is typically done to publish events,
send commands, as well as engage in request/response conversations.
Hosting receive endpoints and persistent consumers is not recommended
(use a service as shown above).
Does anyone know the reasoning behind it? Is it not safe to add receive endpoints in a web application? Will they not work properly?
Hosting endpoints in a web application is not recommended because web applications often restart for various reasons. These reasons are typically outside the control of the application itself.
While using a standalone Windows service is highly recommended, as long as the bus is properly started and stopped using the Application_Start and Application_End methods, it can be okay if you have no other options available.

How to connect to a relay service hosted on the service bus in iOS

I want to use Azure service bus in my iOS app to communicate with server i have went through the below link. its pointing to C#.Need suggestions to work on iOS.
http://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-relay/#next_steps
You may want to consider using WebHttpRelayBinding for your service so you can hit the Azure endpoint using HTTP / HTTPS.
WCF supports both RESTfull and classic SOAP style messaging but using lightweight json requests in a RESTfull service would be better from a mobile app.
read the following article for details. but you don't need to write custom autostarter if you are using IIS 7.5 or greater with appfabric, since it has autostart functionality in built.
http://msdn.microsoft.com/en-us/library/hh966775.aspx
if you don't need request-response messaging pattern then you can also consider service bus queues for persistence, and your on-premise process can pull and process the messages at its own pace.

Windows Service and MVC communication

I have a windows service (C#) that is getting data from other services, processing that data as saving it on the database.
Now I have monitoring application (C# Windows Forms) that monitors the windows service via TCP and xml messages.
But now I want to change my monitor app to MVC 4 web application.
My problem is how can I send notifications from my windows services to the each current client in my MVC application? The clients may be outside the internal network.
Can someone point me to the best approach?
Thanks
Pedro
You have already done much work:
Now I have monitoring application (C# Windows Forms) that monitors the
windows service via TCP and xml messages.
Pass your messages to the an web service that will be accessible by your MVC 4 web application clients.
you need interface between an windows service and the web application which is either a WCF service or Web Service. You can not access windows service in MVC4 application. If they are same machine or the location of XML message file is known and accessible to you then you can directly consume those in your MVC application.
otherwise the path will be Win Service -> WebService/WCF Service -> MVC4 application

Using SOAP web services as model in ASP.NET MVC

I am developing an ASP.NET web application (C#.NET 4) in a scenario where I need to consume WCF SOAP Services (VB.NET 4) provided by another development team as the model.
Services are hosted on IIS using AppFabric. The WCF implementation is created to support the following scenario:
A shared data service layer that is language/platform independent. A requirement is also that services should provide a black-box when front-end development is outsourced to external developers. WCF SOAP services are used to provide the common web based API. Consumers of the services are both web applications and desktop software that are internal and external.
My question is about my current web application architecture. The application is developed using ASP.NET MVC 2 and jQuery UI. From what I have read this far it seems that using WCF SOAP Services as the model is ok. My plan is also to use ViewModels and AutoMapper based on this post:
Using SOAP web service object as a model in ASP.NET MVC 2
What are the pitfalls if any?
How should I develop the communication with services?
Are there overheads in term of communication with this kind of architecture?
Any Best Practices?
(Re-engineering the service layer to OData is not an option at this stage)
If you think about your web services as a "remote database" you can just follow the same practices that you would when developing an MVC application against a database. But be prepared for far more disconnection problems that you would otherwise.
I would suggest you create your model to wrap the calls to the web services and provide any error handling logic that you will need (which will be probably a lot if the web services will be remote.) Remember that network connectivity on a WAN is not guaranteed and hiccups are not unusual.

Resources