on 2021 Jun 29 11:08 AM
Hi - I'm using the Java CAP sample to implement my own multi-tenant application running on BTP. So far everything is working as expected 🙂
I need to add some features that aren't covered in the sample and am looking for some guidance on how to achieve:
1. Programmatically create a custom route for the newly subscribed tenant. From a Node.js sample it looks like this is possible via a number of REST calls to different Cloud Foundry APIs. Is this also how it needs to be done from a CAP Java application also? Any guides on how to do this?
2. In the @After("Subscribe") event, I'd like to persist some tenant-specific information into the newly created tenant HDI container. It seems like i need to add the user/tenant context to be able to persist to the tenant schema, but I'm not sure how to do this. Any pointers on how to do this from CAP Java?
Once i have this working I would be happy to contribute it back to the sample application.
To answer question 2, this code does what i need:
@Autowired
private PersistenceService persistenceService;
@After(event = MtSubscriptionService.EVENT_SUBSCRIBE)
public void afterSubscription(MtSubscribeEventContext context) {
context.getCdsRuntime().requestContext().modifyUser(user -> user.setTenant(context.getTenantId())).run(
newContext -> {
persistenceService.run(Insert.into(<my entity>.class).entries(<data to insert>));
}
);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.