vertex-rabbitmq-client cannot conntect to server!!

1,053 views
Skip to first unread message

Sungkwon Eom

unread,
Sep 3, 2016, 12:44:36 AM9/3/16
to vert.x

Hello,


Thanks all of you  for dedication on amazing vert.x framework. !!


I'm trying to apply vertex-rabbitmq-client ( http://vertx.io/docs/vertx-rabbitmq-client/java/ ) to our vert.x tcp server.



I got a error message as follow when I try to connect to rabbitMQ server.


io.vertx.core.impl.NoStackTraceThrowable: Not connected



Did I miss something?

I confirmed python program can connect successfully.



Here is the java source to test. 

==================publisher=====================


JsonObject config = new JsonObject();

// Each parameter is optional

// The default parameter with be used if the parameter is not set

config.put("user", "client");

config.put("password", "client");

config.put("host", "147.6.130.123”); 

config.put("port", 5672);

config.put("virtualHost", "dataService");

config.put("connectionTimeout", 60); // in seconds

config.put("requestedHeartbeat", 60); // in seconds

config.put("handshakeTimeout", 60); // in seconds

config.put("requestedChannelMax", 5);

config.put("networkRecoveryInterval", 5); // in seconds

config.put("automaticRecoveryEnabled", true);


client = RabbitMQClient.create(vertx, config);


final Async async = context.async();

JsonObject message = new JsonObject().put("body", "Hello RabbitMQ, from Vert.x !");

client.basicPublish("ttlExchange", "", message, pubResult -> {

  if (pubResult.succeeded()) {

    System.out.println("Message published !");

    async.complete();

  } else {

System.out.println("adsdsfsdfasdfa");

    pubResult.cause().printStackTrace();

  }

});

muhammed senussi

unread,
Sep 7, 2016, 7:46:43 AM9/7/16
to vert.x
Same as what i got. https://groups.google.com/forum/?fromgroups=#!topic/vertx/qOzvec1xJsE
Still i got no solution. and it works fine when using rabbitmq java client, or spring rabbit client.

Paulo Lopes

unread,
Sep 7, 2016, 7:54:43 AM9/7/16
to vert.x
I think you're forgetting to connect to the server :)

you're missing something like:

client.start(v -> {
  // here do your code...
})

sudhir kumar

unread,
Oct 13, 2016, 7:29:34 AM10/13/16
to vert.x
Hi Lopes ,

Just for update , i have used that code too. I was following http://vertx.io/docs/vertx-rabbitmq-client/java/ for Vertx RabbitMQ Client . We have Rabbit MQ over AWS and is accessible from the box. However while creating client we are not getting channel and connection ,both are null. Not sure if anything additional we need to provide ?

 public void basicConsume(RabbitMQClient client) {
        client.start(v->{
            System.out.println("Started QQWERTYUI");
        });

        // Create the event bus handler which messages will be sent to
        this.vertx.eventBus().consumer("my.address", msg -> {
            JsonObject json = (JsonObject) msg.body();
            System.out.println("Got message: " + json.getString("body"));
        });

        // Setup the link between rabbitmq consumer and event bus address
        client.basicConsume("task_queue", "my.address", consumeResult -> {


Regards,
Sudhir

Clement Escoffier

unread,
Oct 13, 2016, 8:20:32 AM10/13/16
to ve...@googlegroups.com
Hi,

My guess is that you should not do client.basicConsume until the client has been started. 

So it would be: client.start(v-> {
    // You should probably check whether or not it has been successful by checking v.
    client.basicConsume(….)
}

Clement


-- 
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9ab324d0-956f-4f06-bf0e-761761400281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sudhir kumar

unread,
Oct 13, 2016, 8:33:26 AM10/13/16
to vert.x
Thanks for reply . Actually even i tried start lambda method while creating 'RabbitMQClient' instance . And got the same error, facing issue with connection.
Is it good to call client.basicConsume(….) on start method of Queue? 

Regards,
Sudhir

Tim Fox

unread,
Oct 13, 2016, 9:13:14 AM10/13/16
to vert.x
Your best bet is probably to look at the tests to get an idea of how to use it.
Message has been deleted

Harsha Jayaweera

unread,
Jan 23, 2020, 1:19:09 AM1/23/20
to vert.x
In consumer scenario following code worked for me

client.start(v->{
System.out.println("Started QQWERTYUI");
  client.basicConsumer(main_queue_name, rabbitMQConsumerAsyncResult -> {
if (rabbitMQConsumerAsyncResult.succeeded()) {
System.out.println("RabbitMQ consumer created !");
RabbitMQConsumer mqConsumer = rabbitMQConsumerAsyncResult.result();
mqConsumer.handler(message -> {
System.out.println("Got message: " + message.body().toString());
});
} else {
System.out.println("Error connecing...............");
rabbitMQConsumerAsyncResult.cause().printStackTrace();
}
});
});
Reply all
Reply to author
Forward
0 new messages