These are chat archives for davidsowerby/krail

28th
Feb 2018
Marco Collovati
@mcollovati
Feb 28 2018 21:10
Hi
David Sowerby
@davidsowerby
Feb 28 2018 21:10
hi, how are you?
Marco Collovati
@mcollovati
Feb 28 2018 21:11
fine, thanks.And you?
David Sowerby
@davidsowerby
Feb 28 2018 21:11
Great - not sure why, but your avatar looks like you are not online
Hence the email
Marco Collovati
@mcollovati
Feb 28 2018 21:12
it the same for me
you seem not to be online
David Sowerby
@davidsowerby
Feb 28 2018 21:12
Ah, Ok never used Gitter before, seems a bit odd
Well, we are here now - do you want to start with your topics
Marco Collovati
@mcollovati
Feb 28 2018 21:13
Yes
David Sowerby
@davidsowerby
Feb 28 2018 21:13
Your first was - PUSH from background threads (new Thread vs Vertx.setTimer)
Marco Collovati
@mcollovati
Feb 28 2018 21:14
First of all
I deployed on heroku the example app
David Sowerby
@davidsowerby
Feb 28 2018 21:15
Ok, I'm logged in to it
Marco Collovati
@mcollovati
Feb 28 2018 21:15
In the last days a made some changes on session usage
David Sowerby
@davidsowerby
Feb 28 2018 21:16
Ok
Marco Collovati
@mcollovati
Feb 28 2018 21:16
I had trouble usign PUSH from backgorund thread due to serialization
so I decided to implement a sort of "near cache" session store implementation
this is a LocalMap backed by a ClusteredSessionStore
so the whole session is always propagated to the cluster
but the running instance uses a local cache
David Sowerby
@davidsowerby
Feb 28 2018 21:17
Neat
Marco Collovati
@mcollovati
Feb 28 2018 21:17
this way capturing object in background processes work fine
About background threads
In vertx it is highly recommended to not using blocking apis
like Thread.sleep, lock, etx
*etc
David Sowerby
@davidsowerby
Feb 28 2018 21:19
On the event loop, yes
Marco Collovati
@mcollovati
Feb 28 2018 21:19
Exactly
So I think that for background threads the best way will be using Vertx api
or the eventbus
Do you think there should be some vertx-vaadin API that offers the ability to run runnable in background?
David Sowerby
@davidsowerby
Feb 28 2018 21:21
Interesting thought.
Do you have use cases in mind?
Marco Collovati
@mcollovati
Feb 28 2018 21:22
not an use case, but i notice that updating ui from thread other than eventloop seem to cause VaadinSession deadlocks
so maybe having an api like VertxVaadin.runLater( () -> { .... })
can hide complexity of interaction with vertx api for vaadin users
David Sowerby
@davidsowerby
Feb 28 2018 21:25
If I understand correctly, you have a working solution Push using your "write through cache" approach?
  • for Push
Marco Collovati
@mcollovati
Feb 28 2018 21:25
yes
David Sowerby
@davidsowerby
Feb 28 2018 21:26
So the "api like VertxVaadin.runLater( () -> { .... })" would be for other situations where a developer currently uses the UI access() method?
Marco Collovati
@mcollovati
Feb 28 2018 21:27
It will not be a replace of ui.access
but a replacement for new Thread(() -> { .... }).start()
or CompletableFuture.runAsync()
David Sowerby
@davidsowerby
Feb 28 2018 21:27
Would it spawn a WorkerVerticle?
Marco Collovati
@mcollovati
Feb 28 2018 21:28
in order to use instead Vertx.setTimer or Vertx.setPeriodic
This is one idea
I didn't try the WorkerVerticle but it sounds a good solution
David Sowerby
@davidsowerby
Feb 28 2018 21:29
I haven't looked at those Vertx features, but if there is something in the Vaadin integration which cold cause errors, then yes it does seem sensible to offer a way to resolve them
Marco Collovati
@mcollovati
Feb 28 2018 21:30
I will investigate on WorkerVerticle
David Sowerby
@davidsowerby
Feb 28 2018 21:31
I think there is also a question of distributed application design
Vaadin is usually used in a monolithic way, and running background threads as part of that
As you said earlier, in many cases it would be better to fire an event over the eventbus to another service to do the work and return a response when done
Perhaps the first question to ask is whether a Vaadin application should run background threads on Vertx?
Marco Collovati
@mcollovati
Feb 28 2018 21:33
Good point
David Sowerby
@davidsowerby
Feb 28 2018 21:34
There may be good uses cases for it, but actually I think I would discourage it
Essentially that is all a WorkerVerticle is doing, offloading a blocking task away from the event loop
I'm not impressed with Gitter, I can't tell whether you are typing!
Marco Collovati
@mcollovati
Feb 28 2018 21:37
Did we switch to anoter tool?
David Sowerby
@davidsowerby
Feb 28 2018 21:37
Do you have a preference? Hangouts maybe?
Marco Collovati
@mcollovati
Feb 28 2018 21:38
never used, but we can try
David Sowerby
@davidsowerby
Feb 28 2018 21:38
Ok, I'm just starting it up
I've invited you