cancel
Showing results for 
Search instead for 
Did you mean: 

JCoIDoc.Server stops receiving

Former Member
0 Kudos

We are using SAP Java Connector 2.1.8 and we have problem that sometimes our application stops receiving of IDOCs. It works good again if our application is restarted and makes new connection. We have an information that SAP system can mark our connected receiver (JCoIDoc.Server implementation) as offline and SAP will stop sending to us.

The solution should probably be implementation of JCO.ServerStateChangedListener, where we have to react correctly to change of status. None example or specification show how it must be done exactly. Does following code describe what we have to do? My example unregister and register new instance of JCoIDoc.Server in case of JCO.STATE_STOPPED.

Martin Zak


class SapIdocServer extends JCoIDoc.Server {
  ...
}
 
SapIdocServer myServer;
 
void startServer() {
      java.util.Properties srvProps = new java.util.Properties();
      ...
      java.util.Properties clntProps = new java.util.Properties();
      ...        
      JCO.addClientPool(JCO_POOL_NAME, SAP_POOL_CONNECTION_NUM, clntProps);
      jcoRepository = JCO.createRepository(jcoRepositoryName, JCO_POOL_NAME);
      idocRepository = JCoIDoc.createRepository(idocRepositoryName, JCO_POOL_NAME);
      
      mySapIdocServer = new SapIdocServer(srvProps, jcoRepository, idocRepository);
}
 
void stopServer() {
     mySapIdocServer.suspend();
}
 
class MyListener implements JCO.ServerStateChangedListener {
 
  serverStateChangeOccurred(Server server, int old_state, int new_state) {
    if ((new_state & JCO.STATE_STOPPED    ) != 0) {      
      stopServer(); // ending of not working server
      startServer(); // new start of server
    }
  }
  
}
 
void main() {
  ...
  startSever(); // start server when application start
  ...
}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The JCO.Server would reconnect automatically, if it recognizes a connection interruption. So you don't have to do this on your own. You also will not receive the STATE_STOPPED in this case. The issue is, that the server does not recognize an error and therefore does not stop.

Please see note [1494757|https://service.sap.com/sap/support/notes/1494757] for further explanations and recommendations on this.

Besides this, your coding looks correct at first sight, but unfortunately is useless.

Additionally, in a multi-application environment you should always check the passed Server instance in your listener interface. As the listeners are global, you would also be notified about events that are meant for other servers in your environment. So a the check like "server instanceof SapIdocServer" would make sure that the given event is for you.