Search code examples
.netmultithreadingsolrtask-parallel-librarysolrnet

Asynchronous Operations in SolrNet


Is it possible to make asynchronous operations in SolrNET that follow the APM (begin, end) pattern? I need to make several asynchronous calls to different Solr search indexes in my Asp.NET web application and I am trying to reduce the load on the thread pool by using non-blocking threads. Please advise. Thanks.


Solution

  • At least looking through the SolrNet source, while the IHttpWebRequest interface includes Begin/End pairs, those aren't used/exposed higher in the interfaces (like ISolrConnection), so AFAICT you'd have to change (or reimplement) those to support it.

    That said, it's likely worth just trying it as-is (kicking them off with Task.Run or the like) and seeing whether you really end up starving the threadpool - if you do, you can reconfigure it with higher limits, after all. :)

    Making SolrNet Task-based via TAP would likely be a good chunk of effort since you typically need to do async/Task through all the levels of the stack (and in the case of SolrNet, probably should just do so in a fork that targets 4.5 so it can rely on the new HttpClient and its native Task-based calls)