Hi,
I did more troubleshooting and fixed the issue:
Replaced the following:
context.Services.AddSingleton<AmazonSQSClient>(new AmazonSQSClient());
with:
context.Services.AddSingleton(new AmazonSQSClient(awsRegionEndpoint));
Thanks for your assistance.
* An exception was thrown while activating CastandCrew.Payroll.Timecard.CapsPay.v1.CapspaytimecardAppService -> CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating CastandCrew.Payroll.Timecard.CapsPay.v1.CapspaytimecardAppService -> CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper.
---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper' can be invoked with the available services and parameters:
Cannot resolve parameter 'Amazon.SQS.IAmazonSQS sqsClient' of constructor 'Void .ctor(Amazon.SQS.IAmazonSQS)'.
[DependsOn(
typeof(TimecardDomainModule),
typeof(TimecardApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
)]
public class TimecardApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.AddAutoMapperObjectMapper<TimecardApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<TimecardApplicationModule>(validate: true);
options.AddProfile<TimecardApplicationAutoMapperProfile>(validate: true);
});
//Register an instance as singleton
context.Services.AddSingleton<AmazonSQSClient>(new AmazonSQSClient());
//Register a factory method that resolves from IServiceProvider
context.Services.AddScoped<IAmazonSQS>(
sp => sp.GetRequiredService<AmazonSQSClient>()
);
}
}
Following is the code for AwsSqsHelper class which injects IAmazonSQS:
public class AwsSqsHelper : ApplicationService, IAwsSqsHelper
{
#region Class Variables
private readonly ILogger<CapspaytimecardAppService> _logger;
private readonly ISettingProvider _settingProvider;
private readonly IAmazonSQS _sqsClient;
#endregion
#region Constructors
public AwsSqsHelper(
IAmazonSQS sqsClient)
{
_sqsClient = sqsClient;
_logger = NullLogger<CapspaytimecardAppService>.Instance;
}
#endregion
#region IAwsSqsHelper Implementation
public async Task<bool> DeleteMessageAsync(string messageReceiptHandle)
{
*** Removed for brevity ***
}
public async Task<bool> IsQueueReady()
{
*** Removed for brevity ***
}
public async Task<List<Message>> ReceiveMessageAsync()
{
*** Removed for brevity ***
}
public async Task<bool> SendMessageAsync(
string message,
SqsMessageAttributes messageAttributes)
{
*** Removed for brevity ***
}
#endregion
}
Following is the code for CapspaytimecardAppService:
public class CapspaytimecardAppService : TimecardAppService, ITimecardAppService
{
#region Class Variables
private readonly IAwsSqsHelper _awsSqsHelper;
private readonly ICapspaytimecardManager _capsPayManager;
private readonly ILogger<CapspaytimecardAppService> _logger;
private readonly IObjectMapper _objectMapper;
private readonly IStringLocalizer<TimecardResource> _stringLocalizer;
#endregion
#region Constructors
public CapspaytimecardAppService(
IAwsSqsHelper awsSqsHelper,
IHttpClientFactory httpClientFactory,
ICapspaytimecardManager capsPayManager,
IObjectMapper objectMapper,
IStringLocalizer<TimecardResource> stringLocalizer) : base(httpClientFactory)
{
_awsSqsHelper = awsSqsHelper;
_capsPayManager = capsPayManager;
_objectMapper = objectMapper;
_stringLocalizer = stringLocalizer;
_logger = NullLogger<CapspaytimecardAppService>.Instance;
}
internal CapspaytimecardAppService(
IAwsSqsHelper awsSqsHelper,
HttpClient httpClient,
ICapspaytimecardManager capsPayManager,
ILogger<CapspaytimecardAppService> logger,
IObjectMapper objectMapper,
IStringLocalizer<TimecardResource> stringLocalizer) : base(httpClient)
{
_awsSqsHelper = awsSqsHelper;
_capsPayManager = capsPayManager;
_logger = logger;
_objectMapper = objectMapper;
_stringLocalizer = stringLocalizer;
}
#endregion
*** Removed for brevity ***
}
The code was working until I introduced AmazonSQS implementation. Please let me know if you need additional information.
Thanks.
Hi,
The information from our log which is also stated in the Exception details/Stack Trace portion of the ticket is :
Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://dev.web-gateway.integrationservices.dev.aws.test.com/api/client/v1/test/contractlocations, Response status code: 404
Eventually, we were able to figure out the issue.
Thanks.
Hi,
Everything works on my side locally as it is on your side. As previously stated, when we deploy to our dev server, then the Client endpoints fail with 404.
Thanks.
Hi,
Do you have an insight into the issue? Do you need any more information than provided?
We would like to resolve the issue as we need to get it deployed soon.
Thanks.
Hi,
The version we are testing has project reference to Client module. Testing locally (localhost), the Client endpoints work.
When deployed and using Nuget packages for Client and Project, the endpoints for Project work. We get the 404 error for Client endpoints.
I have updated the csproj file on the OneDrive location shared with you to include project references to Client module. You will have to update the location to the one appropriate for yours via Abp Studio.
Thanks
Hi,
The microservice (host) has project references to Project Service (module). The screenshot above shows the relative path to the module on my machine based on our repo working folder.
Is it possible for you to change these to the Client and Project module locations on your machine? I use ABP Studio to set/fix the project references:
Please let me know if that works.
Thanks
Hi,
I have shared all the files for the three (host, service1 and service2) solutions. These are copies of all the files from my machine after successful compilation.
Looking forward to your feedback.
Thanks,
Suresh