Hello, World!
The obligatory "Hello, World!", but it's a pretty cool design and implementation that you will really love. That's because it's a service that demonstrates the reactive platform components.

Your First Program

The xoom-helloworld example is a pinned repository on our GitHub VLINGO organization. To use to it learn, first clone the repository and build the project. Open a console/command window so you can build the xoom-helloworld artifact and start it by executing the built jar file.
Note that snapshot artifacts are hosted on GitHub, which requires credentials to be provided to Maven by way of it's ~/.m2/settings.xml. This is explained in more detail and with an example here.
1
$ git clone https://github.com/vlingo/xoom-helloworld.git
2
...
3
$ cd xoom-helloworld
4
$ mvn package
5
...
6
java -jar target/xoom-helloworld-withdeps.jar
7
...
8
$
Copied!
The above java command executes the jar on the default port 18080. If you would like to use a different port, you must provide it on the command line. This command uses port 8080.
1
$ java -jar target/xoom-helloworld-withdeps.jar 8080
Copied!
The following examples assume that you have started the service with the default port, 18080.
There are two resources, each with multiple endpoints. These are discussed next.

Hello Resource

The first resource is used to get "Hello, World!" and similar messages.
You may curl with GET methods on the following resources.
1
$ curl -i -X GET http://localhost:18080/hello
Copied!
The above curl responds with 200 OK and the content body entity "Hello, World!"
You may also provide a path parameter to indicate to whom the service should say "Hello". The second example responds with 200 OK and the content body entity "Hello, Me!"
1
$ curl -i -X GET http://localhost:18080/hello/Me
Copied!
In this Hello resource example there is only one component involved,io.vlingo.xoom.hello.infra.resource.HelloResource.

Greeting Resource

The second resource is a bit more involved, and is used to maintain any number of Greeting messages. These greetings have the following data associated with them.
  • id: a unique identity
  • message: a text message
  • messageChangedCount: the number of times the message text has changed since first being defined
  • description: a text description of the message
  • descriptionChangedCount: the number of times the description text has changed since first being defined
The first operation used is to define a new Greeting. To do so you POST a JSON object to the /greetings URI.
1
$ curl -i -X POST -H "Content-Type: application/json" -d '{"id":"","message":"Hey","messageChangedCount":"0","description":"Says Hey","descriptionChangedCount":"0" }' http://localhost:18080/greetings
Copied!
The resource will respond with (only the id could be different):
1
HTTP/1.1 201 Created
2
Location: /greetings/242
3
Content-Length: 105
4
5
{"id":"242","message":"Hey","messageChangedCount":0,"description":"Says Hey","descriptionChangedCount":0}
Copied!
Following this you may query the new Greeting. The Location of the new Greeting resource is /greetings/{someId}. Let's GET that resource.
1
$ curl -i -X GET http://localhost:18080/greetings/242
Copied!
You should see the following:
1
HTTP/1.1 200 OK
2
Content-Length: 105
3
4
{"id":"242","message":"Hey","messageChangedCount":0,"description":"Says Hey","descriptionChangedCount":0}
Copied!
Next PATCH the Greeting resource's message.
1
$ curl -i -X PATCH -H "Content-Type: application/json" -d '{"value":"Yo"}' http://localhost:18080/greetings/242/message
Copied!
The resource responds with the following. Note that the message has changed to "Yo", and the messageChangedCount is now 1. Also notice that the description and the descriptionChangedCount remain unchanged.
1
HTTP/1.1 200 OK
2
Content-Length: 104
3
4
{"id":"242","message":"Yo","messageChangedCount":1,"description":"Says Hey","descriptionChangedCount":0}
Copied!
Next PATCH the Greeting resource's description.
1
$ curl -i -X PATCH -H "Content-Type: application/json" -d '{"value":"Says Yo"}' http://localhost:18080/greetings/242/description
Copied!
The resource responds with the following. Note that the description has changed to "Says Yo", and the descriptionChangedCount is now 1.
1
HTTP/1.1 200 OK
2
Content-Length: 103
3
4
{"id":"242","message":"Yo","messageChangedCount":1,"description":"Says Yo","descriptionChangedCount":1}
Copied!
Now both the message and the description and the corresponding counts have all changed.
In this Greeting resource example there are various component sets involved. See the following source code.
1
io.vlingo.xoom.hello.Bootstrap
2
3
io.vlingo.xoom.hello.resource.GreetingResource
4
5
io.vlingo.xoom.hello.model.Greeting
6
io.vlingo.xoom.hello.model.GreetingEntity
7
io.vlingo.xoom.hello.model.GreetingState
8
9
io.vlingo.xoom.hello.infra.persistence.GreetingProjectionActor
10
11
io.vlingo.xoom.hello.infra.persistence.Queries
12
io.vlingo.xoom.hello.infra.persistence.QueriesActor
13
14
io.vlingo.xoom.hello.infra.persistence.* - lower-level persistence setup and storage access
Copied!
Documentation for the above components is found in the following links.
Last modified 7mo ago