Skip to content

How to run and integrate your local Qanary components written in Java

Aleksandr Perevalov edited this page Jul 27, 2022 · 1 revision

Tl;dr

Required prior knowledge

How to register the local component at a remote pipeline

Configuration

There are a few things which you need to configure first. One is spring.boot.admin.client.url in your component's application.properties file. It should contain the endpoint URL of the pipeline at which you want to register your component.

Then, there is server.port which will be the port on which your component will listen. Keep this port in mind for later when we start ngrok.

There is one last thing you need to configure. spring.boot.admin.client.instance.service-base-url is the URL to which requests to your component will be sent. Generally, this could be a domain pointing at a server, but if you want to run a component locally, you can use ngrok to forward requests to localhost. With a free plan, this is not very reliable because the subdomain can change, so you'd need to update it everytime. With a paid plan, you could use the --subdomain parameter, but if you don't need that level of consistency, e. g. for development or a showcase, the free tier is fine.

Forwarding requests to localhost using ngrok

ngrok is a free service which can forward requests from a publicly accessible URL to a local address. For privacy concerns, consult the ngrok privacy policy page

With ngrok installed, you first need to connect your account to your client. This can be done by running the command ngrok config add-authtoken TOKEN in a terminal. TOKEN should be replaced with your authentication token, which can be copied from this page. This token should not be shared as it can be used to use your account against your will.

Once your client has been authenticated, you can simply run ngrok http YOUR_PORT to expose the port YOUR_PORT which you specified in your component's application.properties file. Running this command will expose the specified port to the internet, so be sure there aren't any critical security vulnerabilities in your component which might allow an attacker to enter your system.

After running the command, ngrok should show you the exact URL which accepts the requests. Copy this URL and paste it as the value of spring.boot.admin.client.instance.service-base-url in your component's application.properties file. With the configuration being done and ngrok forwarding requests, you can now start your component. It should now be able to register itself successfully at the pipeline and process requests.

Clone this wiki locally