Archive Handler
The Archive Container can be configured to work against MongoDB (without writing any extra code). The ArchiveOperationHandler interface abstracts the Big-Data storage from the Archive Container. The MongoDB Archive Operation Handler implements this interface by serializing space objects into MongoDB.
Library Dependencies
The MongoDB Archive Operation Handler uses the MongoDB driver for communicating with the MongoDB cluster.
Include the following in your pom.xml
<!-- currently the MongoDB library is not the central maven repository -->
<repositories>
<repository>
<id>org.openspaces</id>
<name>OpenSpaces</name>
<url>http://maven-repository.openspaces.org</url>
</repository>
</repositories>
<dependencies>
...
<!-- mongodb java driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.gigaspaces</groupId>
<artifactId>xap-mongodb</artifactId>
<version>16.2.1</version>
</dependency>
...
</dependencies>
Setup
<bean id="mongoArchiveHandler" class="com.gigaspaces.persistency.archive.MongoArchiveOperationHandler">
<property name="gigaSpace" ref="gigaSpace" />
<property name="config" ref="config" />
<property name="db" value="${mongodb.db}" />
</bean>
ArchiveOperationHandler mongoArchiveHandler =
new MongoArchiveOperationHandlerConfigurer()
.gigaSpace(gigaSpace)
.config(config)
.db("mydb")
.create();
// To free the resources used by the archive container make sure you close it properly.
// A good life cycle event to place the destroy() call would be within the @PreDestroy or DisposableBean#destroy() method.
archiveContainer.destroy();
MongoArchiveOperationHandler Properties
Property | Description |
---|---|
gigaSpace | GigaSpace reference used for type descriptors. See Archive Container Configuration. |
config | MongoClientConfiguration reference used to handle the mongodb driver configuration. see MongoClient. |
db | Mongodb database name. |