Class AsyncRatingServiceClient

java.lang.Object
com.highdeal.cnd.message.AsyncRatingServiceClient
All Implemented Interfaces:
com.highdeal.barbus.ISSLContextProvider
Direct Known Subclasses:
AsyncBatchServiceClient, AsyncStatefulServiceClient, StatelessServiceClient

public abstract class AsyncRatingServiceClient extends Object implements com.highdeal.barbus.ISSLContextProvider
This abstract Java class provides common methods to open, close a connection, and send rating messages.
  • Field Details

    • NONE_TRANSACTION

      public static final int NONE_TRANSACTION
      Constant to return no usage transaction
      See Also:
    • MASTER_TRANSACTION

      public static final int MASTER_TRANSACTION
      Constant to return the master usage transaction
      See Also:
    • ALL_TRANSACTION

      public static final int ALL_TRANSACTION
      Constant to return all the usage transactions
      See Also:
    • ALL_TRANSACTION_AND_RECURRING

      public static final int ALL_TRANSACTION_AND_RECURRING
      Constant to return all the usage transactions and all the recurring/one-shot transactions
      See Also:
    • CHARGING_RESULT_WS

      public static final int CHARGING_RESULT_WS
      Constant to return usage charging result (when used in a SOAP Web Service).
      See Also:
    • CHARGING_RESULT_MSG

      public static final int CHARGING_RESULT_MSG
      Constant to return usage charging result (when used in a Java client).
      See Also:
    • CHARGING_RESULT_REST

      public static final int CHARGING_RESULT_REST
      Constant to return usage charging result (when used in a REST Web Service).
      See Also:
    • CANCELLED

      public static final int CANCELLED
      Constant to set up the resolution used when the time to live (TTL) is expired as canceled
      See Also:
    • CONFIRMED

      public static final int CONFIRMED
      Constant to set up the resolution used when the time to live (TTL) is expired as confirmed
      See Also:
  • Method Details

    • getSslContext

      public SSLContext getSslContext()
      Gets the SSL context used with secure connections.
      Specified by:
      getSslContext in interface com.highdeal.barbus.ISSLContextProvider
      Returns:
      The SSL context used with secure connections
    • setSslContext

      public void setSslContext(SSLContext sslContext)
      Sets the SSL context used with secure connections.
      Parameters:
      sslContext - The SSL context used with secure connections
    • connect

      public final void connect(String hostname, int hostport) throws IOException
      Connects this charging client to the distant SAP CC Core Server system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.

      This method is equivalent to: connect(hostname, hostport, -1, null);.

      Parameters:
      hostname - The name of the machine that hosts a dispatcher instance of the SAP CC Core Server system
      hostport - The communication port on which the server system waits for requests on TCP/IP channel used by the Message TCP/IP technical interface
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running, for example).
    • connect

      public final void connect(String hostname, int hostport, int timeout) throws IOException
      Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; A client timeout must be specified.

      This method is equivalent to: connect(hostname, hostport, null, timeout);.

      Parameters:
      hostname - The name of the machine that hosts a dispatcher instance of the SAP CC Core Server system
      hostport - The port on which the server waits for requests
      timeout - The timeout in milliseconds for each operation request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the operation request.
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running for example)
    • connect

      public final void connect(String hostname, int hostport, FoundLostRatingListener ratingListener) throws IOException
      Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.
      Parameters:
      hostname - The host name of the server
      hostport - The port on which the server waits for request
      ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example)
    • connect

      public final void connect(String hostname, int hostport, String bindAddress, int timeout, FoundLostRatingListener ratingListener) throws IOException
      Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.
      Parameters:
      hostname - The host name of the server
      hostport - The port on which the server waits for request
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
      ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost.
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example)
      IllegalArgumentException - if hostname is null or if the port is out of range
    • connect

      public final void connect(String hostname, int port, String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config) throws IOException
      Connects this message client with the Rating Instances.

      First of all, this client contacts the boot instance defined by the arguments hostname and port to get its instance map. Then this client opens connections with all the rating instances defined in the instance map.

      Parameters:
      hostname - The host name of the server
      port - The port on which the server waits for request
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
      ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost
      config - The service tuning configuration
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example).
      IllegalArgumentException - if hostname is null or if the port is out of range.
    • connect

      public final void connect(String hostname, int port, boolean secure, String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config) throws IOException
      Connects this message client with the Rating Instances.

      First of all, this client contacts the boot instance defined by the arguments hostname and port to get its instance map. Then this client opens connections with all the rating instances defined in the instance map.

      Parameters:
      hostname - The host name of the server
      port - The port on which the server waits for request
      secure - true if the connection to the server is secure
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
      ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
      config - The service tuning configuration
      Throws:
      IOException - if the client cannot connect to the server (if server is not running, for example).
      IllegalArgumentException - if hostname is null or if the port is out if range.
    • connect

      public final void connect(@Deprecated String systemName, InetSocketAddress... bootDispatcherAddresses) throws IOException
      Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.

      The use of the parameter systemName is deprecated since SAP Convergent Charging 2023.0. This client will use bootDispatcherAddresses as a boot rating instance address list to connect to the SAP CC system. The client opens connections with the discovered rater instances.

      Prerequisites: At least bootDispatcherAddresses must be provided.

      Parameters:
      systemName - The SAP CC system name
      bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
      Throws:
      IOException - if the client cannot connect to the server (if server is not running, for example)
      IllegalArgumentException - if some arguments are badly provided
    • connect

      public final void connect(@Deprecated String systemName, @Deprecated int lookupDuration, @Deprecated InetSocketAddress discoveryAddress, @Deprecated String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config, InetSocketAddress... bootDispatcherAddresses) throws IOException
      Connects this message client with the Rating Instances.

      The use of the parameters systemName, lookupDuration, discoveryAddress, bindAddress is deprecated since SAP Convergent Charging 2023.0. At least bootDispatcherAddresses must be provided.

      Parameters:
      systemName - The SAP CC system name
      lookupDuration - The system discovery lookup duration
      discoveryAddress - The lookup discovery address, which must be an IPv4 multicast address
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
      ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
      config - The service tuning configuration
      bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
      Throws:
      IOException - if the client cannot connect to the server (if server is not running, for example).
      IllegalArgumentException - if some arguments are badly provided
    • connect

      public final void connect(@Deprecated String systemName, com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses) throws IOException
      Connects this charging client with the Rating Instances.

      The use of the parameter systemName is deprecated since SAP Convergent Charging 2023.0. This client will use bootDispatcherAddresses as a boot rating instance address list to connect to the rating system. The client opens connections with the discovered rating instances.

      At least bootDispatcherAddresses must be provided.

      Parameters:
      systemName - The SAP CC system name
      bootDispatcherAddresses - a backup rating instance boot dispatcher list, provided only if for some reasons
      Throws:
      IOException - if the client cannot connect to the server (if server is not running, for example).
      IllegalArgumentException - if some arguments are badly provided
    • connect

      public final void connect(@Deprecated String systemName, @Deprecated int lookupDuration, @Deprecated InetSocketAddress discoveryAddress, @Deprecated String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config, com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses) throws IOException
      Connects this charging client with the SAP CC system by using the UDP discovery function.

      The use of the parameters systemName, lookupDuration, discoveryAddress, bindAddress is deprecated since SAP Convergent Charging 2023.0. This client will use bootDispatcherAddresses as a boot rating instance address list to connect to the rating system. The client opens connections with the discovered rating instances. At least systemName or bootDispatcherAddresses must be provided.

      Parameters:
      systemName - The Rating system name
      lookupDuration - The system discovery lookup duration
      discoveryAddress - The lookup discovery address, which must be an IPv4 multicast address
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
      ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
      config - The service tuning configuration
      bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
      Throws:
      IOException - if the client cannot connect to the server (if server is not running, for example)
      IllegalArgumentException - if some arguments are badly provided
    • connect

      public final void connect(InstanceMap imap, String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config) throws IOException
      Connects this charging client with the SAP CC system by using an instance map; A timeout must be specified.
      Parameters:
      imap - The instance map that describes the SAP CC system to connect to; Cannot be null.
      bindAddress - The address to bind to, can be null
      timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
      ratingListener - The FoundLostRatingListener that will be notified each time a rater instance will be found or lost.
      config - The service tuning configuration
      Throws:
      IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running, for example).
    • getConnectionStatus

      public ConnectionStatus getConnectionStatus()
      Returns the connection status of the client.
      Returns:
      the connection status of the client
    • isAtLeastOneConnectionIsRegistered

      public boolean isAtLeastOneConnectionIsRegistered()
      Return true if at least one of the connection to the dispatchers is registered, false otherwise.
      Returns:
      true if at least one of the connection to the dispatchers is registered, false otherwise
    • setUserCredentials

      public void setUserCredentials(String userId, String userPassword)
      Set the credentials that will be used to authenticate the client.
      Parameters:
      userId - the user identifier
      userPassword - the user password
    • setUserCredentials

      public void setUserCredentials(String userId, String userPassword, int authTimeout)
      Set the credentials that will be used to authenticate the client.
      Parameters:
      userId - the user identifier
      userPassword - the user password
      authTimeout - the user authentication timeout
    • isNoTimeout

      public final boolean isNoTimeout()
      Checks if this charging client handles timeout.
      Returns:
      true if the charging client handles timeout
    • setNoTimeout

      public final void setNoTimeout(boolean noTimeout)
      Sets that this charging client handles timeout.
      Parameters:
      noTimeout - true if your client handles timeout
    • setClientOpEventListener

      public final void setClientOpEventListener(ClientOpEventTopic topic, ClientOpEventListener listener)
      Sets the client operation event listener to the specified topics; It will be notified each time an event corresponding to the registered topics.
      • It is not possible to set null for the default topic.
      • If the listener is null, then the default listener is set (@link ClientOpEventTopic#DEFAULT).
      Parameters:
      topic - The topic to plug the client operation event listener to
      listener - The client operation event listener
    • getClientOpEventListener

      public final ClientOpEventListener getClientOpEventListener(ClientOpEventTopic topic)
      Gets the client operation event listener used by the client for the specified topic. If the topic is null the default topic listener is returned ( getClientOpEventListener(ClientOpEventTopic.DEFAULT) ). There is always a default listener for a specific topic.
      Parameters:
      topic - The topic plugged the client operation event listener
      Returns:
      not null
    • getTimeout

      public final int getTimeout()
      Returns the client communication timeout in milliseconds for each request (or -1 to wait indefinitely).
      Returns:
      The timeout in milliseconds, or -1 if no timeout has been defined
    • isConnected

      public final boolean isConnected()
      Gets the connected connection status.
      Returns:
      true if the charging client is connected and false otherwise.
    • close

      public final void close()
      Closes the connection with the connected SAP CC system; This method allows to release all the resources attached (sockets and buffers) in the charging client.
    • setBootMode

      @Deprecated public final void setBootMode(BootMode mode)
      Deprecated.
      Defines which API will be used to retrieve from the remote instances, the Instance Map needed for the connection. As BootMode.HTTP_BOOT_MODE and BootMode.HTTPS_BOOT_MODE are deprecated, this method is deprecated too.
      Parameters:
      mode - Is this method is deprecated and to use the Message TCP communication or is HTTP_BOOT_MODE to use the HTTP communication.
    • getBootMode

      public final BootMode getBootMode()
      Returns which API is used to retrieve from the remote instances, the Instance Map needed for the connection.
      Returns:
      MESSAGE_BOOT_MODE because BootMode.HTTP_BOOT_MODE and BootMode.HTTPS_BOOT_MODE are deprecated.
    • setHAEventListener

      @Deprecated public final void setHAEventListener(HAEventListener listener)
      Deprecated.
      Deprecated since version 0.0 of SAP CC

      Sets the HA listener dedicated to High Availability events; It will be notified each time the status of an instance of the connected SAP CC system has changed.

      Parameters:
      listener - The listener for High Availability events
    • addAuthenticationListener

      public void addAuthenticationListener(IAuthenticationListener listener)
      Add a listener which will be triggered by authentication events.
      Parameters:
      listener - the listener which will be triggered by authentication events