Check Proxy
will be working or not
Debezium
Architecture
https://kafka.apache.org/
https://github.com/debezium/debezium
CREATE TABLE dumb_table(id SERIAL PRIMARY KEY, name VARCHAR);
The Proxy Design Pattern provides a placeholder or representative object that controls access to a real object.
Instead of a client talking directly to a real object, it talks to a Proxy, and the Proxy decides:
Whether to forward the request
When to create the real object
How to control access
Whether to cache results
Whether to protect the real object
👉 Proxy = Middleman between Client and Real Object
The main purposes of Proxy are:
Control access to the real object
Delay expensive object creation (Lazy Loading)
Provide security or authentication (Protective Proxy)
Reduce memory usage
Add extra logic without changing real object
Client → Proxy → Real Object
The client talks to Proxy.
Proxy talks to Real Object.
The client does NOT directly interact with the Real Object.
Company gives project to Consultancy A
Consultancy A gives work to Consultancy B
Application Owner interacts only with Consultancy A
Consultancy A internally interacts with Consultancy B
Here, Consultancy A behaves like a Proxy.
public interface ProjectBooker {
void doWork();
void amount(int amount);
}
class RealProjectBooker implements ProjectBooker {
int amount = 0;
@Override
public void doWork() {
System.out.println("Project Finished");
}
@Override
public void amount(int amount) {
this.amount = amount;
}
}
This is the real worker who actually does the work.
class ProxyProjectBooker implements ProjectBooker {
RealProjectBooker realProjectBooker;
int amount;
@Override
public void doWork() {
realProjectBooker = new RealProjectBooker();
realProjectBooker.doWork();
}
@Override
public void amount(int amount) {
this.amount = amount;
int tempAmount = amount / 2;
realProjectBooker.amount(tempAmount);
}
}
👉 What Proxy does here:
Receives full amount from client
Passes only half to real object
Keeps remaining half as profit
public class Test {
public static void main(String[] args) {
// Application owner creates Proxy
ProjectBooker abcProj = new ProxyProjectBooker();
// Application owner asks to do work
abcProj.doWork();
// Application owner gives 10,00,000
abcProj.amount(1000000);
}
}
| Party | Amount Received |
|---|---|
| Application Owner | Pays ₹10,00,000 |
| Proxy (Consultancy A) | Keeps ₹5,00,000 |
| RealProjectBooker (Consultancy B) | Gets ₹5,00,000 |
👉 Conclusion: Proxy controls the real object.
This is a classic Lazy Loading Proxy Example.
public interface Image {
void showImage();
}
class HighResolutionImage implements Image {
public HighResolutionImage(String imageFilePath) {
loadImage(imageFilePath);
}
private void loadImage(String imageFilePath) {
System.out.println("Loading heavy image from disk...");
}
@Override
public void showImage() {
System.out.println("Displaying High Resolution Image");
}
}
This is heavy and expensive object.
class ImageProxy implements Image {
private String imageFilePath;
private Image proxiedImage;
public ImageProxy(String imageFilePath) {
this.imageFilePath = imageFilePath;
}
@Override
public void showImage() {
// Create real image only when required
if (proxiedImage == null) {
proxiedImage = new HighResolutionImage(imageFilePath);
}
proxiedImage.showImage();
}
}
👉 Key idea: Real object is created only when needed.
This is called Lazy Loading Proxy.
public class ImageViewer {
public static void main(String[] args) {
Image remoteImage = new ImageProxy("sample/remote.jpg");
Image localImage = new ImageProxy("sample/local.jpg");
remoteImage.showImage();
localImage.showImage();
}
}
| Step | Action |
|---|---|
| Client creates Proxy | No real image created |
| showImage() called | Now real image is created |
| Second call | Uses already created image |
👉 This saves memory and improves performance.
Controls access based on authentication or authorization.
Example:
Bank system
Admin system
Secure file access
Delays creation of heavy objects.
Example:
Loading high-resolution images
Loading large files
Fetching remote data
| Advantage | Explanation |
|---|---|
| Memory Saving | Creates object only when needed |
| Security | Controls access |
| Performance | Uses caching |
| Flexibility | Adds logic without modifying real object |
| Loose Coupling | Client does not know real object |
“Proxy controls the Real Object. Client talks to Proxy, not to Real Object.”
In both examples:
ProjectBooker example → Proxy controls money flow
Image example → Proxy controls object creation
This makes Proxy Pattern very useful in real-world applications.
Just tell me 👍