Vertx event bus not communicating in single JVM

120 views Asked by At

I have two verticles as below

First verticle is just listening on a address test and reply to messages

public class FirstVerticle extends AbstractVerticle {

@Override
public void start()  {
Logger logger = LogManager.getLogger(FirstVerticle.class);
 vertx.eventBus().consumer("test",message->{
            logger.info("message received " + message.headers());
            message.reply("hi!!!!");
        });
}
}

Second verticle just sends a message to address test

public class SecondVerticle extends AbstractVerticle {

    @Override
        public void start() throws Exception {
            Logger logger = LogManager.getLogger(SecondVerticle.class);
           
            vertx.eventBus().request("test","hey there",handler->{
                if(handler.failed())
                    logger.error("Failed to get data"+handler.cause());
                else
                    logger.info("response " + handler.result().headers());
            });
    
    
        }
    }

The two vertciles are deployed using a common main class

Vertx.clusteredVertx(new VertxOptions().setHAEnabled(true), vertx ->
                vertx.result().deployVerticle(verticleName, new DeploymentOptions().setHa(true))
        );

When running as a separate program and deploy the verticles in different JVM, verticles can communicate with each other using event bus, but when deploying two verticles using common class at a time is not working, getting below error

 Failed to get data(TIMEOUT,-1) Timed out after waiting 30000(ms) for a reply. address:
 __vertx.reply.9da86cc6-f689-47d5-a5b4-bceafbce254a, repliedAddress: test

Any help is highly appreciated. Thanks in advance.

1

There are 1 answers

0
vel On

Vertx event bus can communicate within a JVM.

It was my mistake that I configured the event bus interceptor, but did not completed the chain by calling context.next().