architecturemiddlewaresoftware-designconcept

Struggling with the concept of middelware - Is a middleware an independent process or part of an application?


Im struggling to understand the concept of a middleware. Is a middleware at runtime something that runs independent from an application and has to be called via a socket (or any other way to make a process communicate with another one)?

Or is it part of the application and just a layer that handles some task.

For example: In Java I have function that requests a number "getNumber()". This function should be transformed into a http request. The middleware has the job of getting the function name and transforming it into a http request by using some protocol and then return it.

Would a middleware then be a class within my java package that I just call directly by reference like "middleware.getNumber()" or would it run as independent process that I call via socket communication or something similar.


Solution

  • The middleware will be the HTTP stack that ends invoking your getNumber() function. From point of view of the client it is a separate process, from point of the getNumber - it and the HTTP stack will be in the same process.

    More details:

    The purpose of middleware is to bridge gaps between applications, implement communication and input/output (from: https://en.wikipedia.org/wiki/Middleware). In your situation the business logic of the application is to return the number (getNumber()), hence the middleware will be the thing do the output conversion. Also from the same wiki article:

    In this more specific sense middleware can be described as the dash ("-") in client-server, or the -to- in peer-to-peer. Middleware includes web servers, application servers, content management systems, and similar tools that support application development and delivery.[4]

    Check https://en.wikipedia.org/wiki/Middleware_(distributed_applications):

    The distinction between operating system and middleware functionality is, to some extent, arbitrary. While core kernel functionality can only be provided by the operating system itself, some functionality previously provided by separately sold middleware is now integrated in operating systems. A typical example is the TCP/IP stack for telecommunications, nowadays included virtually in every operating system.