Clone Quickstart Project
Clone the Java Quickstart project from Github.
git clone -b 1.6.4 --single-branch https://github.com/netifi/netifi-quickstart-java.git
Build the Project
After you have cloned the project change to the netifi-quickstart-java directory and build the project:
cd netifi-quickstart-java ./gradlew build
Start the Broker
Once the project is built you need to start the broker. The Netifi Broker is packaged and distributed as a Docker container. To start the Broker run the following command in another terminal window:
docker run \ -p 7001:7001 \ -p 8001:8001 \ -p 8101:8101 \ -e BROKER_SERVER_OPTS=" \ '-Dnetifi.broker.ssl.disabled=true' \ '-Dnetifi.authentication.0.accessKey=9007199254740991' \ '-Dnetifi.authentication.0.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY=' \ '-Dnetifi.broker.admin.accessKey=9007199254740991' \ '-Dnetifi.broker.admin.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY='" \ netifi/broker:1.6.4
Start the Example Service
Back in the netifi-quickstart-java directory start up the service by running the following command:
This will startup a simple service that connects to the broker.
Run the Example Client
Open another terminal window and go the netifi-quickstart-java directory. This time instead of starting the service, use a client to send a message. This can be done by running the following command:
The client will startup, connect to the broker, and send a message to the service.
The following is approximately the expected output from the client:
$ ./gradlew :client:run ... i.n.s.Netifi [main] registering with netifi with account id 100, group quickstart.clients, and destination client1 i.n.p.q.c.Main [main] Sending 'World' to HelloService... i.n.p.q.c.Main [main] message: "Hello, World! from helloservice-2782cbee-1bcd-49c9-991c-fbb88c8e26d7" ...
The service logs should show that it has received the message:
i.n.p.q.s.DefaultHelloService [reactor-tcp-nio-4] received a message -> World
And the broker should show something akin to this:
i.n.r.a.RouterSocketAcceptor [reactor-tcp-nio-4] -4687034539111874558 - adding destination helloservice-2782cbee-1bcd-49c9-991c-fbb88c8e26d7 to group 100:quickstart.services.helloservices i.n.r.a.RouterSocketAcceptor [reactor-tcp-nio-1] -2050621438 - adding destination client1 to group 100:quickstart.clients i.n.r.b.RemoteLoadBalancedRSocket [reactor-tcp-nio-1] -2050621436 - creating load balancer for group quickstart.services.helloservices i.n.r.a.RouterSocketAcceptor [reactor-tcp-nio-1] -2050621438 - removing destination client1 from destination map i.n.r.a.RouterSocketAcceptor [reactor-tcp-nio-1] -2050621438 - removing destination client1 from group 100:quickstart.clients i.n.r.a.RouterSocketAcceptor [reactor-tcp-nio-1] -2050621438 - removing destination client1 from group quickstart.clients load balancer
In this quickstart you will create a service that receives a name from a client and responds to the client with a message. Communication between the client and service is facilitated by the Netifi Broker.
Follow the steps below to get up and running with Netifi quickly.
Now that you have a service, client, and broker successfully running. See if you can implement a ping-pong service whereby the client repeatedly pings the service, and the service always replies with a pong.
An example implementation is in the ping-pong-solution branch.