mDNS

A Quarkus extension allowing use of Multicast DNS or mDNS to expose service advertisement as well as discover other services on your network.

mDNS is sometimes also called ZeroConf/Bonjour/Avahi/Rendezvous and can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration networking technique specified separately in RFC 6763.

Installation

If you want to use this extension, you need to add the io.quarkiverse.mdns:quarkus-mdns extension first to your build file.

For instance, with Maven, add the following dependency to your POM file:

<dependency>
    <groupId>io.quarkiverse.mdns</groupId>
    <artifactId>quarkus-mdns</artifactId>
    <version>1.0.2</version>
</dependency>

Service Advertisement

mDNS by default will advertise your Quarkus server for HTTP discovery using the default application name.

All this is configurable, for example:

quarkus.http.host=0.0.0.0
quarkus.http.port=8081
quarkus.application.name=integration

Will expose your server on mDNS as http://integration.local:8081 as an HTTP service type _http._tcp.local..

quarkus.http.host must be set to 0.0.0.0 for the local URL http://integration.local:8081 to work properly. In dev/test mode this defaults to localhost which means the mDNS URL will not work.

Or you can inject it manually and expose any service you like. For example, this would expose it as supporting Apple TouchRemote on port 1024.

@Inject
JmDNS jmdns;

public void advertise() {
    Map<String, String> props = new HashMap<>();
    props.put("DvNm", "Quarkus Client");
    props.put("RemV", "10000");
    props.put("DvTy", "iPod");
    props.put("RemN", "Remote");
    props.put("txtvers", "1");
    ServiceInfo serviceInfo = ServiceInfo.create("_touch-remote._tcp", hostName, 1024, 0, 0, props);
    jmdns.registerService(serviceInfo);
}

Service Discovery

You may also use mDNS to discover other services on your network by using the injectable component. For example if you wanted to discover all the Apple Airport _airport._tcp.local. devices on your local network.

@Inject
JmDNS jmdns;

public void listServices() {
    ServiceInfo[] infos = jmdns.list("_airport._tcp.local.");
    for (ServiceInfo info : infos) {
        System.out.println(info);
    }
}

Will expose your server on mDNS as http://myserver:8081 as an HTTP service type _http._tcp.local..

Extension Configuration Reference

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Indicate if the extension should be enabled. Enabled in DEV mode by default if not explicitly disabled.

Environment variable: QUARKUS_MDNS_ENABLED

boolean

Host name to advertise in mDNS, will use the quarkus.application.name then machine name if left blank.

Environment variable: QUARKUS_MDNS_HOST

string

Fully qualified service type name, such as _http._tcp.local.

Environment variable: QUARKUS_MDNS_TYPE

string

_http._tcp.local.

Weight of the service

Environment variable: QUARKUS_MDNS_WEIGHT

int

0

Priority of the service

Environment variable: QUARKUS_MDNS_PRIORITY

int

0

Extra properties to append into the service

Environment variable: QUARKUS_MDNS_PROPS__PROPS_

Map<String,String>