c# - Akka.net/RavenDB how to properly load data from database to initialize actors? -
i'm working on project computes continuous flow of data. i've been strugling lately memory , networking exceptions point ask myself if way i'm getting data database good.
i using:
- .net 4.6.1
- akka.net 1.0.8
- ravendb.client 3.5.1
here's example of how load data actors:
public class myactor : receiveactor { public myactor (immutableregistration registration) { receives(); self.tell(new initdbcache()); } private void receives() { receive<initdbcache>(t => { var builder = new databasecachebuilder(); builder.buildfor(registration).continuewith(result => { return new dbcachereceived(result.result); }, taskcontinuationoptions.attachedtoparent & taskcontinuationoptions.executesynchronously).pipeto(self); }); receive<dbcachereceived>(msg => { // init actor retrieved data }); } private sealed class initdbcache { public initdbcache() { } } private sealed class dbcachereceived { public dbcachereceived(databasecache cache) { this.cache = cache; } public databasecache cache { get; } } }
the databasecachebuilder goes :
public sealed class databasecachebuilder { public databasecachebuilder() { } public async task<databasecache> buildfor(immutableregistration registration) { // have repository pattern on top of ravendb client using (var session = outsiderefs.datastore.openravendbsession()) { var queryresult1 = await session.repository1.executequeryasync(registration.id); var queryresult2 = await session.repository2.executequeryasync(registration.id); return new databasecache(queryresult1, queryresult2); } } }
concretely, program throws fair number of "system.io.ioexception: unable read data transport connection: existing connection forcibly closed remote host."
those exceptions throwed ravendb client.
does see problem or correlation code , exception ?
does using async/await regroup async calls bad thing though i'm piping result ?
Comments
Post a Comment