Hi @ismcagdas, Thanks for the link.
In thinking more about my requirements, I'm coming to the conclusion that deferring one job over another depending on demand and job type, may not be the optimal solution. Plus, the solutions recommended require Hangfire.Ace, annual license fee $1500.
I'm considering Azure Functions, which is an elastic on-demand pay-as-you-go n-instance service; more like what I'm looking for.
@zony I'm not seeing a path forward due to the limitations of Hangfire Background Methods, described here: https://docs.hangfire.io/en/latest/background-methods/index.html ...which states
Local variables, instance and static fields and other information isn’t available in our background jobs.
My background process requires injected dependencies for ILocalizationManager, IBinaryObjectManager, and others. (Usage is not shown in the code snippets posted) Unless there is something I'm not understanding, Hangfire doesn't appear to be a viable option.
「wdm」: Compiled successfully.
C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67
f(connection, connection.headers);
^
TypeError: Cannot read property 'headers' of null
at Server.<anonymous> (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67:32)
at Server.emit (events.js:314:20)
at App.emit (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\sockjs.js:196:29)
at C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\transport.js:111:25
at processTicksAndRejections (internal/process/task_queues.js:75:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve --host 0.0.0.0 --port 4200`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tim\AppData\Roaming\npm-cache\_logs\2020-09-25T23_13_53_115Z-debug.log
C:\Users\Tim\Documents\__ngTTMv800\angular>node
Welcome to Node.js v14.12.0.
Type ".help" for more information.
>
Have not tried on another machine. The easiest way to try on another machine would be to clone the SDD and plug disc into another laptop of identical HW. I doubt the outcome would be different, given the OS and all drivers, apps, packages are identical. The hard way would be to install all dev tools, apps and packages from a HDD set to original factory settings, which might have a different outcome. This would take a lot of time, and if the error goes away, the root cause would still remain unknown. Open to other diagnostic suggestions.
Upgraded to Node.js v12.18.4 (latest). Same error as above sequence:
C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67
f(connection, connection.headers);
^
TypeError: Cannot read property 'headers' of null
at Server.<anonymous> (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67:32)
at Server.emit (events.js:315:20)
at App.emit (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\sockjs.js:196:29)
at C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\transport.js:111:25
at processTicksAndRejections (internal/process/task_queues.js:79:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve --host 0.0.0.0 --port 4200`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tim\AppData\Roaming\npm-cache\_logs\2020-09-18T16_45_48_474Z-debug.log
C:\Users\Tim\Documents\__ngTTMv800\angular>node
Welcome to Node.js v12.18.4.
Type ".help" for more information.
>
This error consistently happens in the following scenario:
C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67
f(connection, connection.headers);
^
TypeError: Cannot read property 'headers' of null
at Server.<anonymous> (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\webpack-dev-server\lib\servers\SockJSServer.js:67:32)
at Server.emit (events.js:223:5)
at App.emit (C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\sockjs.js:196:29)
at C:\Users\Tim\Documents\__ngTTMv800\angular\node_modules\sockjs\lib\transport.js:111:25
at processTicksAndRejections (internal/process/task_queues.js:76:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve --host 0.0.0.0 --port 4200`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tim\AppData\Roaming\npm-cache\_logs\2020-09-17T18_23_20_738Z-debug.log
Current remedy: npm start
Your suggestion is the solution. Thank you.
private async Task<byte[]> GetBinaryObject(Guid guid)
{
using (CurrentUnitOfWork.SetTenantId(1))
{
var file = await _binaryObjectManager.GetOrNullAsync(guid);
if (file == null)
{
return null;
}
return file.Bytes;
}
}
I posted the wrong code. Here is the correct code:
public override void Execute(CreateExamJobArgs args)
{
var guid = new Guid("02729c9d-dae0-683b-1d8f-39f5844c75e9");
var file = GetBinaryObject(guid);
}
private async Task<byte[]> GetBinaryObject(Guid guid)
{
var file = await _binaryObjectManager.GetOrNullAsync(guid);
if (file == null)
{
return null;
}
return file.Bytes;
}
Data in AppBinaryObjects:
02729c9d-dae0-683b-1d8f-39f5844c75e9 1 0x89504E470D0A1A0A0000000D494844520000008C000000A00806000000DEAE8473000000017352474200AECE1CE90000000467414D410000B18F0BFC61050000FDDA49444154785E4CFD65771C5BA22D0AFADD738A379B6531332B95CCCC99CA14A698999965C924C96C4B6690999937D7DEB58B0EBC7BEE7D6FF4A7EE0F3D46
When _binaryObjectManager.GetOrNullAsync(guid)
is invoked in an AppService, a BinaryObject is returned, as expected:
_binaryObjectManager = {ngTTM.Storage.DbBinaryObjectManager}
_binaryObjectRepository = {Castle.Proxies.IRepository`2Proxy_17}
file = {[BinaryObject 02729c9d-dae0-683b-1d8f-39f5844c75e9]}
When invoked in a Background Job, a null object is returned, unexpected:
_binaryObjectManager = {ngTTM.Storage.DbBinaryObjectManager}
_binaryObjectRepository = {Castle.Proxies.IRepository`2Proxy_17}
file = null
Using CreationTime
to order entities is the solution.
Thank you.
The code above solved the issue.
Problem discovered: dbo.TtmExamStates column 'Guid' was migrated from another table and renamed 'ExamGuid' after Entity Generator regenerated client code.
Resolution: Fixed code on client to correct name.
Power Tools Entity Generator appears to be working as designed.