Difference between revisions of "Common-accounting ABANDONED"

From Gcube Wiki
Jump to: navigation, search
(Usage)
(Scope)
Line 4: Line 4:
 
The common-accounting-lib allows the services to send the accounting records on the broker and allows the accounting system to receive these messages.  
 
The common-accounting-lib allows the services to send the accounting records on the broker and allows the accounting system to receive these messages.  
 
In our enviroment, the broker is represented by ActiveMQ, which is already replicated with some failover endpoints, in order to increase fault tolerance and scalability. Each infrastructure instance (such as dev, testing and production) has a running instance,  that is related to the scope of the infrastructure. This behavior needs to be mirrored even on the accounting library.
 
In our enviroment, the broker is represented by ActiveMQ, which is already replicated with some failover endpoints, in order to increase fault tolerance and scalability. Each infrastructure instance (such as dev, testing and production) has a running instance,  that is related to the scope of the infrastructure. This behavior needs to be mirrored even on the accounting library.
 +
 +
<code>common-accounting-lib</code> is available in our Maven repositories with the following coordinates:
 +
 +
<source lang="xml">
 +
<dependency>
 +
<groupId>org.gcube.accounting</groupId>
 +
<artifactId>common-accounting-lib</artifactId>
 +
<version>...</version>
 +
</dependency>
 +
</source>
  
 
= Design and implementation notes =
 
= Design and implementation notes =

Revision as of 16:14, 2 September 2013

Scope

This library abstracts the underlying messaging infrastructure in order to provide some facilities both for the services and for the accounting system (i.e. Usage Tracker). The common-accounting-lib allows the services to send the accounting records on the broker and allows the accounting system to receive these messages. In our enviroment, the broker is represented by ActiveMQ, which is already replicated with some failover endpoints, in order to increase fault tolerance and scalability. Each infrastructure instance (such as dev, testing and production) has a running instance, that is related to the scope of the infrastructure. This behavior needs to be mirrored even on the accounting library.

common-accounting-lib is available in our Maven repositories with the following coordinates:

<dependency>
	<groupId>org.gcube.accounting</groupId>
	<artifactId>common-accounting-lib</artifactId>
	<version>...</version>
</dependency>

Design and implementation notes

The "common-accounting" library contains the resource accounting data-model (common-accounting-model), a producer to publish accounting data on the messaging broker and a consumer to retrieve them.

Usage

In order to use the common-accounting-lib to publish accounting records some steps are required:

  • add the Maven dependency of the library in your pom
  • decide where is more appropriate to implement the accounting logic.
  • instantiate a new RawUsageRecord object, which represents the Java implementation of the Resource Accounting model.
  • fill all the basic fields of the record and, optionally, fill even the resource specific fields.
  • get the ResourceAccounting instance through the available factory.
  • and, finally, send a message to the accounting system with the sendAccountingMessage method, passing as a parameter the RawUsageRecord object.