Open rahulsrivastava71 opened 9 years ago
Not sure how you intend to use it. correct use sample: 1) mappingSession is threadsafe and you can reuse it in multiple threads
// new batch statement created each time
mappingSession.withBatch()
.save(obj1)
.delete(obj2)
.execute();
2) you can reuse batch object as soon as you don't modify it, don't add statements
// initialize batch
BatchExecutor batch = mappingSession
.withBatch()
.save(obj1)
.(obj2);
// execute it from multiple threads
batch.execute();
suppose if my mappingSession is singleton and i am trying to access two quries from two different locations using the same session (singleton object) one is simple query and other is batch then i require synchronised block on executor or mappingSession , But you are saying that mappingSession itself is thread safe. So what is the exact way to do it.
On Thu, Sep 3, 2015 at 11:41 PM, Eugene notifications@github.com wrote:
Not sure how you intend to use it. correct use sample: 1) mappingSession is threadsafe and you can reuse it in multiple threads
// new batch statement created each time mappingSession.withBatch() .save(obj1) .delete(obj2) .execute();
1) you can reuse batch object as soon as you don't modify it, don't add statements
// initialize batch BatchExecutor batch = mappingSession .withBatch() .save(obj1) .(obj2); // execute it from multiple threads batch.execute();
— Reply to this email directly or view it on GitHub https://github.com/valchkou/cassandra-driver-mapping/issues/68#issuecomment-137531629 .
you can use same mappingSession from multiple threads, no need to synchronize it.
and if i am modifieying the batch then also i dont need to sysnchronise it.
On Fri, Sep 4, 2015 at 10:25 AM, Eugene notifications@github.com wrote:
you can use same mappingSession from multiple threads, no need to synchronize it.
— Reply to this email directly or view it on GitHub https://github.com/valchkou/cassandra-driver-mapping/issues/68#issuecomment-137649116 .
Dear Eugene, I have one query related to Batch executor that , is your batch executor thread safe or not , as we have to use synchronised block on that executor or not.