Hi Rohit,
Thank you for your guidance. I highly appreciate it.

I have created a database ofbiz_teanant1 and granted all privileges for it
to postgres user.
I am creating tenant on my local by gradle command:
*./gradlew createTenant -PtenantId=tenant1 -PtenantName="tenant1"
-PtenantReaders=seed,seed-initial -PdbPlatform=P -PdbIp=127.0.0.1
-PdbUser=postgres -PdbPassword=asd@1234*

I have made changes to AdminNewTenantData-PostgreSQL.xml to use
*ofbiz_@tenantId@*.

My tenant based login is working well on my backend application as it uses
the *login* method of *LoginWorker.java*.

I have allowed the frontend application to send tenantId along with other
credentials using a custom login service in groovy. I am able to log in
using tenantId in the react application. Password match is done using my
tenant database.

Real issue is coming in with the delegator and dispatcher. I am having
trouble setting them in global servlet context. The login method in
LoginWorker handles it well, but has trouble being invoked directly.

I created delegator using this:

*userTenantId = 'default' + '#' + context.tenantId;*

*tenantDelegator = DelegatorFactory.getDelegator(**userTenantId**)*

I need guidance on how it can be possible to set my new delegator and
dispatcher globally. Any help on this would be highly appreciated.

Looking forward to your reply.

Best regards

Anshul Goyal


On Wed, 21 May 2025 at 14:57, Rohit Koushal <rohit.kous...@hotwaxsystems.com>
wrote:

> *Hey Anshul,To bootstrap a tenant with specific data, you can create
> separate XML data files for each tenant and register them under
> tenant-specific data readers in ofbiz-component.xml then use the loadTenant
> Gradle task to load this data individually for each tenant.On the
> authentication side, OFBiz sets the tenant's context by associating a
> delegator (i.e. tenant's database connection object) into the
> ServletContext.This can be driven by either:*
>
>    - *Sending the userTenantId with every request in case of a stateless
>    application, or only once during login for a stateful application.*
>    - *Using tenant-specific subdomains configured via the TenantDomainName
>    entity, OFBiz will automatically identify the tenant behind the scenes.*
>
> *You can check more in ContextFilter.java on how it works.*
>
> *Thanks!!*
>
> On Wed, May 21, 2025 at 10:46 AM Anshul Goyal <anshe...@gmail.com> wrote:
>
> > Dear OFBiz Community,
> >
> > I hope this message finds you well.
> >
> > I’m following up on an email I sent a couple of days ago regarding best
> > practices for implementing multi-tenancy in Apache OFBiz, particularly in
> > the context of integration with an external React application.
> >
> > To reiterate, I’m currently working on enabling multi-tenant support in
> > OFBiz and am seeking recommendations on the most effective approach to:
> >
> >    -
> >
> >    Manage tenant-specific data and authentication
> >    -
> >
> >    Establish secure and scalable communication between the React frontend
> >    and the OFBiz backend.
> >
> > Any insights, examples, or guidance from the community on how to approach
> > this integration would be greatly appreciated.
> >
> > Looking forward to your valuable input.
> >
> > Best regards
> > Anshul Goyal
> >
>
>
> --
>
> *Kind Regards,*
> *Rohit Koushal | Engineering manager*
> *HotWax Systems* <http://www.hotwaxsystems.com/>
> *Plot no. 80, Scheme no. 78 Part 2, Near Brilliant Convention Center,
> Indore, M.P 452010*
> *Mobile: 9098461867*
>

Reply via email to