Comments (4)
I strongly suggest you consider the reference documentation first - http://www.dizitart.org/nitrite-database/doc/2.0.0/index.html#replication
You don't need to manually create the collections in mongo. It will be created by this line from client
DataGateSyncTemplate syncTemplate
= new DataGateSyncTemplate(dataGateClient, "remote-collection@userId");
Here "remote-collection@userId" is the collection name that will be created in mongo by datagate.
from nitrite-java.
I've been throw the documentation many times but nothing.
this is my client code.
DataGateClient dataGateClient = new DataGateClient("http://localhost:9090")
.withAuth("shadi", "123456")
.withUserAgent(userAgent);
DataGateSyncTemplate syncTemplate
= new DataGateSyncTemplate(dataGateClient, "test-collection@shadi");
NitriteCollection collection = DB.getCollection("test");
SyncHandle syncHandle = Replicator.of(DB)
.forLocal(collection)
// a DataGate sync template implementation
.withSyncTemplate(syncTemplate)
// replication attempt delay of 1 sec
.delay(timeSpan(1, TimeUnit.SECONDS))
// both-way replication
.ofType(ReplicationType.BOTH_WAY)
// sync event listener
.withListener(new SyncEventListener() {
@Override
public void onSyncEvent(SyncEventData eventInfo) {
System.out.println("data is synced" + eventInfo.getError());
}
})
.configure();
syncHandle.startSync();
Document doc = createDocument("firstName", "John")
.put("lastName", "Doe")
.put("birthDay", new Date())
//.put("data", new byte[] {1, 2, 3})
//.put("fruits", new ArrayList<String>() {{ add("apple"); add("orange"); }})
.put("note", "a quick brown fox jump over the lazy dog");
collection.insert(doc);
DB.commit();
DB.close();
my client application is throwing this exception
data is syncedorg.dizitart.no2.exceptions.SyncException: NO2.11011: error while submitting changes to remote collection
[ScheduledWorker.NO₂] ERROR org.dizitart.no2.sync.DataGateSyncTemplate - Remote error while submitting change feed to remote
org.dizitart.no2.exceptions.SyncException: NO2.11017: HTTP/1.1 400 Bad Request
at org.dizitart.no2.sync.DataGateSyncTemplate.change(DataGateSyncTemplate.java:99)
at org.dizitart.no2.sync.SyncService.mergeChanges(SyncService.java:233)
at org.dizitart.no2.sync.SyncService.mergeChanges(SyncService.java:143)
at org.dizitart.no2.sync.CollectionReplicator.run(CollectionReplicator.java:63)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
the server is throwing this exception
2017-09-06 13:41:35.735 ERROR 5847 --- [qtp914356853-15] o.d.n.d.advices.DataGateApiErrorHandler : DataGate HTTP Error
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: NO2.3009: document id is an auto generated value and can not be 771985644632835459; nested exception is com.fasterxml.jackson.databind.JsonMappingException: NO2.3009: document id is an auto generated value and can not be 771985644632835459 (through reference chain: org.dizitart.no2.sync.data.ChangeFeed["modifiedDocuments"]->java.util.ArrayList[0]->org.dizitart.no2.Document["_id"])
please if you any idea where would look for a solution
from nitrite-java.
I'll take a look into it tomorrow. Meantime can you also go through one of the datagate junit tests? That might give you an idea if you are doing anything wrong. Now is the night time for me here, so can't be of immediate help. This is the file you need to look at - https://github.com/dizitart/nitrite-database/blob/master/nitrite-datagate/src/test/java/org/dizitart/no2/datagate/DataGateSyncTest.java
from nitrite-java.
Sorry for the late reply, I was so caught up with my work.
Can you please remove the line - DB.close()
from your code and test? The close()
call will shutdown the sync thread and can cause unexpected result. Meantime, please look into the this test file - SyncIntegrationTest.java for properly initializing your sync code. And let me know if you still see any issue.
from nitrite-java.
Related Issues (20)
- Migrating from 3.x to 4.x: Database file is corrupted HOT 7
- possible memory leak HOT 1
- org.h2.mvstore.Chunk.accountForRemovedPage NPE HOT 2
- MVStore claims to have unsaved changes after calling nitriteDatabase.getCollection(...) HOT 5
- NitriteCollection.update slow when unrelated properties in document are indexed HOT 6
- EntityConverter toDocument HOT 3
- KotlinXSerializationMapper decodes lists to be size 1 always HOT 1
- Invalid repository type for entity where all fields are nullable (with JacksonMapperModule) HOT 3
- Possibiltity to index a field with both text and non-unique/unique filter HOT 3
- Incorrect result when searching indexed column HOT 1
- Support JPMS HOT 6
- Feature request: method for retrieving all document ids in a collection faster HOT 1
- Search for _id always returns an iterator with an element HOT 2
- org.dizitart.no2.common.tuples.Pair cannot be cast to class java.lang.Comparable HOT 4
- @Indices is not neccessary to use, multiple @Index annotations on class are allowed HOT 1
- Repositories initialization logic not compatible with Kotlinx.serialization HOT 5
- bootstrap-3.3.7.min.js: 6 vulnerabilities (highest severity is: 6.1) HOT 1
- jquery.dataTables-1.10.12.min.js: 1 vulnerabilities (highest severity is: 6.1) HOT 1
- Chart-2.1.4.min.js: 1 vulnerabilities (highest severity is: 9.8) HOT 1
- bootstrap-3.3.6.min.js: 6 vulnerabilities (highest severity is: 6.1) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nitrite-java.