I have to implement the both techniques in grails 4:
Is it possible? if yes than how?
Yes, Grails 4 does support both, Multi-Datasources and Multi-Tenancy.
More specifically, Grails supports:
From the official documentation, here is how to do Multi-Datasources:
Multi-Tenancy is supported by GORM (the Grails' Object Relational Mapping) since GORM 6.0, introduced with Grails 3.2
From the official documentation, here is how to do Multi-Tenancy:
I have succesfully implemented Multi-Tenancy on two different Grails Projects. One of them was on a previously working application, and the adaptation was pretty straightforward using the DISCRIMINATOR approach.
Here a couple of tutorials on Multi-Tenancy with Grails, one using the DATABASE approach, and the other using the DISCRIMINATOR approach: