DocumentPersister

DocumentPersister is a JMS message consumer that persists the content of the messages to a document-oriented database. It listens to the XQueue and receives JMS Messages as the requests. Either it inserts the content of the message on a remote server as a document, or it finds a document from a remote server according to the content of the message. In case of find, DocumentPersister puts the queried result to the message body and removes it from the XQueue. On the other end of the XQueue, the node is supposed to retrieve the document from the message. DocumentPersister supports flow control and allows object control from its owner. It is fault tolerant with retry and idle options.

Apart from the common properties, there are many implementation specific properties for DocumentPersister. Most of them depends on the schemes.
Property Name Data Type Requirement Description Examples
CollectionField string optional field name for the name of the collection required for MongoDB (default: Collection)
BucketField string optional field name for the name of the bucket required for Riak (default: Bucket)
KeyField string optional field name for Riak key (default: RIAK)
RCField string optional field name to store return code (0 for success) (default: ReturnCode)
QueryField string optional field name for Mongo query statement (default: Query)
ResultField string optional field name to store the number of items returned (default: QueryResult)
ResultType integer optional type of the result 8 for JSON (default: 1)
Template string optional template to build the request
Retry integer optional number of retry before to give up the delivery 2

Currently, DocumentPersister supports MongoDB and Riak, in terms of the scheme of mongodb or Riak. In the near future, it will support Cassandra. Here is the matrix of supported operations for various schemes:
Scheme Operation Description
mongodb update update the content to a collection
mongodb find query documents from a collection
riak store store documents to a bucket
riak download download documents from a bucket

Here is an example of DocumentPersister:

{
  "Name": "pstr_doc",
  "ClassName": "org.qbroker.persister.DocumentPersister",
  "URI": "mongodb://localhost/test",
  "LinkName": "pool",
  "Operation": "find",
  "ResultType": "8",
  "BaseTag": "Record",
  "XAMode": "1",
  "Retry": "1",
  "Template": "##body##",
  "DisplayMask": "6",
  "StringProperty": {
    "DBName": "",
    "Collection": ""
  }
}
where it expects the message body containing the query data as the request and sends the query to test database of the MongoDB server.