Middleware
1. Definition
Middleware is the software layer that sits between the client (application) and the server (operating system / network / database) and enables communication, data exchange and distributed processing between heterogeneous platforms.
It is the "glue" of client/server and n-tier systems: clients and servers do not need to know each other's OS, language or location.
APPLICATIONS (client / server programs)
========================== <- application interface (API)
MIDDLEWARE
========================== <- hides heterogeneity
OS / NETWORK PROTOCOL STACK / DBMS (TCP-IP, sockets, RPC, SQL)
2. Functions of Middleware
- Transparent transfer of requests and responses across machines and protocols.
- Location transparency — client calls a service by name, not by physical address.
- Protocol / data conversion — marshalling, encoding, character-set translation.
- Directory & naming services — locate objects/services (CORBA Naming, LDAP, JNDI).
- Transaction management — two-phase commit across databases (TP monitors).
- Security — authentication, authorisation, encryption (SSL, Kerberos).
- Load balancing, queuing, failover — distribution and reliability services.
3. Types of Middleware
| Type | Mechanism | Example |
|---|---|---|
| Remote Procedure Call (RPC) | Client calls a procedure on a remote machine as if local | Sun RPC, ONC, gRPC |
| Message-Oriented Middleware (MOM) | Asynchronous queues between applications | IBM MQ, RabbitMQ, Kafka |
| Object Request Brokers (ORB) | Invokes objects across languages/platforms via IIOP | CORBA, Java RMI, DCOM |
| Database middleware (ODBC/JDBC) | Uniform SQL access to any DBMS | JDBC drivers, ODBC manager |
| Transaction processing (TP) monitors | Coordinates distributed transactions, 2-phase commit | IBM CICS, Tuxedo, JTS |
| Web middleware / app servers | Hosts web components, sessions, EJBs | Tomcat, JBoss, WebLogic, IIS |
| Publish–subscribe | Events pushed to subscribed components | JMS topics, MQTT |
| API / service middleware | REST/SOAP gateways, ESBs, API gateways | Kong, WSO2, cloud API gateways |
4. RPC Model (the classic middleware)
CLIENT MACHINE SERVER MACHINE
client proc --> client stub ==network== server stub --> server proc
(marshals args) (unmarshals,
(sends request) calls proc,
returns result)
Steps: client stub marshals parameters → network → server stub unmarshals and calls the actual procedure → result travels back. The client code is identical to a local call (location transparency).
5. Middleware in a 3-Tier Web Architecture
Browser (Tier 1) --HTTP--> Web/App server + middleware (Tier 2)
[ servlets/JSP, session mgmt, connection pool,
JDBC, JMS, ORB ] --SQL--> DB server (Tier 3)
6. Benefits and Limitations
Benefits
- Interoperability across OS, hardware, languages and networks.
- Reuse of business logic; faster development; shields developers from low-level networking.
- Supports scalability (load balancing) and reliability (queuing, failover).
Limitations
- Extra layer → latency and complexity; middleware products can be expensive.
- "Middleware hell" — too many incompatible standards; debugging distributed apps is hard.
- Single middleware failure can affect the whole system (needs clustering).
7. Exam Points
- Define middleware and explain its role in client/server architecture with a diagram — 7 marks.
- Classify middleware types (RPC, MOM, ORB, TP monitor, database middleware) — 10 marks (very frequent).
- Explain the RPC mechanism with client/server stubs — 7 marks.
- Advantages and limitations of middleware — 5 marks.