Package org.jainslee.resources.diameter.gx
The Diameter Gx Resource Adaptor type is based on RFC 4006 and 3GPP specifications of Gx interface defined in:
3GPP Technical Specification 29.212 v10.1.0.
3GPP Technical Specification 29.212 v11.9.0.
3GPP Technical Specification 29.212 v12.13.0.
The DiameterGxProviderFactory
provider factory interface provides methods to obtain a
appropriate version of provider interface.
SBBs can obtain a DiameterGxProviderFactory
instance via JNDI after
specifying an appropriate <resource-adaptor-entity-binding> entry in the SBB deployment descriptor.
Following provider interfaces provide methods to obtain a factory class to create Diameter Credit Control AVPs and Diameter messages.
For Gx version 10.1.0.
org.jainslee.resources.diameter.gx.va10.DiameterGxProvider
For Gx version 11.9.0.
org.jainslee.resources.diameter.gx.vb90.DiameterGxProvider
For Gx version 12.13.0.
org.jainslee.resources.diameter.gx.vcd0.DiameterGxProvider
SBBs can obtain instance of one of provider interfaces calling one of methods:
getGxPoviderVa10()
getGxPoviderVb90()
getGxPoviderVcd0()
These methods return either instance of DiameterGxProvider if resource adaptor entity is configured to support corresponding 3GPP version
or null if resource adaptor entity is not configured to support such 3GPP version.
Client Functionality -- Sending Diameter Credit Control requests
Asynchronous Requests
Examples below are applicable to DiameterGxProvider for all supported 3GPP versions. The SBB developer has to use only packages corresponding to required 3GPP version as listed below:
For 3GPP 10.1.0 :
org.jainslee.resources.diameter.gx.va10
and
org.jainslee.resources.diameter.gx.types.va10
For 3GPP 11.9.0 :
org.jainslee.resources.diameter.gx.vb90
and
org.jainslee.resources.diameter.gx.types.vb90
For 3GPP 12.13.0 :
org.jainslee.resources.diameter.gx.vcd0
and
org.jainslee.resources.diameter.gx.types.vcd0
The DiameterGxProvider interface provides a method to create a
GxClientSessionActivity
on which asynchronous Diameter requests can then be sent.
Diameter credit control activities are created using the
createClientSessionActivity()
method or the
createGxClientSessionActivity(DiameterIdentity, DiameterIdentity)
method. The GxClientSessionActivity
returned can be used to send asynchronous requests. When answers are received by the Diameter stack,
CreditControlAnswer
events are fired on the activity.
Synchronous Requests
Note: The synchronous API should only be used for simple test services that are not expected to run at high loads. The resource adaptor does not currently implement timeouts for synchronous requests, so SBBs may block indefinitely. Services that use the synchronous model also do not scale well.
The DiameterGxProvider interface also has methods which will send a Diameter request then block until the answer
is received. A CreditControlAnswer
instance will be the
return value of the method call. See the DiameterGxProvider
class for details.
Example
The following code fragment demonstrates an initial Credit Control Request being created and sent.
The diameterDiameterGxProvider
variable contains the RA SBB provider interface retrieved from JNDI.
(Note: the utility methods used to create grouped AVPs are not shown.)
GxMessageFactory messageFactory = diameterDiameterGxProvider.getGxMessageFactory(); CreditControlRequest ccr = messageFactory.createGxCreditControlRequest(); ccr.setDestinationRealm(new DiameterIdentity("opencloud")); ccr.setSubscriptionId(createSubscriptionId(messageFactory, subscriptionAddress)); ccr.setMultipleServicesCreditControl(createMsccRequested(messageFactory,1)); ServiceInformation serviceInformation = messageFactory.createServiceInformation(); serviceInformation.setMmsInformation(createMmsInformation(messageFactory)); ccr.setServiceInformation(serviceInformation); GxClientSessionActivity roActivity = diameterDiameterGxProvider.createGxClientSessionActivity(); ActivityContextInterface diameterACI = diameterGxACIFactory.getActivityContextInterface(roActivity); diameterACI.attach(getSbbLocalObject()); roActivity.sendInitialCreditControlRequest(ccr);
Client Functionality -- Receiving Diameter Credit Control Answers
The following code fragment demonstrates a Credit Control Answer being received by an SBB.public void onCreditControlAnswer(CreditControlAnswer cca, ActivityContextInterface aci) { switch ((int) cca.getResultCode()) { case DiameterCcaResultCode.DIAMETER_CREDIT_CONTROL_NOT_APPLICABLE: // ... do behaviour required for billing not applicable ... break; case DiameterResultCode.DIAMETER_AUTHORIZATION_REJECTED: // insufficient credit // ... do behaviour required for insufficient credit ... break; case DiameterResultCode.DIAMETER_SUCCESS: MultipleServicesCreditControl[] mscc = cca.getMultipleServicesCreditControls(); GrantedServiceUnit gsu = mscc[0].getGrantedServiceUnit(); final long ccTime = gsu.getCcTime(); // invalid response if (ccTime == 0) { // ... handle error: illegal Diameter CCA Answer (GSU CC Time = 0) } break; default: // ... handle error: illegal Diameter CCA Answer, unknown result code } }
Server Functionality -- Receiving Diameter Gx Credit Control Requests
The following code fragment demonstrates a Credit Control Request being received by an SBB, and an answer being sent using the same activity.public void onCreditControlRequestInitial(CreditControlRequest event, ActivityContextInterface aci) { // do logic for CCR-Initial GxServerSessionActivity activity = (GxServerSessionActivity) aci.getActivity(); CreditControlAnswer cca = activity.createCreditControlAnswer(); cca.setResultCode(DiameterResultCode.DIAMETER_SUCCESS); cca.setCcRequestType(CcRequestType.INITIAL_REQUEST); try { activity.sendCreditControlAnswer(cca); } catch (SendException e) { // ... handle error: SendException sending answer } } public void onCreditControlRequestUpdate(CreditControlRequest event, ActivityContextInterface aci) { // do logic for CCR-Update GxServerSessionActivity activity = (GxServerSessionActivity) aci.getActivity(); CreditControlAnswer cca = activity.createCreditControlAnswer(); cca.setResultCode(DiameterResultCode.DIAMETER_SUCCESS); cca.setCcRequestType(CcRequestType.UPDATE_REQUEST); try { activity.sendCreditControlAnswer(cca); } catch (SendException e) { // ... handle error: SendException sending answer } } public void onCreditControlRequestTermination(CreditControlRequest event, ActivityContextInterface aci) { // do logic for CCR-Termination GxServerSessionActivity activity = (GxServerSessionActivity) aci.getActivity(); CreditControlAnswer cca = activity.createCreditControlAnswer(); cca.setResultCode(DiameterResultCode.DIAMETER_SUCCESS); cca.setCcRequestType(CcRequestType.TERMINATION_REQUEST); try { activity.sendCreditControlAnswer(cca); } catch (SendException e) { // ... handle error: SendException sending answer } }
-
Interface Summary Interface Description DiameterGxActivityContextInterfaceFactory Interface to obtain an ActivityContextInterface for a Gx activity.DiameterGxProviderFactory Declares the methods to obtain Gx version specific Gx providers.Versions