Skip to Content
0

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

Mar 29 at 12:48 AM

39

avatar image
Former Member

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ivan Mirisola
Apr 02 at 01:18 PM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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; }
}
0

Thanks for sharing! Much appreciated.

0