Is there a way to programmatically check the connectivity to SAP?

103 Views Asked by At

As a mulesoft developer, I want to programmatically check the connectivity to a SAP system, as it is done in AnypointStudio GUI by clicking the button "Test Connection".

Hitting the Test Connection Button

The Mulesoft connector used is the SAP JCO Connector.

Thank you

Below is my sap config global configuration:

<sap:sap-config name="SAP_CONFIG" doc:name="SAP Config" doc:id="c696ca6a-4ca6-4840-87ba-299b83f62179" >
        <sap:simple-connection-provider-connection username="${app.sap.hana.jcoUser}" password="${app.sap.hana.jcoPassword}" systemNumber="${app.sap.hana.jcoSysNr}" client="${app.sap.hana.jcoClient}"  language="${app.sap.hana.jcoLang}" >
            <reconnection>
                <reconnect-forever />
            </reconnection>
            <sap:message-server host="${app.sap.hana.jcoMsHost}" systemId="${app.sap.hana.jcoMsSysId}" group="${app.sap.hana.jcoMsGrpName}"/>
        <sap:extended-properties >
                <sap:extended-property key="jco.server.max_startup_delay" value="300" />
            </sap:extended-properties>
        </sap:simple-connection-provider-connection>
        <expiration-policy maxIdleTime="1" timeUnit="HOURS" />
    </sap:sap-config>   

Below is the flow that listens SAP IDOCs; enter image description here

When the connection is lost, it does not automatically reconnect.

1

There are 1 best solutions below

0
Kamuzu Banda On BEST ANSWER

Hello and thank you all for your support.

The reconnection issue has been fixed by adding the following 2 elements in the sap/jco connector configuration:

reconnection, expiration-policy

<sap:sap-config name="SAP_HANA" <sap:simple-connection-provider-connection <reconnection> <reconnect-forever frequency="5000"/> </reconnection> <sap:message-server ...... </sap:simple-connection-provider-connection> <expiration-policy maxIdleTime="2" timeUnit="MINUTES" /> </sap:sap-config>

Setting the expiration-policy

Setting the reconnection option