Saturday, July 16, 2016

Getting Started with Vert.x

What is Vert.x ?


Vert.x is a toolkit for writing scalable, polyglot, reactive applications which run on the JVM. Vert.x is similar to Node.js as both provide an asynchronous API and as it is event-driven. 

Polyglot


Vert.x is written in Java, but we can use it with many languages like Java, Groovy, Ruby, Python, and even JavaScript. You can even mix and match languages. 

Reactive


Vert.x is asynchronous. It can be used to create highly concurrent applications. Vert.x allows to create multiple threads based on the number of CPU cores while only one process is executed. It handles the multi-threading so users can focus on implementing business logic. Developer won't have to worry about synchronization, deadlocks or data races.

Verticles


Verticles are building blocks of vert.x application. They are units which operate independently. It can simply said that running a vert.x application means running one or more verticles. Verticles communicate with each other using event bus. Vert.x has some command line tool which enable the developer to simply run the program without compiling it. 

How to install vert.x ?


Vert.x can be installed linux, Windows or OSX. Before installing, you need to have JDK 1.7.0 or later installed and JAVA_HOME added to the PATH variable. 

Linux

  • Download the latest version of vert.x from here.
  • Extract it to a place where it will stay permanent. (Extracted directory shouldn't be moved since path will be set accordingly).
  • Add vert.x/bin to PATH variable. Open a terminal and run the following command 
                          export PATH=$PATH:/path

      where
          path = absolute path to the bin directory of your vert.x extract

     eg:
                          export PATH=$PATH:/home/user/Vertx/bin


      If you are having trouble changing the PATH variable, see this.

  • Verify your installation by running the command 
                         vertx version

Windows

  • Download the latest version of vert.x from here.
  • Extract it to a place where it will stay permanent. (Extracted directory shouldn't be moved since path will be set accordingly).
  • Search for 'View Advanced System Settings' and select 'Environment Variables'
  • From 'System Variables' section, highlight 'Path' and click on 'Edit'
  • For windows 7 and 8 
          append ;path to the existing 'Variable Value'
          where
          path = absolute path to the bin directory of your vert.x extract

           eg:
                          ;C:\Users\User\Vertx\bin

  • For Windows 10 click 'New' and add the path with no semicolon. 
             eg:
                          C:\Users\User\Vertx\bin


Running Vert.x programs


Vert.x programs can be simply run using vert.x command line tools. 

eg: 
        vertx run myprogram.java
        vertx run myprogram.js
    


No comments:

Post a Comment

Optimized quick sort

In the previous article  we discussed about quick sort algorithm. In this article we are going to discuss about further optimizing quick sor...