cancel
Showing results for 
Search instead for 
Did you mean: 

How to run scheduled jobs with SFSF Extension Account, Destination can't be found

Former Member
0 Kudos

Hello everyone,

Anyone already has used the ConnectivityConfiguration API ?

I need execute scheduled jobs and accordingly with sap.help I should use the authentication method with SAML2BearerAssertion using a technical user

I supplied the --technical-user-id in command neo hcmcloud-create-connection and the destination was created in subscription level

The application is supplied via subscription

In Java application, reading the documentation I tried this code, even with the destination created in sub account the result always is null ...

Context ctx = new InitialContext(); 
localConnectivityConfiguration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration");
localConnectivityConfiguration.getConfiguration("name of destination");

I also tried the method getConfiguration(String accountID, String DestinationName) with no success

Context ctx = new InitialContext(); 
localConnectivityConfiguration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration");
localConnectivityConfiguration.getConfiguration("AccountID", "name of destination");

How can i run the scheduled jobs in host and access destinations from consumer subaccount ?

accordingly with documentation ...

If you have two destinations with the same name, one configured on subaccount level and the other on application level, the getConfiguration() method will return the destination on subaccount level. The preference order is: subscription level -> subaccount level -> application level.

But this is not happening ...

Anyone already implemented scheduler with subscriptions or have faced something similar?

Accepted Solutions (1)

Accepted Solutions (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi Murilo,

Have you seen this blog?

When you schedule a task in Java, your application needs to execute the Destination API methods on a particular tenant (sub-account) in order to find the configuration. Check the Tenant API documentation.

So first you get the available subscriptions to your "global account" and later you call execute method with a callable object that will perform the calls to the destination API to retrieve the sub-account destinations and from there run any relevant Tasks.

Regards,
Ivan

Former Member
0 Kudos

Thank you for the answer Ivan,

SAP Support suggested the same as you...

For someone else here are the snippet of code

try {

    InitialContext ctx = new InitialContext();

    Context hostContext = (Context) ctx.lookup("java:comp/env");
    TenantContext tenantHostContext = (TenantContext) hostContext.lookup("TenantContext");

    for(Tenant tenant: tenantHostContext.getSubscribedTenants()){

        Map<String, String> lista = tenantHostContext.execute(tenant.getId(), classcallable);
        lista.toString();
} } catch (Exception e) { e.printStackTrace();
}
public class ClassCallable implements Callable<Map<String, String>>{
public Map<String, String> call() throws Exception {
this.sync()
}
public Map<String, String> sync() throws NamingException {
Map<String, String> lista = this.sync(); return lista; }
}
Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks for sharing! Much appreciated.

Answers (0)