tags:

views:

156

answers:

5

I have a java application which runs under Tomcat. Fairly simple architecture - users invoke a servlet through HTTP which then puts a request onto an in memory queue. A consumer thread which was started as a ServletListener and is running continuously polls the queue and processes the requests which includes calling some stored procs and sending some data over socket connections to backend systems.

I may need to port the code over to C#. What I am trying to figure out is what is the equivalent technology in Microsoft land which will allow me to architect the same system. The porting of the code from Java to C# will be trivial, but what I can't seem to find is an application server technology from MS which will allow me to drop in my code and then declaratively specify that I want a new "servlet" for each HTTP call, and that I need to run a "daemon" thread in the same process, etc...

Any advice? I am not very familiar with the MS landscape...

A: 

I'm betting it's System.Net.HttpListener:

http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx

But I'm not a .NET guy yet, either.

duffymo
A: 

If you're unfamiliar with the Microsoft environment then don't expect to learn things quickly, since running a web site/service is far more complex than most people think. That is, if you want to run a secure environment.

First of all, I do wonder why you're moving to C# and IIS. Apache runs perfectly on Windows too, and it wouldn't surprise me if you can get everything running in the same way on a Windows system.

But if you do want to move towards C# and Windows development, start by reading some technical books first! O'Reilly has some excellent books about C# and .NET, including titles like "Learning WCF", "Programming Entity Framework" and "Programming ASP.NET 3.5" which should provide enough information for moving to .NET.

However, it will be different from what you're used to. The design patterns are similar, the names and techniques do differ though.

I'm not a Java guy, though. So I don't know what it is you want to do here...


Looking at your comment and desires, it seems that what you're building is a messagequeue system, where requests are sent to a queue on the server, waiting to be resolved. Windows has some good build-in functionality for that, although it might not be exactly what you're looking for. Still, the principle would be simple: the web interface will add requests to the queue and a Windows service (not a WEB service) will query the message queue for new requests to process these. It makes porting your code from Java to C# a lot less trivial, though!

About the equivalent of servlets in ASP.NET, I think gimel is partly right. An HTTP handler will allow you to generate any kind of response, including non-html pages. I've used them in the past to return data in XML or Excel format to the user. I've also used them to generate dynamic images with additional watermark. But a data service (.svc) might also be a good alternative. (I use one as a RESTful service around an Entity model.) Or just a regular web service(.asmx) could be as practical.

.NET and Java aren't easy to compare at this level. Each has a lot of it's own techniques to handle things. I'd almost think the equivalent of servlets is ASP.NET itself, not a subpart.

Workshop Alex
Note that Entity Framework is not the only ORM/OPF solution for .NET. ;)
TrueWill
True, but it simplifies a few things, especially when you use WCF to create a RESTful service around your database. It allows the use of quick solutions so users can use sooner before the final version is delivered.
Workshop Alex
The interest to move it to .NET comes from the client, it is not my decision. I'd have left it as is. Also, this is an internal application so the security aspect is really not that critical.To reiterate, all I want to do is to replicate my (fairly simple) architecture. I want the ability for multiple concurrent clients to be able to send in requests that get queued up. Then there is a daemon process which can read through the queue and process the requests.
Andy Faibishenko
+1  A: 

See what-are-the-correspondent-of-servlet-and-applet-in-net. The accepted answer says:

In .Net, HTTP handlers (.ashx) are probably the closest thing to a servlet.

gimel
+1  A: 

Migration from J2EE to .NET by vivek devarajan Read http://www.stardeveloper.com/articles/display.html?article=2003032802&page=1

He has a section on Servlet Migration to C# that you may like

Regards jnc at Kolkata

jnc at Kolkata
A: 

The vendor, who will make standardized, transactional, container based .NET server with all J2EE concepts like Servlets, MDBs and resource connectors working with less than 1 million config files will win.

RocketSurgeon