How do I query a collection or index using REST/http in an embedded RavenDB v3.5? - ravendb

Firstly I feel like the need to qualify why having to do this on such an old version of RavenDB:
We are using Particular ServiceControl for NServiceBus/RabbitMQ message handling, namely error messages. Latest version of ServiceControl (v4.22.0) uses an embedded RavenDB v3.5 for storing among other things failed messages.
We need to monitor these failed messages using an external monitoring tool, and therefore I need to periodically scrape and group the failed messages and expose these groupings as metrics for the monitoring software to react upon.
Attempts so far
I have managed to expose the RavenDB database thus allowing myself to access it via REST/http. As such I can loop through e.g. an index using a request like
curl -X GET "http://localhost:33334/indexes/FailedMessageViewIndex?pageSize=5"
This works, but have no filtering options, field selectors or the like.
According to docs (of later versions, I admit), I should be able to query indices like this with RQL syntax:
curl -X POST "http://live-test.ravendb.net/databases/<system>/queries" -d "{ \"Query\": \"from doc in docs.FailedMessages\" }"
but I can only get it to produce the following error:
{"Url":"/databases/%3Csystem%3E/queries?debug=true","Error":"System.Exception: Error reading RavenJArray from JsonReader. Current JsonReader item is not an array: StartObject\r\n at Raven.Json.Linq.RavenJArray.Load(JsonReader reader)\r\n at Raven.Database.Server.Controllers.RavenBaseApiController.d__28.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Raven.Database.Server.Controllers.QueriesController.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()"}
Now I can deduce that this /queries endpoint expects an array of some sort, but poking around Raven Studio this seems to be a fixed list of strings with which to obtain various information, e.g. payloads ["Raven/StudioConfig"], ["Raven/Alerts"] et.al.
Lastly I can seem to touch something by using the GET request I started out with with a "query" query string parameter, but I get no results - i.e.
curl -X GET http://localhost:33334/indexes/FailedMessageViewIndex?pageSize=3&query=from%20index%20FailedMessageViewIndex
Result:
{
"Results": [],
"Includes": [],
"IsStale": false,
"IndexTimestamp": "2022-10-11T23:01:30.7137228Z",
"TotalResults": 0,
"SkippedResults": 0,
"IndexName": "FailedMessageViewIndex",
"IndexEtag": "01000000-0000-0101-0000-00000000DE8D",
"ResultEtag": "6F5C0902-5EAA-79A4-9D23-B493D5048FB6",
"Highlightings": {},
"NonAuthoritativeInformation": false,
"LastQueryTime": "2022-10-11T23:01:31.6916452Z",
"DurationMilliseconds": 0,
"ScoreExplanations": {},
"TimingsInMilliseconds": {},
"ResultSize": 0
}
The question
I realize that I am at this point merely trying to guess my way through.
But my question is: can I somehow query my embedded RavenDB v3.5 with REST/http using RQL, Lucene or in some other way provide arguments as to what I wish to retrieve?

Related

What's the meaning of 'compensation is thrown for an activity' and 'compensation is thrown for the current scope'?

Even if i have read the compensation-intermediate-throwing-event of bpmn construct for serveral times, i still cannot understand the meaning of 'compensation is thrown for an activity' and 'compensation is thrown for the current scope'.
Does it means a compensation-intermediate-throwing-event can be configured to thrown for a specific acivity or can be configured to thrown to current scope?

ERROR: The supervisor is stopping, no additional scopes can be created

