The Print Service: VeloxFactory on your printers
VeloxFactory does not talk to printers directly. Instead, a lightweightA companion Windows application, the BackgroundVeloxFactory PrintingPrint Service, runs on any Windows machine that has the target printers installed. It receives print tasks from VeloxFactory, rendersprints the PDF toon the printer,right printer and reports the result back. TheBoth two componentssides communicate exclusivelyonly over the VeloxFactory REST API and WebSocket;the thereWebSocket server (Laravel Reverb). There is no shared database and no shared file system.
This chapter describes version 2.0. It replaces the former console application Background Printing Service (.NET Framework 4.7.2, configuration in App.config) completely.
At a glance
--headless the same program runs without any window from the Windows Task Scheduler, whether a user is logged on or Retry-After, print tasks wait instead of failing.
Nothing on disk
PDFs stay in memory. The API token is stored encrypted (DPAPI) and separate from the configuration.
Operable
Rolling log files, Windows event log with fixed event ids, optional local health endpoint, diagnostic package, graceful stop for updates.
How it works
The
VeloxFactory servicePrint startsService as a regular Windows console process and works through two sequential phases.
Phase 1(Windows)
------------ Initial-----------------------
pull
Print Ontask startupcreated the service immediately calls GET /api/v1/report-print-task?status=pending and processes all tasks it finds. It repeats this in a loop, waiting two seconds between rounds, until the queue comes back empty and no jobs are still running. This ensures that any tasks queued while the service was offline are handled before switching to real-time mode.
Phase 2 -- WebSocket listener
event Once--> Receiver (WebSocket / poll)
<-- GET task + PDF --- Journal: known task? skip
Worker -> printer lock -> PDFium -> Windows spooler
<-- set-printed ------- Outbox (retried until delivered)
<-- set-status error -- on permanent failures
report-print-task.created private-report-print-tasks. POST /api/v1/broadcasting/authProcessing aprocessing print task
Whether a task arrives via the initial pull or via a WebSocket event, the processing steps are identical:
GET /api/v1/report-print-task/{id}withMedia=true). reportPdfFileTempPathC:\VeloxFactory\temp\42_delivery_note.pdfprinterNamenumberOfCopiesPATCH /api/v1/report-print-task/{id}/set-printedprintedPATCH /api/v1/report-print-task/{id}/set-status {"status":a "error",categorised "errorMessage":error "..."}broadcastIdBroadcastOperating ID filteringmodes
listeningBroadcastIds is a list of broadcast channel identifiers the service will accept. Any report-print-task.created event whose broadcastId is not in this list is silently ignored.
This makes it straightforward to run multiple service instances in parallel, for example one per location or printer group, each configured to respond only to its own broadcastId. The initial pull is not filtered this way: it always processes all pending tasks returned by the API, regardless of broadcastId.
Configuration
All settings live in App.config in the applicationSettings section. Edit the file in a text editor and restart the service for changes to take effect.
|
global:use-apireport-print-task:read:update:delete:readreport-print-tasks4|abc123...--headless, normally from the scheduled task
The engine runs without any window. This is the production mode.
websocketUrlMonitor
ws://10.0.0.10:8080/app/veloxfactoryengine and edits its configuration. It does not print itself.
websocketAuthUrlInteractive
http://10.0.0.10:8088/api/v1/broadcasting/authThe engine runs reportPrintTask_indexinside ?status=pendinghttp://10.0.0.10:8088/api/v1/report-print-task?status=pendingreportPrintTask_get{0}http://10.0.0.10:8088/api/v1/report-print-task/{0}reportPrintTask_setPrinted{0}http://10.0.0.10:8088/api/v1/report-print-task/{0}/set-printedreportPrintTask_setError{0}http://10.0.0.10:8088/api/v1/report-print-task/{0}/set-statuslisteningBroadcastIds<string>StandardWarehousemaxParallelPrintJobs1010reportPdfFileTempPathC:\VeloxFactory\templogFile.\Log.loglaconicLoggingTrueFalseFalse
A
Concurrency
named mutex per instance makes sure only one engine runs. The servicewindow usesdetects twoa layersrunning ofheadless concurrencyengine controlautomatically and switches to avoidmonitor overloading printers.mode.
A
--config tasks<path> maxParallelPrintJobsLogging
In Thethis service uses Serilog and writes to both the console and a rolling log file. Log files are capped at 100 MB each; up to 10 rotated files are retained before the oldest is deleted.
Set laconicLogging to True in App.config to suppress informational messages and log only errors, useful in production once the service is confirmed working.
Dependencieschapter
PdfiumViewerInstallation and updates
PdfiumViewer.Native.x86_64.v8-xfaRestSharpConfiguration reference
config.json Newtonsoft.JsonReceiving and processing print tasks
SerilogPrinters and printing
App.config. Set up the new service report-print-task:delete.