Why you need to Glue ?
When I was beginning my career in programming I used to wonder how two applications in different programming language can be made to interplay. Let me ease that.
Suppose your API engine is running over .NET core and you want to implement a PDF creator. Now one solution could be to find a library implemented in .NET core only. But, what if no such library is available or the one that’s available is paid one ?
Then, another solution could be to implement the PDF creator portion using some other library like PDFkit – which by the way is implemented in Node.js
But wait, how you can make Node.js and .NET core work together ? There can be many methods like COM interfacing, IPC, Web service based approach. But the most easiest and least intrusive among them is achieved by using middleware like Kafka or RabbitMQ
In this post we will be discussing Kafka.
To keep things easy, I will be using docker so that I get a pre-configured kafka environment. Find it’s image here.
What we will be building ?
We will simulate control of applications in different technologies. We shall build :
- Master app (.NET Core console app) – that will direct slave app to initiate or kill project.
- Slave app (.NET Core console app) – that will start or close a C++ app that prints “Hello World” in an infinite while loop.
- Controlled app (C++ app) – simple hello world application in C++.
- Slave and Master app will communicate over Kafka.
In this example I am using two .NET Core console program to control a CPP application. In similar fashion, multiple applications in different languages can be made to communicate. Kafka producer-consumer connectors are available for all major languages.
Please find code of the demo project at: https://github.com/jyotendra/kafka-demo
Here’s the final result:
I have coded it over ubuntu – you might need to change your build command in case of C++ sample project to suit your OS. Let me know in comments if you have any questions.
I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all site owners and bloggers made good content as you did, the internet will be much more useful than ever before.
https://waterfallmagazine.com/
Thank you for sharing your info. I truly appreciate
your efforts and I am waiting for your next write ups
thanks once again.