Most cross language calls do not need conversions at runtime JVM interop enabled with --jvm Drop in replacement for node.js (mostly compatible with existing libs)
jar 2. Call it from node 3. Use it in our application 4. Go home early --vm.cp Java.addToClasspath(path) OR We’ll specify the classpath manually with --vm.cp
jar 2. Call it from node 3. Use it in our application 4. Go home early const BCrypt = Java.type("org.mindrot.jbcrypt.BCrypt"); const salt = "$2a$10$sfMWTWROyUu5JxTEwm413u"; const hash = BCrypt.hashpw("Hello", salt); console.log(hash); bcrypt.js
jar 2. Call it from node 3. Use it in our application 4. Go home early const BCrypt = Java.type("org.mindrot.jbcrypt.BCrypt"); const salt = "$2a$10$sfMWTWROyUu5JxTEwm413u"; const hash = BCrypt.hashpw("Hello", salt); console.log(hash); bcrypt.js FLAGS="\ --jvm \ --vm.cp=./jbcrypt-0.3m.jar" node $FLAGS bcrypt.js > $2a$1...ugoQ3u/Mjb/CYi run it!
jar 2. Call it from node 3. Use it in our application 4. Go home early const BCrypt = Java.type("org.mindrot.jbcrypt.BCrypt"); const salt = "$2a$10$sfMWTWROyUu5JxTEwm413u"; app.post('/login', (req, res) => { const pass = req.query.password; res.send(BCrypt.hashpw(pass, salt)); }); app.js
Call it from node 3. Use it in our application 4. Go home early We blocked the event loop fortunately... The node community knows how to deal with blocking workloads SYNC INTEROP
Call it from node 3. Use it in our application 4. Go home early We blocked the event loop fortunately... The node community knows how to deal with blocking workloads so We can create a pool of workers and do the work there SYNC INTEROP
.map(v => `In node: ${v}`) .forEach(console.log); callback.js run it! ASYNC INTEROP node --jvm callback.js > In node: 1 > In node: 2 1. Figure out how to do callbacks with Graal 2. Define the Java API 3. Handle a rabbitmq message in node
queueName, Handler handler ); interface Handler { void handle(String message); } } 1. Figure out how to do callbacks with Graal 2. Define the Java API 3. Handle a rabbitmq message in node
RabbitMQ(); mq.init(); const handle = console.log; mq.addConsumer("hello-rabbit", handle); 1. Figure out how to do callbacks with Graal 2. Define the Java API 3. Handle a rabbitmq message in node