How to add multiple destinations for a java application in cloud foundry?

删除回忆录丶 提交于 2020-01-06 04:36:33

问题


I developed a Java application using S4Hana SDK. After deploying the application to SAP Cloud platform, I set the destinations as an environment variable with below command.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"}]'

Now, I would like to add a second destination for the same application. Can someone please help me?

Thanks, Sankeerth


回答1:


You can define multiple destinations in the environment variable. It is a JSON array.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"},{name: "ErpQueryEndpoint2", url: "https://URL", username: "USER", password: "PASSWORD"}]'

In the execute method in the virtual data model you can define which destination to use:

BusinessPartnerService service = new DefaultBusinessPartnerService();

final List<BusinessPartner> businessPartners =
        service.getAllBusinessPartner().execute(new ErpConfigContext("ErpQueryEndpoint2"));

However, better than using the environment variables is to use the destination service.

Step 4 of the SDK tutorials explains how to use this service: https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/

With that it is even possible to have destination configurations per tenant.



来源:https://stackoverflow.com/questions/49636397/how-to-add-multiple-destinations-for-a-java-application-in-cloud-foundry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!