Multiple DOCKER Installation using WEB-UI and Java Client

I’am setting up two different Docker Containers metasfresh installations on the same docker Host. The WEB-UI Access ist on the same Docker Host URL and two different ports 80/81this is working fine.

I also have to Access this Installations with the Java Client because not everything in the WEB-UI ist working as expected. Now I have exported in the app and db containers the port on different port Numbers (example: metasfresh1/app Port:61616 -> 61616 metasfresh1/db Port:5432 -> 5432 metasfresh2/app Port:61616 -> 61618 metasfresh2/db Port:5432 -> 5434). If I connect with the java client then I have to define the Applikation Server and Applikation Port with this information the connection gets the DB Information from the app Server with calling the StatusService and is setting the DB Connection. Inside the metasfresh1 and metasfresh2 are the db ports 5432 (in different docker networks) in this situation StatusService always gets db Port 5432 and it is not possible to set it different in the connection Window.

To get a solution for this situation I had set Two Environments in the docker-composer METASFRESH_DB_HOST_ONCLIENT METASFRESH_DB_PORT_ONCLIENT and have changed the StatusService to read this variables an send to the client.

This is now working for me.

Do you think this is a good solution or are there better solutions.

Thanks for you opinion.

Hi @peterwyss64

Sure, if this works for you, it’s fine.

However there might be a different approach to handling multiple metasfresh-docker instances on a single server when using the Java client, we generally use internally for testing specific Client issues:

If you’re starting your client for the first time or if you remove the file metasfresh.properties stored on your client workstation, the initial configuration window will pop up, where you’re able to define the application-server and it’s port as well as the database-server and it’s port.

As you already mentioned: if calling the StatusService by hitting the “Test access to application” the rest of the fields for the database-connection will autofill with the information provided by the application-server.

However, if you do NOT click the “Test” button, you’re able to manually fill in the fields for the database-server yourself, which also let’s you define the port for the database-server you exposed in docker-compose.yml

In your example above, just fill in all fields like this, without clicking any “Test connection” button:

applications-server: mydockerhost
applications-port: 61618

Database-Type: PostgreSQL (default)
Database-Server: mydockerhost
Database-Port: 5434
Database-Name: metasfresh
User: metasfresh
Password: metasfresh    <-- you can change this when setting a different password for the metasfresh role in postgres

Now if you just hit the “Confirm-Button” at the bottom right corner of the window, the Java-Client will use exactly this configuration. And if you (as I assume from your message) correctly configured your firewall, dns, etc. the client will connect perfectly fine to the application-server and it’s corresponding database-server.

Also, if you log in to the application for the first time, these settings will automatically be saved in a new metasfresh.properties file, so you don’t have to enter them every time you start the client.

With this, you can experiment with eg. different properties-files for different users on your client workstations, which lets them connect to different servers.

Anyway, this is what we usually use in case we need to test multiple servers with Java clients running on the same docker-host, since it worked out fine for us.

If your solution works fine for you, the better :slight_smile: There’s more than one way to skin a cat (not that I’d approve of skinning a cat, you mind :wink: )

Please feel free to share your experience with metasfresh with us any time and I hope I could help you with my answer.

Kindly,
Julian

Hi Julian

Thank you very much for your explanation. Your way ist much better, my problem was that i didn’t realised to remove the properties file, because only with a new properties file it is possible to fill in all the fields and I was never able to fill in all the fields.

Thank you

You’re welcome :slight_smile:

By the way, you don’t really need to remove the properties file so you can fill in new information manually, if you already have valid entries “greyed out”:

Just modify the “application server” field and type in random text. After hitting the “Test” button, the Java Client will complain and pop up an error window, not being able to connect to broker. If you close the error window, voilá - the fields are now editable.

This is of course a “quick and dirty” way as opposed to the clean “remove properties file” way.

But for quick testing this should suffice :wink: