Tuesday, May 26, 2009

What is a Middleware? A Platform, A Framework or What?

Some time ago I wrote a post about the difference between "platform" and "framework" and recently a reader, Hemanth Gowda, posted a comment to that text, asking how the concept of "middleware" is positioned between those definitions.

In my opinion, the concept of middleware is all about service providing. While a platform allows a software to run and a framework is more focused on software design, a middleware will provide services for your application. These services will allow your application to support many concurrent users, connect to several data sources, interoperate with services provided by other middleware instances, expand the platform to scale the application, support several frameworks to give flexibility for developers and many other relevant features.

The best example of middleware in the Java world is an application server, such as Glassfish, JBoss and Websphere. They provide all features mentioned above and much more. If you develop an application to run in any of these application servers it will a) support multiple users by default; b) be able to connect to several database from different vendors (Oracle, MySQL, MSSQL); c) access web services (stack or rest); d) send emails; e) provide fameworks for logging, data access, user interface rendering; and f) manage multiple instances of the application server to optimize the use of available hardware, among other advantages. The figure below shows the graphical schema of an application server.



There are other kinds of middleware and I would like to emphasize a) message queue systems (MQS) to mainly interchange asynchronous messages between applications; b) enterprise service bus (ESB) to integrate different kind of services provided by several systems; and c) transaction systems to guarantee the consistency of the data involved in the same business operation, such as database management systems.

Comparing middleware with framework and platform, I would say that a middleware system contributes to reduce the complexity of your application, which is one of the main characteristics of a framework, but it is not actually part of your application as a framework is. A middleware will provide many services for your application, but everything (middleware + application) will run on the available platform, which could be a virtual machine, or an operating system or a mobile device, etc.

I appreciate your questions and I love to answer them here! So, do not hesitate to post your comments as Hemanth did. Thanks for the opportunity to discuss the topic.

13 comments:

  1. Dear Hildeberto,

    I got my doubts clarified.

    Thank you,
    Hemanth
    ReplyDelete
  2. Hi Hildeberto

    Nice explanation. Here are my thoughts:

    Since these application servers you have mentioned RUN a software (assuming that you would agree that an application is also a software), are they not platforms?

    Since these appplications servers, MQS, ESB also provide some services which makes the developers job easy, are they not frameworks?

    I am tempted to come to the same conclusion you and Lionel Lawson arrived at for OI that these middlewares are also indeed "technologies". Would it be appropriate to say so?

    Thanks
    Syed Sheriff
    ReplyDelete
  3. Hello Syed, summarizing your questions:

    Is an application server a platform? What defines a platform is the ability to execute a software. In this case, what exactly runs a software deployed on the application server is the Java Virtual Machine (JVM), which is a platform. The application server also runs on top of the JVM, and, as a middleware, it provides the resources needed by the software, like a database connection or an email service. So, it is not a platform because it is not directly responsible for the software execution, despite being responsible for the software activation, which is more a logical implementation.

    Are MQS and ESB also frameworks? It is important to mention that platform, framework and middleware effectively make the developer's job easier. What differentiates them is their responsibility. The platform is responsible for the execution. The framework is part of the software (embedded libraries) and helps on the simplification and elegance of the code. Finally, middleware provides resources for the software, simplifying the interaction of this software with other available softwares. So, MQS and ESB are not frameworks because they provide resources and they are not part of the application.

    Are middleware also technologies? Everything we discussed here is technology. Platform, framework and middleware are technologies. The point about OI is that it can be embedded in an application, as a framework, and it can execute several applications, as a platform. So, we decided to go up one level of abstraction to cover both concepts.

    Thank you so much for your questions. They were very constructive.
    ReplyDelete
  4. Is email a middleware??What if I use a message queue server together with a built-in Java email service to complete a certain task?What is a middleware in this case?
    ReplyDelete
  5. In this case, an email server has the same status of a web server. It just manages email boxes, storing, sending and receiving messages. It is not a middleware because it is actually the end service that you are interested in. In this case, middleware is the software that will manage the communication between your application and the email server, taking care of security, optimized number of connections, transparency, etc.

    Concerning the second question, considering you are not talking about a Java email server (not a middleware as explained in the previous answer), but a JavaMail service, the message queue server and its use of the JavaMail service are both performing the role of a middleware. The MQ makes the integration between your application and the email server, through a JavaMail service.
    ReplyDelete
  6. Thanks for such a great explanation!!:)
    Actually,I was talking about some queue server like WebSphere MQ that I use in conjunction with built-in Java email service API(email libraries).I wanted to use publish/subscribe messaging model,so my application publishes a JMS message to the queue(specific topic) and then java email service would listen(subscribe) to this event and trigger the email to a specific user(based on topic).So,as I could understand,in this case the whole thing(MQ + email API) act as a middleware?
    Thanks very much in advance!
    ReplyDelete
  7. Yes, they are in the middle, between your application and the email server. ;)

    This is very flexible. Your application doesn't have to know how the MQ will deal with that message (transparency). Today, it could send an email message, but tomorrow it could be a SMS and your application doesn't even have to be changed, or just a minimal change could happen (e.g. message size).
    ReplyDelete
  8. Dear Hildeberto,

    Thank you very much,your explanations are very clear and to the point!

    Just one last question off-topic to clarify finally my doubts:when you are talking about email server,what exactly do you mean?I mean,I know what it does,but I'm just wondering if the email server is usually provided as a part of the framework I'm using(J2EE or Zend etc) or is it supported usually by the application server?Or in order to use the email services mentioned in the previous questions,I have to find and download some open-source email server software and then configure it to send emails?I mean,where do you get the email server from?:)
    ReplyDelete
  9. An email server is not usually provided as part of the framework. It is a server which runs independently, in most of the cases in another physical server (hardware). It provides a SMTP address to send emails and a POP/IMAP address to receive emails. This is a list of existing email servers on Wikipedia. This is an example of how to configure a JEE server (Glassfish) to access an email server using JavaMail.

    You can use the SMTP of GMail/Yahoo/MSN to send emails or you can use your own email server for that. To install an email server is not a easy task. It demands good knowledge about the network to configure all the security aspects. Better to use an exiting one.
    ReplyDelete
  10. Such a great explanation!!
    Just wondering if the SMTP server is supposed to be a part of presentation or business logic tier in the dustributed n-tier web architecture?Is it usually in the presentation tier together with the web server?
    ReplyDelete
  11. No. It has nothing to do with the presentation tier. The presentation tier considers technologies used to implement what the end-user will interact.

    It is more related with the business tier, where business components have access to resources provided by the application server (e.g. JavaMail). However, I wouldn't classify the email server in a specific tier, but as a service provider.
    ReplyDelete
  12. Hi,

    I am just wondering; are there two kinds of middleware?

    One used in the infrastructure like websphere and which helps to connect applications with servers.

    The other kind of middleware in which the idea is to extend an existing programming language by introducing a new layer "in the middle", between the application and the network and helps to the developer to hides the complexity of the communication and transfers.

    Is this correct?

    greets

    Christian
    ReplyDelete
  13. Hi Christian,

    The first kind is the one we are talking about here. The second kind looks like the concept of framework.

    Actually, it makes sense when you say there is something "in the middle" in both kinds. However, we must visit the concepts of "layer" and "tier" to understand the difference between framework and middleware.

    Layers are logical. A way of organizing the code into a set of layers according to architectural principles (i.e. MVC). Tiers are physical, where layers are deployed, where the code runs.

    Therefore, a framework is "in the middle" to implement the communication between layers and a middleware is "in the middle" to implement the communication between systems running on different computers or in different processes on a single computer.
    ReplyDelete