You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+44-24Lines changed: 44 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
:page-permalink: /
3
3
:page-github: vertx-howtos/service-proxy-howto
4
4
5
-
This document will show you how to bootstrap an Event Bus service using Vert.x Service Proxy module. As you will see, this approach is particularly useful when you want to design and consume a service on the event bus using plain Java interfaces.
5
+
This document will show you how to bootstrap an Event Bus service using Vert.x Service Proxy module.
6
+
As you will see, this approach is particularly useful when you want to design and consume a service on the event bus using plain Java interfaces.
6
7
7
8
== What you will build
8
9
@@ -12,7 +13,7 @@ We are going to deploy two verticles: the `BarmanVerticle` that exposes the serv
12
13
== What you need
13
14
14
15
* A text editor or IDE
15
-
* Java 8 higher
16
+
* Java 11 higher
16
17
* Maven
17
18
18
19
== Create a project
@@ -25,28 +26,37 @@ Here is the content of the `pom.xml` file you should be using:
25
26
include::pom.xml[]
26
27
----
27
28
28
-
You must import both `vertx-codegen` with `processor` classifier and `vertx-service-proxy`. We are going to use `vertx-web-client` to load the beer names.
29
+
You must import both `vertx-codegen` with `processor` classifier and `vertx-service-proxy`.
30
+
We are going to use `vertx-web-client` to load the beer names.
29
31
30
32
== Design the `BarmanService`
31
33
32
-
First, we must define our service interface. Under the hood, a code generator analyze it and generates the event bus message handler and the proxy class.
34
+
First, we must define our service interface.
35
+
Under the hood, a code generator analyze it and generates the event bus message handler and the proxy class.
<1> Add `@VertxGen` and `@ProxyGen` to trigger code generation
40
-
<2> Define the method that generates a new beer and adds it to the bill of the customer specified. When the beer is ready, It calls the `handler` with the new beer
45
+
<2> Define the method that generates a new beer and adds it to the bill of the customer specified.
46
+
When the beer is ready, the `Future` is completed.
41
47
<3> Define the method that retrieves the bill.
42
-
<4> Define the method that settles the bill. This is a fire and forget method
43
-
<5> Specify the method that creates a new proxy. `BarmanServiceVertxEBProxy` is the class name of the proxy that the code generator will create for us
48
+
<4> Define the method that settles the bill.
49
+
This is a fire and forget method.
50
+
<5> Specify the method that creates a new proxy.
51
+
`BarmanServiceVertxEBProxy` is the class name of the proxy that the code generator will create for us.
44
52
45
-
There are a couple of rules you must follow while defining the service interface. Look at http://vertx.io/docs/vertx-service-proxy/java/#_restrictions_for_service_interface[Restrictions for service interface] for more info.
46
-
In our interface we are using a couple of primitives and `Beer`, a POJO annotated as `@DataObject`.
47
-
If you want to use `@DataObject`s inside your interface, they must define both a constructor with only a `JsonObject` parameter and a `toJson()` method that returns a `JsonObject`
53
+
There are a couple of rules you must follow when defining the service interface.
54
+
Look at http://vertx.io/docs/vertx-service-proxy/java/#_restrictions_for_service_interface[Restrictions for service interface] for more info.
55
+
In our interface, we are using a couple of primitives and `Beer`, a POJO annotated as `@DataObject`.
56
+
If you want to use types annotated with `DataObject` inside your interface, they must define both a constructor with only a `JsonObject` parameter and a `toJson()` method that returns a `JsonObject`.
48
57
49
58
To trigger the code generation, you must also add in the same package of the interface a `package-info.java` with `@ModuleGen` annotation:
0 commit comments