This is the error details
System.OperationCanceledException: The supervisor is stopping, no additional
scopes can be created
at MassTransit.Util.TaskSupervisor.CreateScope(String tag)
at MassTransit.Util.TaskScope.MassTransit.Util.ITaskSupervisor.CreateScope(String tag)
at MassTransit.Util.TaskSupervisorExtensions.CreateScope(ITaskSupervisor supervisor, String tag, Func`1 afterStopped)
at MassTransit.RabbitMqTransport.Integration.RabbitMqModelCache.ModelScope..ctor(ITaskScope supervisor)
at MassTransit.RabbitMqTransport.Integration.RabbitMqModelCache.Send(IPipe`1 connectionPipe, CancellationToken cancellationToken)
at MassTransit.RabbitMqTransport.RabbitMqSendTransport.<MassTransit-Transports-ISendTransport-Send>d__6`1.MoveNext()
--- The last part of the stack trace in the previous location that caused the exception ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer.<RabbitMQ-Client-IBasicConsumer-HandleBasicDeliver>d__19.MoveNext()
This error will appear on time,how to solve him,thx for help!!!!!!!!

"Invalid object name 'OpenIddictAuthorizations'." - OpenIddict/.Net Core Identity Error

I am new to .Net Core 2.0 and Identity framework. I am trying to use OpenIddict in the project.
References:
OpenIddict (2.0.0-rc1-final)
OpenIddict.EntityFrameworkCore(2.0.0-rc1-final)
Microsoft.AspNetCore.Identity.EntityFrameworkCore (2.0.1)
I keep on getting the following runtime error:
Invalid object name 'OpenIddictAuthorizations'.
Here is the stack trace:
at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__108_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext()
It looks like a SQL exception but I am not sure why it is looking for an object called OpenIddictAuthorizations in the database. Any help is highly appreciated.
Because you need this Table in your Db beside other tables
dbo.OpenIddictApplications
dbo.OpenIddictAuthorizations
dbo.OpenIddictScopes
dbo.OpenIddictTokens
So, OpenId can store the tokens and verify them.

Task Canceled While Creating Order

When creating a new order I am seeing long execution times and then it finally fails with a TaskCanceledException.
I'm using my own payment module and I've compared it to one's written already and I seem to be implementing things right. The payment is being processed.
https://github.com/montanehamilton/vc-module-PayPal-Rest
I do have a custom shipping method module as well
https://github.com/montanehamilton/vc-fedex
Any thought's on where to look when encountering this behavior? Running 2.13.9 of the platform.
Exception Details
POST storefrontapi/cart/createorder 500 Internal Server Error A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at VirtoCommerce.Storefront.AutoRestClients.OrdersModuleApi.OrderModule.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at VirtoCommerce.Storefront.AutoRestClients.OrdersModuleApi.OrderModuleExtensions.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at VirtoCommerce.Storefront.Controllers.Api.ApiCartController.d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.b__36(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.b__32(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult)
The tasks were getting canceled due to timeouts. The VirtoCommerce storefront should be configured to set these timeouts to a value appropriate for the task.
In my case PayPal recommends at least 30 seconds, if not more. I set the timeout to 1 minute and the problem was resolved.
You can set the AppSetting with name "VirtoCommerce:Storefront:ApiRequest:Timeout" in your web.config to change the timeout when making API calls.
I recommend update platform to 2.13.11 and modules to latest version.
The update reduced Memory Usage and performance during order flow, so we can decrease Azure price plan.

NServiceBus 6 (6.0.0-beta0004) - The requested service 'NServiceBus.RecoverabilityExecutorFactory' has not been registered

Just running with a vanilla NServiceBus 6.0.0-beta0004
var endpointConfiguration = new EndpointConfiguration("endpoint");
endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);
This throws an exception:
Bus.ProgramService An unhandled error has occurred.
Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'NServiceBus.RecoverabilityExecutorFactory' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
at NServiceBus.AutofacObjectBuilder.Build(Type typeToBuild) in D:\Code\GitHub\agupta-au\NServiceBus\src\NServiceBus.Core\ObjectBuilder\Autofac\AutofacObjectBuilder.cs:line 39
at NServiceBus.CommonObjectBuilder.Build[T]() in D:\Code\GitHub\agupta-au\NServiceBus\src\NServiceBus.Core\ObjectBuilder\Common\CommonObjectBuilder.cs:line 28
at NServiceBus.StartableEndpoint.CreateReceivers() in D:\Code\GitHub\agupta-au\NServiceBus\src\NServiceBus.Core\StartableEndpoint.cs:line 93
at NServiceBus.StartableEndpoint.<Start>d__1.MoveNext() in D:\Code\GitHub\agupta-au\NServiceBus\src\NServiceBus.Core\StartableEndpoint.cs:line 45
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at NServiceBus.Endpoint.<Start>d__1.MoveNext() in D:\Code\GitHub\agupta-au\NServiceBus\src\NServiceBus.Core\Endpoint.cs:line 28
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
What am I missing? My understanding is that the Recoverability stuff is to do with the First Level Retries + Second Level Retries but I've not set this up yet. Moreover, there seems to be discussion between the guys about this already: https://github.com/Particular/NServiceBus/pull/3828
Any help would be greatly appreciated :)
As Daniel already mentioned in the comments, this code should not be part of the available beta packages. It's highly recommended to stick with the available beta packages on NuGet instead because it's very likely to run into issues when using any persistence/transport package otherwise. The release-6.0.0 branch is still under active development.
(But of course that exception should not occur at all ;) )