<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ vertx - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ vertx - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 27 Jul 2026 20:16:19 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/vertx/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to set up Vertx in Spring ]]>
                </title>
                <description>
                    <![CDATA[ By Rick Lee Spring is probably the most popular framework in the Java space. We all love its dependency injection and all that autowired/configuration magic. It makes unit testing a piece of cake. On the other hand, Vertx.io, which is a newer toolkit... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vertx-in-spring-39c2dd7bc2a9/</link>
                <guid isPermaLink="false">66c364861917b5c625ae4b07</guid>
                
                    <category>
                        <![CDATA[ Java ]]>
                    </category>
                
                    <category>
                        <![CDATA[ MySQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spring-boot ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vertx ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 11 Feb 2019 01:43:36 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*zOLXCXhrX_NgyWJf3KGmrQ.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Rick Lee</p>
<p><a target="_blank" href="https://spring.io/">Spring</a> is probably the most popular framework in the Java space. We all love its dependency injection and all that autowired/configuration magic. It makes unit testing a piece of cake.</p>
<p>On the other hand, <a target="_blank" href="https://vertx.io/">Vertx.io</a>, which is a newer toolkit/framework, is gaining traction in recent years. It is light-weight and supports fully asynchronous programming via event loop like Node.js and eventbus messaging like Akka. Also, the community has made quite a lot of asynchronous tools/db clients like <a target="_blank" href="https://vertx.io/docs/vertx-mysql-postgresql-client/java/">Async MySQL / PostgreSQL Client</a>, which make it another trendy choice besides Spring.</p>
<p>It seems that it’s tough to choose between Vertx and Spring for new projects, but the good news is they are indeed not mutually exclusive! The following is a simple example to illustrate the setup.</p>
<p>This example project is about deploying a Vertical in a Springboot application. The Vertical provides a function for querying MySQL using an Async MySQL client. The function can be called directly or via vertx.eventbus.</p>
<p>First of all, create a simple maven Springboot application. You can create it through <a target="_blank" href="https://start.spring.io/">Spring Initializer</a>. Then add the following to the pom.xml:</p>
<p>As we’re going to query mysql using <a target="_blank" href="https://vertx.io/docs/vertx-mysql-postgresql-client/java/">Async MySQL / PostgreSQL Client</a>, a very primitive MysqlClient.java is created and the MySQL configuration is put on the application.yaml.</p>
<p>Create a dummy user table with 2 fields and insert some data:</p>
<p>Optionally, create a repository class for accessing the user table:</p>
<p>Now we can create the vertical, which has a single method for handling MySQL queries.</p>
<p>Finally, create the Spring application and add a deployVerticle method with the @PostConstruct annotation.</p>
<p>If you run the Spring application, you will see the following System printout of “dbVerticle deployed” and it means the Verticle is running on the Spring application.</p>
<pre><code><span class="hljs-number">2019</span><span class="hljs-number">-02</span><span class="hljs-number">-11</span> <span class="hljs-number">08</span>:<span class="hljs-number">56</span>:<span class="hljs-number">27.110</span>  INFO <span class="hljs-number">29444</span> --- [ntloop-thread<span class="hljs-number">-0</span>] i.v.ext.asyncsql.impl.MYSQLClientImpl    : Creating configuration <span class="hljs-keyword">for</span> localhost:<span class="hljs-number">33062019</span><span class="hljs-number">-02</span><span class="hljs-number">-11</span> <span class="hljs-number">08</span>:<span class="hljs-number">56</span>:<span class="hljs-number">27.442</span>  INFO <span class="hljs-number">29444</span> --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService <span class="hljs-string">'applicationTaskExecutor'</span>dbVerticle deployed2019<span class="hljs-number">-02</span><span class="hljs-number">-11</span> <span class="hljs-number">08</span>:<span class="hljs-number">56</span>:<span class="hljs-number">27.848</span>  INFO <span class="hljs-number">29444</span> --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): <span class="hljs-number">8080</span> (http) <span class="hljs-keyword">with</span> context path <span class="hljs-string">''</span><span class="hljs-number">2019</span><span class="hljs-number">-02</span><span class="hljs-number">-11</span> <span class="hljs-number">08</span>:<span class="hljs-number">56</span>:<span class="hljs-number">27.853</span>  INFO <span class="hljs-number">29444</span> --- [           main] n.r.s.SpringVertxExampleApplication      : Started SpringVertxExampleApplication <span class="hljs-keyword">in</span> <span class="hljs-number">5.393</span> seconds (JVM running <span class="hljs-keyword">for</span> <span class="hljs-number">6.671</span>)
</code></pre><p>To test it, we can simply add a db query request right after the Verticle was deployed.</p>
<p>The console prints out the following:</p>
<pre><code>dbVerticle deployedsuccess[{<span class="hljs-string">"id"</span>:<span class="hljs-number">10466</span>,<span class="hljs-string">"username"</span>:<span class="hljs-string">"ricklee"</span>}][{<span class="hljs-string">"id"</span>:<span class="hljs-number">10468</span>,<span class="hljs-string">"username"</span>:<span class="hljs-string">"maryjohnson"</span>}]
</code></pre><p>This example illustrated how you can enjoy the facilities from both the Spring and Vertx world with a simple setup.</p>
<p>Source code here: <a target="_blank" href="https://github.com/rickcodetalk/spring-vertx-example">https://github.com/rickcodetalk/spring-vertx-example</a></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
