我在neo4j 2.3.2
应用程序的嵌入模式下使用2.1.8
(从JAVAEE
升级)。我的问题是每当我执行应用程序和服务器重启时,我丢失了我最近保存的所有数据。以下是我正在使用的属性配置。它运行在8GB服务器上。
allow_store_upgrade=true
dbms.pagecache.memory=2g
下面是我发送ack给salesforce后用于以xml的形式输入图形数据库的代码(Servlet)
String theString = IOUtils.toString(request.getInputStream(), "UTF-8");
log.info("Salesforce data/n " + theString);
//gets request input stream
Transaction tx = null;
try {
log.info(" " + request.getContentType());
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
Map<String,String> update = new HashMap<>();
is.setCharacterStream(new StringReader(theString));
System.out.println("After parsing XML");
Document doc = db.parse(is);
doc.getDocumentElement().normalize();
Element ele = doc.getDocumentElement();
Node node = doc.getDocumentElement();
log.info("Root element " + doc.getDocumentElement());
//get fields from xml objects
NodeList sObject = doc.getElementsByTagName("sObject");
tx = ICTCDBUtil.getInstance().getGraphDB().beginTx();
for (int j = 0; j < sObject.getLength(); j++) {
Node rowNode = sObject.item(j);
String salesforceObj =
rowNode.getAttributes().getNamedItem("xsi:type").getNodeValue();
log.info(salesforceObj);
if (salesforceObj.equalsIgnoreCase("sf:Farmer_Biodata__c")) {
farmerID = getXmlNodeValue("sf:Id",ele);
agentId = getXmlNodeValue("sf:CreatedById",ele);
bb = biodataModel.getBiodata("Id", farmerID);
if(null!=bb )
{
log.info("Farmer Already Exist Id " + farmerID);
out.println(sendAck());
}
else
{
org.neo4j.graphdb.Node biodataNode = ICTCDBUtil.getInstance().getGraphDB().createNode();
biodataNode.addLabel(Labels.FARMER);
for (int k = 0; k < rowNode.getChildNodes().getLength(); k++) {
// System.out.println("node: " + rowNode.getChildNodes().item(k).getNodeName() + ": " + rowNode.getChildNodes().item(k).getTextContent());
if (rowNode.getChildNodes().item(k).getNodeName().equals("sf:Id") ||rowNode.getChildNodes().item(k).getNodeName().equals("sf:CreatedById") ) {
log.info("id : " + getObjectFieldId(rowNode.getChildNodes().item(k).getNodeName()));
biodataNode.setProperty(getObjectFieldId(rowNode.getChildNodes().item(k).getNodeName()), rowNode.getChildNodes().item(k).getTextContent());
}
if (!rowNode.getChildNodes().item(k).getNodeName().equals("sf:Id") && !rowNode.getChildNodes().item(k).getNodeName().equals("#text") && !rowNode.getChildNodes().item(k).getNodeName().equals("sf:CreatedById")) {
log.info(getObjectFieldName(rowNode.getChildNodes().item(k).getNodeName()));
biodataNode.setProperty(getObjectFieldName(rowNode.getChildNodes().item(k).getNodeName()), rowNode.getChildNodes().item(k).getTextContent());
}
}
biodataNode.setProperty(Biodata.LAST_MODIFIED,new Date().getTime());
log.log(Level.INFO, "new node created {0}", biodataNode.getId());
out.println(sendAck());
}
tx.success();
}
}
} catch (Exception ex) { Logger.getLogger(SaleforceIntegrationController.class.getName()).log(Level.SEVERE, null, ex);
tx.failure();
} finally {
tx.close();
}