I have a Xamarin application with Visual Studio 2017 for Android. I have added Parse.NETStandard2 version 2.0.0 to the main app.
I have another .NET core app that uses Parse 1.7, all the below works on the .NET core version.
If I add the standard Parse to the Xamarin code it complains that not NET Standard 2 compatable which is why I switch to the other version of Parse.
Question: Any idea why it can't find the entry point? Note the ParseClient is not throwing an error.
Xamarin version:
I added the following to the main App to initialize the parse connection:
ParseClient.Initialize(new ParseClient.Configuration
{
ApplicationId = "...",
WindowsKey = "...",
Server = #"http://...:80/parse/"
});
When I run this code:
try
{
var q = ParseObject.GetQuery("Category");
var t = q.FirstOrDefaultAsync();
t.Wait();
System.Diagnostics.Debug.WriteLine(t.Result);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
I get this error:
[0:] System.AggregateException: One or more errors occurred. ---> System.EntryPointNotFoundException: GetModuleFileName
at (wrapper managed-to-native) StandardStorage.StorageUtilities.GetModuleFileName(System.Runtime.InteropServices.HandleRef,System.Text.StringBuilder,int)
at StandardStorage.StorageUtilities.GetModuleFileNameLongPath (System.Runtime.InteropServices.HandleRef hModule) [0x00042] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.get_ExecutablePath () [0x00021] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.GetAppFileVersionInfo () [0x00046] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.get_CompanyName () [0x00042] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.GetAppSpecificStoragePathFromBasePath (System.String basePath) [0x00000] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.FileSystem.get_LocalStorage () [0x00007] in <492e9128255c4fa2885761586862f4f3>:0
at Parse.Common.Internal.StorageController+<>c.<.ctor>b__5_1 (System.Threading.Tasks.Task _) [0x00006] in <bafb02353d284fa488514259b803efcb>:0
at System.Threading.Tasks.ContinuationResultTaskFromTask`1[TResult].InnerInvoke () [0x00024] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <fe08c003e91342eb83df1ca48302ddbb>:0
--- End of stack trace from previous location where exception was thrown ---
at Parse.Common.Internal.InternalExtensions+<>c__DisplayClass7_0`1[TResult].<OnSuccess>b__0 (System.Threading.Tasks.Task t) [0x0003c] in <bafb02353d284fa488514259b803efcb>:0
at System.Threading.Tasks.ContinuationResultTaskFromTask`1[TResult].InnerInvoke () [0x00024] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <fe08c003e91342eb83df1ca48302ddbb>:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Wait () [0x00000] in <fe08c003e91342eb83df1ca48302ddbb>:0
at Parse.ParseUser.get_CurrentUser () [0x00007] in <bafb02353d284fa488514259b803efcb>:0
at Parse.ParseQuery`1[T].FirstOrDefaultAsync (System.Threading.CancellationToken cancellationToken) [0x0000d] in <bafb02353d284fa488514259b803efcb>:0
at Parse.ParseQuery`1[T].FirstOrDefaultAsync () [0x00006] in <bafb02353d284fa488514259b803efcb>:0
at TheBabyQuoteApp.Views.MainPage..ctor () [0x0001b] in D:\WebSites\TheBabyQuote_Projects\TheBabyQuoteApp\TheBabyQuoteApp\TheBabyQuoteApp\Views\MainPage.xaml.cs:22
---> (Inner Exception #0) System.EntryPointNotFoundException: GetModuleFileName
at (wrapper managed-to-native) StandardStorage.StorageUtilities.GetModuleFileName(System.Runtime.InteropServices.HandleRef,System.Text.StringBuilder,int)
at StandardStorage.StorageUtilities.GetModuleFileNameLongPath (System.Runtime.InteropServices.HandleRef hModule) [0x00042] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.get_ExecutablePath () [0x00021] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.GetAppFileVersionInfo () [0x00046] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.get_CompanyName () [0x00042] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.StorageUtilities.GetAppSpecificStoragePathFromBasePath (System.String basePath) [0x00000] in <492e9128255c4fa2885761586862f4f3>:0
at StandardStorage.FileSystem.get_LocalStorage () [0x00007] in <492e9128255c4fa2885761586862f4f3>:0
at Parse.Common.Internal.StorageController+<>c.<.ctor>b__5_1 (System.Threading.Tasks.Task _) [0x00006] in <bafb02353d284fa488514259b803efcb>:0
at System.Threading.Tasks.ContinuationResultTaskFromTask`1[TResult].InnerInvoke () [0x00024] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <fe08c003e91342eb83df1ca48302ddbb>:0
--- End of stack trace from previous location where exception was thrown ---
at Parse.Common.Internal.InternalExtensions+<>c__DisplayClass7_0`1[TResult].<OnSuccess>b__0 (System.Threading.Tasks.Task t) [0x0003c] in <bafb02353d284fa488514259b803efcb>:0
at System.Threading.Tasks.ContinuationResultTaskFromTask`1[TResult].InnerInvoke () [0x00024] in <fe08c003e91342eb83df1ca48302ddbb>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <fe08c003e91342eb83df1ca48302ddbb>:0 <---
Error if I add Parse 1.7.0 to the Xamarin app:
Warning NU1701 Package 'Parse 1.7.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Related
I am trying to authenticate my API JWT, but unable to compile as it gives error :
- $exception {"Scheme already exists: Bearer"} System.InvalidOperationException
If i remove the authentication code then it works perfectly fine. If i place authentication code in program.cs then I am able to compile but then again when i host it as a windows service. I get error 500.
program.cs
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.AddJsonFile("certificate.json", optional: true, reloadOnChange: true)
.AddJsonFile($"certificate.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
.Build();
string certificateFileName = "C:\\old\\kestrelssl.pfx";
string certificatePassword = "12345";
var certificate = new X509Certificate2(certificateFileName, certificatePassword);
return Host.CreateDefaultBuilder(args)
/*.ConfigureServices(services => {
services.AddAuthentication(option =>
{
option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(option =>
{
option.RequireHttpsMetadata = true; //made purposly to test ssl with kestrel
option.TokenValidationParameters = new TokenValidationParameters()
{
ValidateLifetime = true,
ValidateIssuer = true,
ValidateAudience = true,
ValidIssuer = ConfigHelper.AppSetting("issuer"),
ValidAudience = ConfigHelper.AppSetting("audience"),
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ConfigHelper.AppSetting("secretkey"))),
ClockSkew = TimeSpan.Zero
};
});
})*/
.ConfigureWebHost(webBuilder =>
{
webBuilder.UseKestrel(options =>
{
options.AddServerHeader = false;
options.Listen(IPAddress.Loopback, 44302, listenOptions =>
{
listenOptions.UseHttps(certificate);
});
})
.UseIISIntegration()
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseUrls("https://localhost:44302");
webBuilder.UseStartup<Startup>();
}).UseWindowsService(); ;
}
Startup.Cs
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(option =>
{
option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(option =>
{
option.RequireHttpsMetadata = false;
option.TokenValidationParameters = new TokenValidationParameters()
{
ValidateLifetime = true,
ValidateIssuer = true,
ValidateAudience = true,
ValidIssuer = ConfigHelper.AppSetting("issuer"),
ValidAudience = ConfigHelper.AppSetting("audience"),
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ConfigHelper.AppSetting("secretkey"))),
ClockSkew = TimeSpan.Zero
};
});
services.AddMvc(options => { options.EnableEndpointRouting = false; });
services.AddControllers().AddNewtonsoftJson(options =>
{
// Use the default property (Pascal) casing
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});
// services.AddHttpsRedirection(options => options.HttpsPort = 5001);
services.AddScoped<IApplication, Application>();
services.AddScoped<IServiceRepository, ServiceRepository>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMvc();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "ServiceNS/{action}");
});
}
StackTrace
at Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(String name, Action`1 configureBuilder)
at Microsoft.AspNetCore.Authentication.AuthenticationBuilder.<>c__DisplayClass4_0`2.<AddSchemeHelper>b__0(AuthenticationOptions o)
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
at Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider..ctor(IOptions`1 options, IDictionary`2 schemes)
at Microsoft.AspNetCore.Authentication.AuthenticationSchemeProvider..ctor(IOptions`1 options)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_0.<UseMiddleware>b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.GenericWebHostService.<StartAsync>d__31.MoveNext()
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.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__9.MoveNext()
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.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
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.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at ***.Program.Main(String[] args) in D:\Learning\Projects\***\Program.cs:line 20
According to your program.cs codes, I found you call the startup.cs twice, I suggest you could try to modify it to remove one startup.cs and try again.
.UseStartup<Startup>()
.UseUrls("https://localhost:44302");
webBuilder.UseStartup<Startup>();
Thanks to Brando, for looking into this, I removed one of the Startup Reference and its working as expected.
But when i launched the EXE as a Windows Service, it just gave me InternalServerError, So i looked further in event logs and found below :
Exception:
System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\Windows\system32\appsettings.json'.
As soon as i pasted it (appsettings.json) inside C:/Windows/system32 , Its working smooth.
I was scratching my head from past 3 days, hope this will help someone in future.
I'm trying to set MassTransit up with Azure Service Bus. I want to use the DLQ instead of relying on _skipped and _error queues, but I'm not sure if I'm doing it wrong.
This is a simplified version of my setup:
services.AddMassTransit(busConfigurator =>
{
busConfigurator.AddConsumer<MessageConsumer>();
busConfigurator.UsingAzureServiceBus((context, serviceBusBusFactoryConfigurator) =>
{
serviceBusBusFactoryConfigurator.Host(connectionString);
serviceBusBusFactoryConfigurator.SubscriptionEndpoint<Message>(
"message-subscription",
configurator =>
{
configurator.ConfigureDeadLetterQueueErrorTransport();
configurator.ConfigureDeadLetterQueueDeadLetterTransport();
configurator.ConfigureConsumer<MessageConsumer>(context);
});
});
});
services.AddMassTransitHostedService(true);
---
public class Message
{
public string Text { get; set; }
}
public class MessageConsumer : IConsumer<Message>
{
public Task Consume(ConsumeContext<Message> context)
{
throw new Exception("Hello");
}
}
When publishing a message ( await _bus.Publish<Message>(new {})), I'm getting something like this in the logs:
[15:19:22 | DBG | MassTransit] Create send transport: sb://mytestbus.servicebus.windows.net/MassTransit/Fault--Acme.Common.Messaging.Contracts.Events/Message--
[15:19:22 | DBG | MassTransit] Topic: MassTransit/Fault--Acme.Common.Messaging.Contracts.Events/Message-- ()
[15:19:22 | DBG | MassTransit] Topic: MassTransit/Fault ()
[15:19:22 | DBG | MassTransit] Subscription Fault-MassTransit (MassTransit/Fault--Acme.Common.Messaging.Contracts.Events/Message-- -> sb://mytestbus.servicebus.windows.net/MassTransit/Fault)
[15:19:22 | DBG | MassTransit] SEND sb://mytestbus.servicebus.windows.net/MassTransit/Fault--Acme.Common.Messaging.Contracts.Events/Message-- 09c40000-5dcc-0015-85cf-08d9988339b8 MassTransit.Fault<Acme.Common.Messaging.Contracts.Events.Message>
[15:19:22 | ERR | MassTransit] R-FAULT sb://mytestbus.servicebus.windows.net/Acme.Common.Messaging.Contracts.Events/Message/Subscriptions/message-subscription 09c40000-5dcc-0015-5c52-08d998833786 Acme.Common.Messaging.Contracts.Events.Message Acme.Services.UpdateService.MessageConsumer(00:00:03.0423556)
System.Exception: Hello
at Acme.Services.UpdateService.MessageConsumer.Consume(ConsumeContext`1 context) in C:\Development\acme\src\Acme.Services.UpdateService\Startup.cs:line 503
at MassTransit.Pipeline.Filters.MethodConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumerConsumeContext<TConsumer,TMessage>>.Send(ConsumerConsumeContext`2 context, IPipe`1 next)
at GreenPipes.Pipes.LastPipe`1.Send(TContext context)
at MassTransit.Scoping.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Scoping.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
[15:19:23 | WRN | MassTransit] Message Lock Lost: 09c400005dcc00155c5208d998833786
Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue, or was received by a different receiver instance.
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.DisposeMessagesAsync(IEnumerable`1 lockTokens, Outcome outcome)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.DeadLetterAsync(String lockToken, IDictionary`2 propertiesToModify)
at MassTransit.Azure.ServiceBus.Core.Contexts.ReceiverClientMessageLockContext.DeadLetter(Exception exception)
at MassTransit.Azure.ServiceBus.Core.Pipeline.DeadLetterQueueExceptionFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.GenerateFaultFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Azure.ServiceBus.Core.Pipeline.DeadLetterQueueExceptionFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.GenerateFaultFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.DeadLetterFilter.GreenPipes.IFilter<MassTransit.ReceiveContext>.Send(ReceiveContext context, IPipe`1 next)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Azure.ServiceBus.Core.Transport.BrokeredMessageReceiver.MassTransit.Azure.ServiceBus.Core.Transport.IBrokeredMessageReceiver.Handle(Message message, CancellationToken cancellationToken, Action`1 contextCallback)
[15:19:23 | WRN | MassTransit] Exception on Receiver sb://mytestbus.servicebus.windows.net/Acme.Common.Messaging.Contracts.Events/Message/Subscriptions/message-subscription during UserCallback ActiveDispatchCount(0) ErrorRequiresRecycle(False)
Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue, or was received by a different receiver instance.
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.DisposeMessagesAsync(IEnumerable`1 lockTokens, Outcome outcome)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.DeadLetterAsync(String lockToken, IDictionary`2 propertiesToModify)
at MassTransit.Azure.ServiceBus.Core.Contexts.ReceiverClientMessageLockContext.DeadLetter(Exception exception)
at MassTransit.Azure.ServiceBus.Core.Pipeline.DeadLetterQueueExceptionFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.GenerateFaultFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Azure.ServiceBus.Core.Pipeline.DeadLetterQueueExceptionFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.GenerateFaultFilter.GreenPipes.IFilter<MassTransit.ExceptionReceiveContext>.Send(ExceptionReceiveContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.DeadLetterFilter.GreenPipes.IFilter<MassTransit.ReceiveContext>.Send(ReceiveContext context, IPipe`1 next)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Azure.ServiceBus.Core.Transport.BrokeredMessageReceiver.MassTransit.Azure.ServiceBus.Core.Transport.IBrokeredMessageReceiver.Handle(Message message, CancellationToken cancellationToken, Action`1 contextCallback)
at MassTransit.Azure.ServiceBus.Core.Transport.BrokeredMessageReceiver.MassTransit.Azure.ServiceBus.Core.Transport.IBrokeredMessageReceiver.Handle(Message message, CancellationToken cancellationToken, Action`1 contextCallback)
at MassTransit.Azure.ServiceBus.Core.Contexts.SubscriptionClientContext.<>c__DisplayClass16_0.<<OnMessageAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Azure.ServiceBus.MessageReceivePump.MessageDispatchTask(Message message)
Is this by design or am I doing something wrong? I would have thought that the message would have been moved to the DLQ, without any logged warnings (except for the exception that I throw).
If I uncomment ConfigureDeadLetterQueueErrorTransport, then I no longer get the MessageLockLostException.
Using MassTransit 7.2.3
With a subscription endpoint, the DLQ is the default behavior.
What you've configured is likely conflicting with the default configuration. If you get rid of the following lines, it should work as expected:
configurator.ConfigureDeadLetterQueueErrorTransport();
configurator.ConfigureDeadLetterQueueDeadLetterTransport();
You can see that those same lines are already configured for subscription endpoints.
Those lines are only needed to configure a receive endpoint to use the DLQ.
I am trying to connect two services using RabbitMQ queue. First services pushes value to queue, second retrieves it and process. All is fine, but when second service tries to process job, it throws exception. Queue item stays in JobAttempt queue without any information, and consumer service retries to process job, but throws same exception every time.
Exception
fail: MassTransit.ReceiveTransport[0]
S-FAULT rabbitmq://localhost/JobAttempt f0cb0000-1616-902e-edb0-08d97cd26cf9 MassTransit.Contracts.JobService.JobStatusCheckRequested
fail: MassTransit.ReceiveTransport[0]
T-FAULT rabbitmq://localhost/JobAttempt f0cb0000-1616-902e-8129-08d97cca994f
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at MassTransit.Saga.InMemoryRepository.InMemorySagaRepositoryContext`2.Delete(SagaConsumeContext`1 context)
at MassTransit.Saga.MissingSagaPipe`2.Send(SagaConsumeContext`2 context)
at MassTransit.Saga.MissingSagaPipe`2.Send(SagaConsumeContext`2 context)
at MassTransit.Saga.SendSagaPipe`2.Send(SagaRepositoryContext`2 context)
at MassTransit.Saga.InMemoryRepository.InMemorySagaRepositoryContextFactory`1.Send[T](ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Saga.Pipeline.Filters.CorrelatedSagaFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Saga.Pipeline.Filters.CorrelatedSagaFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.InMemoryOutboxFilter`2.Send(TContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.InMemoryOutboxFilter`2.Send(TContext context, IPipe`1 next)
at GreenPipes.Filters.RetryFilter`1.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
at GreenPipes.Partitioning.Partition.Send[T](T context, IPipe`1 next)
at GreenPipes.Filters.TeeFilter`1.<>c__DisplayClass5_0.<<Send>g__SendAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at GreenPipes.Filters.DynamicFilter`1.<>c__DisplayClass10_0.<<Send>g__SendAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at MassTransit.Pipeline.Filters.DeserializeFilter.Send(ReceiveContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
at MassTransit.Pipeline.Filters.DeadLetterFilter.GreenPipes.IFilter<MassTransit.ReceiveContext>.Send(ReceiveContext context, IPipe`1 next)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.Transports.ReceivePipeDispatcher.Dispatch(ReceiveContext context, ReceiveLockContext receiveLock)
at MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer.<>c__DisplayClass24_0.<<HandleBasicDeliver>b__0>d.MoveNext()
Producer startup:
services.AddMassTransit(x =>
{
x.SetKebabCaseEndpointNameFormatter();
x.UsingRabbitMq((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
});
});
services.AddMassTransitHostedService();
Consumer startup:
services.AddMassTransit(x =>
{
x.AddDelayedMessageScheduler();
x.AddConsumer<LoanRequestJobConsumer>(cfg =>
{
cfg.Options<JobOptions<LoanRequestBroker>>(options =>
{
options.SetJobTimeout(TimeSpan.FromMinutes(5));
options.SetConcurrentJobLimit(10);
});
});
x.SetKebabCaseEndpointNameFormatter();
x.UsingRabbitMq((context, cfg) =>
{
cfg.UseDelayedMessageScheduler();
cfg.ServiceInstance(instance =>
{
instance.ConfigureJobServiceEndpoints(js =>
{
js.SagaPartitionCount = 1;
js.FinalizeCompleted = true;
});
cfg.ReceiveEndpoint("loan-request-processing", e =>
{
e.ConfigureConsumer<LoanRequestJobConsumer>(context);
});
instance.ConfigureEndpoints(context);
});
});
});
services.AddMassTransitHostedService();
Job consumer
public class LoanRequestJobConsumer : IJobConsumer<LoanRequestBroker>
{
private readonly ILogger<LoanRequestJobConsumer> _logger;
private readonly ILoanProcessingService _processingService;
public LoanRequestJobConsumer(
ILogger<LoanRequestJobConsumer> logger,
ILoanProcessingService processingService)
{
_logger = logger;
_processingService = processingService;
}
public async Task Run(JobContext<LoanRequestBroker> context)
{
_logger.LogInformation($"{nameof(LoanRequestJobConsumer)}: start processing loan request id = {context.Job.Id}");
var processingInfo = new LoanProcessingInfo
{
Status = TaskStatus.InProgress,
LoanRequest = context.Job.Adapt<LoanRequest>()
};
processingInfo = await _processingService.SaveProcessingInfoAsync(processingInfo);
processingInfo = await _processingService.ProcessAsync(processingInfo);
processingInfo = await _processingService.SaveProcessingInfoAsync(processingInfo);
_logger.LogInformation($"{nameof(LoanRequestJobConsumer)}: end processing loan request id = {context.Job.Id}" +
$"\nResult: {JsonConvert.SerializeObject(processingInfo)}");
}
}
How I push item to the queue
var endpoint = await _sendEndpointProvider.GetSendEndpoint(_brokerEndpoints.LoanProcessingQueue);
await endpoint.Send(loanRequest.Adapt<LoanRequestBroker>());
If I had to guess, without any other error log details, I would think that the delayed exchange plug-in is not installed/enabled on RabbitMQ.
I am using the ZXing.Mobile.Forms Scanning Libary and I am getting the following error
The strange thing is its works for scans in a row but on the fourth scan it boms out
09-28 15:37:59.887 E/mono-rt ( 8983): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.RuntimeException: getParameters failed (empty parameters)
09-28 15:37:59.887 E/mono-rt ( 8983): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.RuntimeException: getParameters failed (empty parameters)
09-28 15:37:59.887 E/mono-rt ( 8983): at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <f13ae3cb9fcf47aa8f3adccd03288827>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <f13ae3cb9fcf47aa8f3adccd03288827>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at Android.Hardware.Camera.GetParameters () [0x0000a] in <3d3cf2a3639e4422aea8bb417e71ff8d>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at ZXing.Mobile.CameraAccess.CameraController.ApplyCameraSettings () [0x00033] in <819b29aa6d91462699e19a679be55a44>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at ZXing.Mobile.CameraAccess.CameraController.RefreshCamera () [0x00010] in <819b29aa6d91462699e19a679be55a44>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at ZXing.Mobile.CameraAccess.CameraAnalyzer.RefreshCamera () [0x00001] in <819b29aa6d91462699e19a679be55a44>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at ZXing.Mobile.ZXingSurfaceView.OnWindowFocusChanged (System.Boolean hasWindowFocus) [0x0008f] in <819b29aa6d91462699e19a679be55a44>:0
09-28 15:37:59.887 E/mono-rt ( 8983): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.41(intptr,intptr)
09-28 15:37:59.887 E/mono-rt ( 8983): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.41(intptr,intptr)
09-28 15:37:59.887 E/mono-rt ( 8983): --- End of stack trace from previous location where exception was thrown ---
09-28 15:37:59.887 E/mono-rt ( 8983):
I am using the following to capture the scan on button click and this does work but only for the first 3 scanns.
public string BarCode { get; set; }
var scanPage = new ZXingScannerPage();
scanPage.ToggleTorch();
await Navigation.PushAsync(scanPage);
scanPage.OnScanResult += (result) =>
{
// Stop scanning
scanPage.IsScanning = false;
// Pop the page and show the result
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopAsync();
BarCode = result.Text;
}
//I call my save function here.
StockTakeTransaction stockTake = new StockTakeTransaction();
stockTake.StockTakeCountSheetItemId = item.StocktakeCountShtItemID;
stockTake.Quantity = 1;
stockTake.MobileDeviceCode = settings.DeviceID.ToString();
stockTake.WarehouseId = WarehouseId;
stockTake.MobileDeviceUser = settings.UserName.ToString();
transferList.Add(stockTake);
SaveFunction(sender, e, stockTake);
}
The save function here is called from the above method
private async void SaveFunction(object sender, EventArgs e, StockTakeTransaction StockTakeitem)
{
Device.BeginInvokeOnMainThread(async () => {
BtnScanStockTakeItem_Clicked(sender, e); });
}
I do some postback to api which works so I am not keeping it here
I then click the btn for a scan again. It's quite odd that its happening like this was QA testing that picked it up
I received that exception in my Xamarin.Forms App (Android, HTC Desire 510) on OS Android: 4.1.2but it's not very expressive and I don't know where to start investigation:
Xamarin caused by: Android.Views.WindowManagerBadTokenException:
Unable to add window -- token android.os.BinderProxy#4174fee8 is not
valid; is your activity running? at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in :0 at
Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod
(Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo
method, Java.Interop.JniArgumentValue* args) [0x00084] in
:0 at
Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod
(System.String encodedMember, Java.Interop.IJavaPeerable self,
Java.Interop.JniArgumentValue* parameters) [0x0002f] in
:0 at Android.App.Dialog.Show ()
[0x0000a] in <79e6945a2f4a4e2f844e36c860dfb012>:0 at
Acr.UserDialogs.UserDialogsImpl+<>c__DisplayClass24_0.b__0 ()
[0x00011] in <435daf83b740428697641f6937603702>:0 at
Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in
<79e6945a2f4a4e2f844e36c860dfb012>:0 at
Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr
native__this) [0x00009] in <79e6945a2f4a4e2f844e36c860dfb012>:0 at
(wrapper dynamic-method)
System.Object:c03c2323-76c4-49c2-96eb-2a4f82e62e78 (intptr,intptr)
Hope someone can point me in the right direction.
Eric