java - Use of eventBus in vertx -


I am using vertx in my project and I have problems with eventBus if I think right, then this is a The server transmits multiple languages ​​to use a string representing the root. My server has this code. Java:

  vertx.eventBus (). RegisterHandler ("gettree", new handler & lt; message & lt; string & gt; & gt; () {public void handle (message & lt; string & gt; e) {// E.rely (calling the function Is returning the JSSN string);}});  

In a JavaScript file, I need to print that Jason String for the moment. I have:

  var eventBus = Required ('vertx / event_bus'); EventBus.send ('getTree', '', function (answer) {console.log ('I got a reply' + reply);}); }  

But does anyone know what does anyone know?

I think you want to see something like in your console answer Please give it.

To be able to get back anything on your Javascript answer handler, you will need to change your java message handler and call answer . Incoming messages such as

  vertx.eventBus (). RegisterHandler ( "getTree", a new handler & lt; message & lt; string & gt; & gt; () {public void handle (Message & lt; String & gt; msg) message {Msg.reply ( "Java handler" );}}); Nothing in your Javascript sender / reply recipient code will be lost, without calling a  answer  method.  

After adding the changes mentioned in your java code, you should be able to see the following logs in the console:

I received a reply message from the Java handler

Note that even though you use different languages ​​with Vert.x, the whole argument is executed by JVM (Javascript by Rhino Open-Source implementation).


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -