Increase EventBus timeout

784 views
Skip to first unread message

jp gouin

unread,
Feb 22, 2018, 11:02:11 AM2/22/18
to vert.x

Hi,

I would like to know how to setup a timeout on the eventbus  when it's clustered (Infinispan) into openshift (minishift).

I would like to increase the 30 second timeout.

I've tried to set the DeliveryOptions but it only seems to work when i start my micro services locally.

This is what i've tried : 

  DeliveryOptions options = new DeliveryOptions().setSendTimeout(200000);
        
    Single<String> obs1 = vertx.eventBus()
                .<String>rxSend("troubleshooting", metadata.toString(),options).subscribeOn(io.vertx.rxjava.core.RxHelper.scheduler(vertx)).retry(2).timeout(5, TimeUnit.MINUTES)
                .map(Message::body);
    obs1.subscribe(
    x -> rc.response().end(x),
                t -> rc.response().setStatusCode(500).end(t.getMessage())
    );

The troubleshooting handler perform a long task and then send a reply.



Thanks !

Thomas SEGISMONT

unread,
Feb 23, 2018, 9:36:07 AM2/23/18
to ve...@googlegroups.com
Hi,

The sendTimeout is not handled by the cluster manager but by the event bus implementation in Vert.x core.
Can you provide more details about your deployment?

Thanks

--
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+unsubscribe@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/1aaf76dc-95ec-426e-b89f-87f3e0d79d37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jp gouin

unread,
Feb 23, 2018, 9:53:05 AM2/23/18
to vert.x
Ok , so how can i increase the 30 second timeout ?

I have an application which is composed of 5 services deployed into minishift (for test puprose) using Kubernetes and Docker.

I use Infinispan as the cluster manager but i have no obligation about that (if the problem come from infinispan i can use another one).

Here is a snap of my code : 

public class ServerService extends AbstractVerticle {
Logger LOG = LoggerFactory.getLogger(ServerService.class);
@Override
    public void start() {
    Router router = Router.router(vertx);

        Set<String> allowedHeaders = new HashSet<>();
        allowedHeaders.add("x-requested-with");
        allowedHeaders.add("Access-Control-Allow-Origin");
        allowedHeaders.add("origin");
        allowedHeaders.add("Content-Type");
        allowedHeaders.add("accept");
        allowedHeaders.add("X-PINGARUNER");

        Set<HttpMethod> allowedMethods = new HashSet<>();
        allowedMethods.add(HttpMethod.GET);
        allowedMethods.add(HttpMethod.POST);
        allowedMethods.add(HttpMethod.OPTIONS);
        /*
         * these methods aren't necessary for this sample, 
         * but you may need them for your projects
         */
        allowedMethods.add(HttpMethod.DELETE);
        allowedMethods.add(HttpMethod.PATCH);
        allowedMethods.add(HttpMethod.PUT);
        
        router.route().handler(CorsHandler.create("*").allowedHeaders(allowedHeaders));
   
    router.route().handler(BodyHandler.create());
    router.get("/").handler(this::invokeMySecondMicroService);
    router.post("/investigation").handler(this::troubleshootingTreeHandler);

        vertx.createHttpServer()
        .requestHandler(router::accept)
        .listen(8080);
}

  private void troubleshootingTreeHandler(RoutingContext rc) {
   
      // The body has now been fully read, so retrieve the form attributes
        MultiMap formAttributes = rc.request().formAttributes();
        Gson gson = new Gson();
        JsonObject metadata = new JsonObject();
        
        for (Map.Entry<String, String> entry : formAttributes.getDelegate().entries()) {
        LOG.info(entry.getValue());
            metadata.add(entry.getKey(), gson.fromJson(entry.getValue(), JsonElement.class));
}

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.

Thomas SEGISMONT

unread,
Feb 26, 2018, 8:28:35 AM2/26/18
to ve...@googlegroups.com
2018-02-23 15:53 GMT+01:00 jp gouin <gouin.jea...@gmail.com>:
Ok , so how can i increase the 30 second timeout ?

With DeploymentOptions.setSendTimeout. I only meant that, as long as the cluster is well formed, the eventbus send timeout is not a cluster manager concern.
I just tried to reproduce and here are my findings:

- the HTTP request fails, with status 504

This is not Vert.x related, it's just the proxy timing out requests which takes longer than 30 seconds.

- when settings sendTimeout to a low value (500ms), the http request fails with a Vert.x timeout message.

So I suspect your issue is with the proxy timeout. Can you confirm?

Also, in the RxJava code I would

1/ simply create a scheduler for the verticle:

// Init a verticle field at the beginning of the start method
scheduler = RxHelper.scheduler(vertx.getOrCreateContext());

2/ provide this scheduler on the timeout operation

.timeout(5, TimeUnit.MINUTES, scheduler)

3/ remove the subscribeOn operation (useless)

jp gouin

unread,
Feb 27, 2018, 3:10:04 AM2/27/18
to vert.x
Thanks for the answer.

You are rigth , i have a 504 error message and when i set the DeliveryOption timeout under 30 sec i have a vertx error message.

I will change my code with your suggestion.

How can i specify the DeploymentOptions , in the init method ?

Thomas SEGISMONT

unread,
Feb 27, 2018, 4:24:07 AM2/27/18
to ve...@googlegroups.com
2018-02-27 9:10 GMT+01:00 jp gouin <gouin.jea...@gmail.com>:
Thanks for the answer.

You are rigth , i have a 504 error message and when i set the DeliveryOption timeout under 30 sec i have a vertx error message.

I will change my code with your suggestion.

How can i specify the DeploymentOptions , in the init method ?

Sorry for the confusion, it's actually DeliveryOptions.setSendTimeout which drives the eventbus timeout.
 

--
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+unsubscribe@googlegroups.com.

jp gouin

unread,
Feb 27, 2018, 5:28:43 AM2/27/18
to vert.x
Ok but i already got the DeliveryOption setup with a large timeout.

so how can i increase the timeout from the proxy ?
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.

jp gouin

unread,
Feb 27, 2018, 8:18:51 AM2/27/18
to vert.x
I solved my problem , thanks for your help !

As you pointed out the problem came from the timeout of the route deployed by kubernetes. 
Using openshift command i increased the timeout and now it's working

Thomas SEGISMONT

unread,
Feb 27, 2018, 8:22:28 AM2/27/18
to ve...@googlegroups.com
Thanks for letting us know. Would you mind to share the command here ?

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

Clement Escoffier

unread,
Feb 27, 2018, 8:29:27 AM2/27/18
to ve...@googlegroups.com
Hi,

Yes, I would be very interested to know how you increase the timeout on a route. It is an attribute of the route (can’t find it)? or do you need to rebuild the router.

Clement

jp gouin

unread,
Feb 28, 2018, 3:14:43 AM2/28/18
to vert.x
You don't have to rebuilt the route , but juste annotate it.

Using the following command , it will change the timeout of the route "myroute" to 2 seconds
oc annotate route myroute --overwrite haproxy.router.openshift.io/timeout=2s

And into openshift , into the Applications->routes , select your route and click on "show annotations".
You will see the your new timeout.


Clement

Thomas SEGISMONT

unread,
Feb 28, 2018, 6:22:46 AM2/28/18
to ve...@googlegroups.com
Thanks for sharing

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages