.NET Quickstart

Overview

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.

**Early Release**

This is an early release, and under development. We are actively looking for feedback while we develop our .NET client, and work with the community on rsocket-net.

Prerequisites

You need the following items installed on your machine to run the quickstart:

Get Started

Follow the steps below to get up and running with Netifi quickly.

  1. Clone Quickstart Project

    Clone the .NET Quickstart project from Github.

    git clone -b 1.6.9 --single-branch https://github.com/netifi/netifi-quickstart-net.git
  2. Build the Project

    After you have cloned the project change to the netifi-quickstart-net directory and build the project:

    cd netifi-quickstart-net
    ./gradlew build
  3. 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.9
  4. Start the Example Service

    Back in the netifi-quickstart-net directory start up the service by running the following command:

    dotnet run -p Netifi.Quickstart.Server

    This will startup a simple service that connects to the broker.

  5. Run the Example Client

    Open another terminal window and go the netifi-quickstart-net directory. This time instead of starting the service, use a client to send a message. This can be done by running the following command:

    dotnet run -p Netifi.Quickstart.Client

    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:

    $ dotnet run -p Netifi.Quickstart.Client
    ...
    Sending 'World' to HelloService...
    0001 Payload {160|HasMetadata|IsComplete|IsNext}, Metadata[0], Data[14]
    Hello, World
    ...

    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:

    2019-09-16 07:13:28,002 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-3] new destination connection from access key 9007199254740991, connectionId 9d04e135-6106-45ba-8600-a1fdbed0b53a and group quickstart.services.helloservices
    2019-09-16 07:13:28,032 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-3] adding destination 9d04e135-6106-45ba-8600-a1fdbed0b53a to group quickstart.services.helloservices
    2019-09-16 07:13:28,032 INFO c.n.b.a.ClusterSocketAcceptor [reactor-tcp-epoll-3] adding destination 9d04e135-6106-45ba-8600-a1fdbed0b53a with tags [tag(com.netifi.destination=helloservice)] to group quickstart.services.helloservices
    2019-09-16 07:14:02,574 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-4] new destination connection from access key 9007199254740991, connectionId 0fbe7a53-9212-43de-b151-721f75b049da and group quickstart.clients
    2019-09-16 07:14:02,585 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-4] adding destination 0fbe7a53-9212-43de-b151-721f75b049da to group quickstart.clients
    2019-09-16 07:14:02,586 INFO c.n.b.a.ClusterSocketAcceptor [reactor-tcp-epoll-4] adding destination 0fbe7a53-9212-43de-b151-721f75b049da with tags [tag(com.netifi.destination=client)] to group quickstart.clients
    2019-09-16 07:14:02,865 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-4] removing destination 0fbe7a53-9212-43de-b151-721f75b049da from group quickstart.clients
    2019-09-16 07:14:02,866 INFO c.n.b.a.ClusterSocketAcceptor [reactor-tcp-epoll-4] removing destination 0fbe7a53-9212-43de-b151-721f75b049da from group quickstart.clients
    2019-09-16 07:14:02,868 INFO c.n.b.a.BrokerSocketAcceptor [reactor-tcp-epoll-4] removing destination 0fbe7a53-9212-43de-b151-721f75b049da from destination map
Background Image

Check out our blog to learn more about Netifi and RSocket.

Read Our Blog