Class StatelessServiceClient
- All Implemented Interfaces:
com.highdeal.barbus.ISSLContextProvider
Java class allows your client application to send some stateless rating and prerating events
to the connected SAP CC Core Server system by using the
Message TCP high-speed technical interface.
Consider the following information in this topic:
- Synchronous Services and Operations
- Features
- Implementation in Your Client Application
- Notes on SAP CC Implementation
Synchronous Services and Operations
Deprecated Services and Operations
The following business operations or services are now deprecated and replaced. SAP SE recommends that you do not implement these operations anymore. They will be revoked in newer versions of SAP Convergent Charging.
| Business Services | Deprecated Operations | Technical Names (Consider the methods in this Java class) | Replaced by |
|---|---|---|---|
| Non authenticated server connection | All class builders (except the empty one) that connect the client to the server without user credentials. | Replaced by the StatelessServiceClient() + a call to AsyncRatingServiceClient.setUserCredentials(String, String) then a call to one of the following methods to connect the client:
|
Features
This rating and charging client benefits from
the functions provided by the Message TCP technical interface.
Refer to its features about:
- High Availability Management
- High Volume Management
- High Performance Management
Communication Timeout
When a timeout is associated to a given message client, it must be performed during this limited time.
If this limited time is exceeded, the operation is rolled back but client timeout does not guarantee that related
operations successfully ended (see Technical Reference Guide).
High Performances
By default, this charging client provides high throughput performances
and very low latency responses.
For very high troughput performances, consider the fine-tuning activity.
High Availability (HA)
By default, this charging client provides high availability services with an SAP CC system with distributed instances in HA setup.
Security
To implement user authentication between the client and SAP CC, the client must set up some valid user credentials by calling the setUserCredentials() method.
Then, the client application will be authenticated and authorized to connect to the SAP CC server by calling one of the following connect() methods:
Code Snippet
The following code snippet provides an example of how to authenticate a client application to the SAP CC server :
private static final String DISPATCHER_HOST = "localhost";
private static final int DISPATCHER_EXT_PORT = 2000;
// Initialize the stateless service client by (always) calling the empty builder (other builders are deprecated)
StatelessServiceClient client = new StatelessServiceClient();
// Set the user credentials for the new created client
// These credentials must refer to an existing service user in SAP CC having the "messageChargingClient" role.
client.setUserCredentials("clientX", "foopasswd");
//Call one of the connect() methods that are provided in the Service Client classes according to the
// expected behavior.
ConnectionStatus status = client.connect(DISPATCHER_HOST, DISPATCHER_EXT_PORT);
// Check the result of the connect() method.
if (!status.isServiceAvailable()) { // No dispatcher can be reached
} // else at least one CC dispatcher has been reached and charging is available
Implementation in Your Client Application
Initializing and Connecting
Your charging client (based on this StatefulServiceClient class)
must be initialized via establishing a connection to one of more dispatcher instances available in the distant SAP CC system.
Once at least one dispatcher of the SAP CC system is connected from the client application,
the client application retrieves automatically the list of all available dispatcher instances
on the server system side. It establishes a connection with every one of them automatically.
Implementing Event-Based Rating Services
Depending on your business requirements, you implement one of the following operations in your Java-based client application:
Additional Information
Consult all the online and offline charging services that you can implement in your Java-based client application and in your system landscape.
Consult the SAP CC Application Help for more information about the online charging services, the charging process and its execution modes (stateless, stateful).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class com.highdeal.cnd.message.AsyncRatingServiceClient
ALL_TRANSACTION, ALL_TRANSACTION_AND_RECURRING, CANCELLED, CHARGING_RESULT_MSG, CHARGING_RESULT_REST, CHARGING_RESULT_WS, CONFIRMED, MASTER_TRANSACTION, NONE_TRANSACTION -
Constructor Summary
ConstructorsConstructorDescriptionCreates a non-initialized stateless service client in your client application.StatelessServiceClient(String hostName, int port) Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection.StatelessServiceClient(String hostName, int port, int timeout) Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection.StatelessServiceClient(String hostName, int port, FoundLostRatingListener ratingListener) Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection.StatelessServiceClient(String hostName, int port, FoundLostRatingListener ratingListener, int timeout) Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection.StatelessServiceClient(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout) Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect(InstanceMap imap, String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config) voidconnect(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout) Connect this stateless service client using the round robin with the server.voidconnect(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config) Connect this stateless service client using the round robin with the server.statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, boolean withDetails, ChargeableItem newCi) This method is dedicated to the stateless post-rating.statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, String[] retainedDetails, ChargeableItem newCi) Similar tostatelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details.statelessPreRate(StatelessRatingEvent ratingEvent, String chargeCode, StatelessPreRatingContext preRatingContext, Date ratingDate, long reservationUID, long postrateDeadline, boolean withDetails, boolean checkDates) This method is dedicated to the stateless pre-rating.statelessPreRate(StatelessRatingEvent ratingEvent, String chargeCode, StatelessPreRatingContext preRatingContext, Date ratingDate, long reservationUID, long postrateDeadline, String[] retainedDetails, boolean checkDates) Similar tostatelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details.statelessRate(String chargeCode, Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, boolean withDetails, boolean checkDates) This main business operation requests the SAP CC system to rate (dynamically determine the price)statelessRate(String chargeCode, Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, String[] retainedDetails, boolean checkDates) Similar tostatelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details.Object[]Translates some values by using aninstance of translation table.Object[]Translates some values by using a translation table.Methods inherited from class com.highdeal.cnd.message.AsyncRatingServiceClient
addAuthenticationListener, close, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getBootMode, getClientOpEventListener, getConnectionStatus, getSslContext, getTimeout, isAtLeastOneConnectionIsRegistered, isConnected, isNoTimeout, setBootMode, setClientOpEventListener, setHAEventListener, setNoTimeout, setSslContext, setUserCredentials, setUserCredentials
-
Field Details
-
POST_RATE_CONFIRMATION
public static final int POST_RATE_CONFIRMATION- See Also:
-
POST_RATE_CANCELLATION
public static final int POST_RATE_CANCELLATION- See Also:
-
-
Constructor Details
-
StatelessServiceClient
Creates a non-initialized stateless service client in your client application.One of the methods
connect()must then be used to connect it to the SAP CC system.- Throws:
IOException- if an error occurred reading the currency resources.
-
StatelessServiceClient
Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. Creates a stateless service client and connect it to a server.- Parameters:
hostName- The host name of the serverport- The port on which the server waits for request- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
-
StatelessServiceClient
@Deprecated public StatelessServiceClient(String hostName, int port, int timeout) throws IOException Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. Creates a stateless service client and connect it to a server.- Parameters:
hostName- the host name of the server.port- the port on which the server waits for request.timeout- the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
-
StatelessServiceClient
@Deprecated public StatelessServiceClient(String hostName, int port, FoundLostRatingListener ratingListener) throws IOException Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. Creates a stateless service client and connect it to a server.- Parameters:
hostName- the host name of the server.port- the port on which the server waits for request.ratingListener- the listener informed when rating is found or lost.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
-
StatelessServiceClient
@Deprecated public StatelessServiceClient(String hostName, int port, FoundLostRatingListener ratingListener, int timeout) throws IOException Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. Creates a stateless service client and connect it to a server.- Parameters:
hostName- the host name of the server.port- the port on which the server waits for request.ratingListener- the listener informed when rating is found or lost.timeout- the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
-
StatelessServiceClient
@Deprecated public StatelessServiceClient(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout) throws IOException Deprecated.Deprecated since version 4.1 SP2 of SAP CC and replaced by the empty builder and an authenticated connection. Creates a stateless service client and connect it to a server.- Parameters:
hostName- the host name of the server.port- the port on which the server waits for request.bindAddress- address to bind description.ratingListener- the listener informed when rating is found or lost.timeout- the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
-
-
Method Details
-
connect
public void connect(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout) throws IOException Connect this stateless service client using the round robin with the server.- Parameters:
hostName- the host name of the server.port- the port on which the server waits for request.bindAddress- the address to bind description.ratingListener- theFoundLostRatingListenerthat will be notified each time a Rating Instance will be found or lost.timeout- the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance).
-
connect
public void connect(String hostName, int port, String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config) throws IOException Connect this stateless service client using the round robin with the server.- Parameters:
hostName- The host name of the serverport- The port on which the server waits for requestbindAddress- The address to bind descriptionratingListener- TheFoundLostRatingListenerthat will be notified each time a Rating Instance will be found or lost.timeout- The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.config- A tuned configuration for this client, can be null.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance).
-
connect
@Deprecated public void connect(InstanceMap imap, String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config) throws IOException Connects this stateless service client using the round robin with the distant SAP CC system.- Parameters:
imap- The instance mapbindAddress- The address to bind descriptionratingListener- TheFoundLostRatingListenerthat will be notified each time a Rating Instance will be found or lost.timeout- The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then aCommunicationFailureExceptionwill be thrown without sending request.config- A tuned configuration for this client, can be null.- Throws:
IOException- if the client cannot connect to the server (if server is not running, for instance).
-
statelessRate
public StatelessRateResult statelessRate(String chargeCode, Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, boolean withDetails, boolean checkDates) throws StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException This main business operation requests the SAP CC system to rate (dynamically determine the price)This method should not be used on aStatelessRatingContextwhich is embeded into aStatelessPreRatingContext. SeeStatelessPreRatingContextdocumentation.- Parameters:
chargeCode- The identification code of themaster chargeconfigured in SAP CC; This charge includes a particular price plan dedicated to the stateless rating services.ratingDate- The date of the ratingevent- The event to rate or take into accountcontext- The context of the ratingwithDetails- With all or main details in the returned resultscheckDates- Check date chronology- Throws:
StatelessRateException- if the rate stateless failsInvalidItemException- if the item is invalidForbiddenChargeException- if the process is forbidden (no access in the price plan of the specified charge, agreement is not valid any longer, the price plan forbids rating or when arguments are not correct)CommunicationFailureException- if all the rater instances are unavailable in the connected SAP CC system.ServerFailureException- if a failure occurred on SAP CC Core Server system side
-
statelessRate
public StatelessRateResult statelessRate(String chargeCode, Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, String[] retainedDetails, boolean checkDates) throws StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException Similar tostatelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details. Indeed, theretainedDetailsparameter enables to list the transaction details to retain in the resulting transaction(s).When
retainedDetailsis null, this is equivalent tostatelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content ofretainedDetailsis.- Parameters:
chargeCode- The code of the chargeratingDate- The date of the ratingevent- The event to ratecontext- The context of the ratingretainedDetails- The list of names of transaction details to retain in resulting transaction(s).checkDates- Check date chronology- Throws:
StatelessRateException- when the rate stateless fails.InvalidItemException- when the item is invalid.ForbiddenChargeException- when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).CommunicationFailureException- if all the raters are unavailable.ServerFailureException- if a failure occurred on server side.- See Also:
-
translate
public Object[] translate(String tableCode, int operator, Date date, String[] inValues) throws DoesNotExistException, CommunicationFailureException, ServerFailureException Translates some values by using aninstance of translation table.- Parameters:
tableCode- The code of the translation table which must be usedoperator- The comparison operatordate- The version date of the translation tableinValues- An array of String which represents the input values- Returns:
- An array of the translated
Object - Throws:
DoesNotExistException- thrown if the translation table does not existCommunicationFailureException- if all the raters are unavailableServerFailureException- if a failure occurred on server side- See Also:
-
translate
public Object[] translate(String tableCode, int operator, Date date, Date referenceDate, String[] inValues) throws DoesNotExistException, CommunicationFailureException, ServerFailureException Translates some values by using a translation table.- Parameters:
tableCode- The code of the translation table which must be usedoperator- The comparison operatordate- The version date of the translation tablereferenceDate- The reference date used to check column "start date" and column "end date"inValues- An array of String which represents the input values- Returns:
- An array of the translated
Object - Throws:
DoesNotExistException- thrown if the translation table does not existCommunicationFailureException- if all the raters are unavailableServerFailureException- if a failure occurred on server side- See Also:
-
statelessPreRate
public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, String chargeCode, StatelessPreRatingContext preRatingContext, Date ratingDate, long reservationUID, long postrateDeadline, boolean withDetails, boolean checkDates) throws StatelessPreRatingException, StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException This method is dedicated to the stateless pre-rating.After a call to this method, the passed
StatelessPreRatingContextis not modified. It must be updated (if needed) explicitly calling theStatelessPreRateResult.update(StatelessPreRatingContext)method of the result.The underlying rating is done using the
StatelessRatingContextassociated with the charge code in the givenStatelessPreRatingContext. If no suchStatelessRatingContextexists, it's created (it will be then really added in theStatelessPreRatingContextby the further call toStatelessPreRateResult.update(StatelessPreRatingContext)).See also
StatelessPreRatingContextdocumentation for limitation and constraints to follow.- Parameters:
ratingEvent- the event to rate.chargeCode- the code of the charge.preRatingContext- the context of the stateless pre-rating.ratingDate- a date based on which the chargeable item is rated.reservationUID- the unique identifier of the reservation.postrateDeadline- the delay after which the availability of pending prerating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.withDetails- with all or main details in results.checkDates- check date chronology.- Throws:
StatelessPreRatingException- when the pre rate stateless fails.StatelessRateException- when the rate stateless fails.InvalidItemException- when the item is invalid.ForbiddenChargeException- when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).CommunicationFailureException- if all the raters are unavailable.ServerFailureException- if a failure occurred on server side.
-
statelessPreRate
public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, String chargeCode, StatelessPreRatingContext preRatingContext, Date ratingDate, long reservationUID, long postrateDeadline, String[] retainedDetails, boolean checkDates) throws StatelessPreRatingException, StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException Similar tostatelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details. Indeed, theretainedDetailsparameter enables to list the transaction details to retain in the resulting transaction(s).When
retainedDetailsis null, this is equivalent tostatelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content ofretainedDetailsis.- Parameters:
ratingEvent- the event to rate.chargeCode- the code of the charge.preRatingContext- the context of the stateless pre-rating.ratingDate- a date based on which the chargeable item is rated.reservationUID- the unique identifier of the reservation.postrateDeadline- the delay after which the availability of pending pre-rating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.retainedDetails- list of names of transaction details to retain in resulting transaction(s).checkDates- check date chronology.- Throws:
StatelessPreRatingException- when the pre rate stateless fails.StatelessRateException- when the rate stateless fails.InvalidItemException- when the item is invalid.ForbiddenChargeException- when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).CommunicationFailureException- if all the raters are unavailable.ServerFailureException- if a failure occurred on server side.- See Also:
-
statelessPostRate
public StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, boolean withDetails, ChargeableItem newCi) throws StatelessPreRatingException, StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException This method is dedicated to the stateless post-rating.After a call to this method, the passed
StatelessPreRatingContextis not modified. It must be updated (if needed) explicitly calling theStatelessPostRateResult.update(StatelessPreRatingContext)method of the result.- Parameters:
reservationUID- the unique identifier of the reservation.preRatingContext- the context of the stateless pre-rating.resolution- the resolution (one ofPOST_RATE_CONFIRMATIONorPOST_RATE_CONFIRMATION).withDetails- with all or main details in results.newCi- the new chargeable item, in case of confirmation with new CI.- Throws:
StatelessPreRatingException- when the pre rate stateless fails.StatelessRateException- when the rate stateless fails.InvalidItemException- when the item is invalid.ForbiddenChargeException- when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).CommunicationFailureException- if all the raters are unavailable.ServerFailureException- if a failure occurred on server side.
-
statelessPostRate
public StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, String[] retainedDetails, ChargeableItem newCi) throws StatelessPreRatingException, StatelessRateException, InvalidItemException, ForbiddenChargeException, CommunicationFailureException, ServerFailureException Similar tostatelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details. Indeed, theretainedDetailsparameter enables to list the transaction details to retain in the resulting transaction(s).When
retainedDetailsis null, this is equivalent tostatelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content ofretainedDetailsis.- Parameters:
reservationUID- the unique identifier of the reservation.preRatingContext- the context of the stateless pre-rating.resolution- the resolution (one ofPOST_RATE_CONFIRMATIONorPOST_RATE_CONFIRMATION).retainedDetails- list of names of transaction details to retain in resulting transaction(s).newCi- the new chargeable item, in case of confirmation with new CI.- Throws:
StatelessPreRatingException- when the pre rate stateless fails.StatelessRateException- when the rate stateless fails.InvalidItemException- when the item is invalid.ForbiddenChargeException- when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).CommunicationFailureException- if all the raters are unavailable.ServerFailureException- if a failure occurred on server side.- See Also:
-