Vertx-sync update

460 views
Skip to first unread message

Tim Fox

unread,
Jul 1, 2015, 11:59:20 AM7/1/15
to ve...@googlegroups.com
I've playing around some more with vertx-sync the last couple of days,
and I've got it now using codegen to automatically generate sync style
APIs from other codegen APIs.

I've applied this to vertx-sql-common and vertx-jdbc-client and created
a simple example which demonstrates doing some JDBC stuff in a
synchronous, but non blocking (kernel threads) way:

https://github.com/vert-x3/vertx-examples/blob/examples-3.1.0/jdbc-examples/src/main/java/io/vertx/example/jdbc/query_sync/JDBCExampleSync.java

It's basically the same example as the async JDBC example:

https://github.com/vert-x3/vertx-examples/blob/examples-3.1.0/jdbc-examples/src/main/java/io/vertx/example/jdbc/query_params/JDBCExample.java

But this time, sync

Asher Tarnopolski

unread,
Jul 1, 2015, 2:02:44 PM7/1/15
to ve...@googlegroups.com
vertx-sync will be a killer

bytor99999

unread,
Jul 1, 2015, 2:11:46 PM7/1/15
to ve...@googlegroups.com
Very slick.

Mark

On Wednesday, July 1, 2015 at 11:02:44 AM UTC-7, Asher Tarnopolski wrote:
vertx-sync will be a killer

Oren Shvalb

unread,
Jul 3, 2015, 8:52:16 AM7/3/15
to ve...@googlegroups.com
Have you compared between both solutions in terms of performance?
Message has been deleted

Terry Bleger

unread,
Jul 3, 2015, 1:33:43 PM7/3/15
to ve...@googlegroups.com
Hi Tim,

That looks great.

Btw, where can I find the JDBCClientSync file?

Behind the scene, do you still use vertx.executeBlocking? Because I tried to use Fiber before and if I don't put the blocking code inside executeBlocking vertx will still complain about blocking the thread.

Terry Bleger

unread,
Jul 3, 2015, 7:29:10 PM7/3/15
to ve...@googlegroups.com
Finally I think I can understand how to use Fiber with Vertx.

I'm sharing this gist for those who can't wait to use sync-able vertx. Hope will help.

Simon Gemmell

unread,
Jul 17, 2015, 5:48:49 AM7/17/15
to ve...@googlegroups.com
We have been using Quasar in all our stuff - it's amazing. Async code is so legible (looks like sync code)! Ends up looking like this:

@Override
public void handle(RoutingContext context) {
new Fiber<Void>() {
@Override
protected Void run() throws SuspendExecution, InterruptedException {
try {
StormpathAuthProvider stormpathAuthProvider = context.get("stormpathAuthProvider");
// The following is an async call that will suspend this fibre (not block!) until the HTTP response comes in!
JsonNode customData = stormpathAuthProvider.userCustomDataAsync(context.user().principal());
final OffsetDateTime now = OffsetDateTime.now();
...


We use a wrapper for http client requests that does the magic of turning it into a fibre so that we can do something like this:
ExpandedHttpClientResponse resp = FiberWrappers.sendHttpClientRequest(getCustomDataRequest);
// This occurs after the response is returned (in a non blocking manner).
if (resp.response.statusCode() != 200) {


I'm so impressed with fibres (and Quasar) that I sought out a thread to post to! It's so much simpler than nested code, and so much simpler than CompleteableFuture based code (which quickly becomes unreadable as we found out).

Only gotcha is that you have to remember that while it looks sync, it aint.

Simon Gemmell

unread,
Jul 17, 2015, 5:49:37 AM7/17/15
to ve...@googlegroups.com
Goes without saying that I am really looking forward to sync-vertx!

Les Novell

unread,
Dec 3, 2015, 1:14:19 AM12/3/15
to vert.x
Hey Tim, these examples look great.
How about the generated JDBCClient for use with vertx-sync, is that published somewhere yet?

Thanks,
Les

Clement Escoffier

unread,
Dec 3, 2015, 3:34:24 AM12/3/15
to ve...@googlegroups.com
-- 
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 http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/8c5c1551-9fa5-4861-b833-5022d486106e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages