I am working on a project that involves implementing a Kafka messaging bus for resiliency along with SQS in my app. The backend services are developed in CLJ and the frontend script is in CLJS. I have successfully implemented Kafka producers in the backend services, but now I need to implement Kafka consumers in the frontend application. The frontend application is a browser-based app that is using ClojureScript code as the script, and it is built with the Boot build tool.
The problem I am facing is that there is no perfect library to build a Kafka client in CLJS. I have considered wrapping a JavaScript library using Cljsjs and using it for my app, but I am having difficulty creating an extern file for the package. I am specifically trying to use the kafkajs 2.2.4 library, which can be found here: https://github.com/tulios/kafkajs.
I am aware that I could use shadow-cljs, but since the frontend is already developed in Boot and is in production, it would be a hassle to ditch Boot. Is there any way to use shadow-cljs with Boot? I know that shadow-cljs can be integrated with Boot, but the documentation is incomplete for Boot integration.
I would appreciate any help with creating an extern file for the JS library, or any guidance on integrating shadow-cljs with Boot.
Thanks in advance!
The answer is still the same as in your last question. Kafka is not frontend tech, the library you mentioned specially states "A modern Apache Kafka® client for Node.js". It will not run in the browser, regardless of build tool used.
Directly talking to Kafka from your Frontend seems like a bad idea on multiple levels. Maybe you want to implement some kind of relay mechanism, so that your backend acts as a middlemen and transfers messages from kafka to your frontend and back.