Documentation Index
Fetch the complete documentation index at: https://mintlify.com/msolli/proletarian/llms.txt
Use this file to discover all available pages before exploring further.
enqueue! adds a job to the Proletarian job queue by inserting a row into the job table within the supplied database connection. Because it operates directly on a java.sql.Connection, you control the transaction boundary — making it a natural fit for the Transactional Outbox Pattern, where job enqueuing and your business-logic writes share a single atomic transaction.
Namespace: proletarian.job
Signature
Required Parameters
A JDBC database connection. The connection must be inside an active transaction when using the Transactional Outbox Pattern — if the transaction rolls back, the job is never written to the database. Obtained from your connection pool or via a helper such as
next.jdbc’s jdbc/with-transaction.A keyword that identifies the type of job. This value is passed as the first argument to your
handler-fn when the job is processed. Use namespaced keywords (e.g. :myapp/send-email) to avoid collisions across job types.The data the job needs at processing time. It is serialized to a string by the configured
:proletarian/serializer when stored, and deserialized back before being passed as the second argument to handler-fn. Must be serializable by the chosen serializer.Options
Options are passed as trailing keyword arguments or as a single map. All keys are optional.Scheduling
The earliest
Instant at which the job should be processed. If the instant is in the past, the job is eligible for immediate processing. If both :process-at and :process-in are supplied, :process-at takes precedence.A
Duration to add to the current time to compute the earliest processing instant. Negative durations are treated as zero (immediate). Ignored if :process-at is also supplied.Configuration
The name of the queue to enqueue into. Must match the
:proletarian/queue configured on the worker that will process jobs from this queue.The fully-qualified PostgreSQL or MySQL table name for the job queue. Override only if you renamed the table during schema installation.
An implementation of the
proletarian.protocols/Serializer protocol used to encode the payload before storage. Defaults to the Transit JSON serializer returned by proletarian.transit/create-serializer. Must be the same serializer used by the corresponding create-queue-worker call.An implementation of the
proletarian.protocols/JobIdStrategy protocol used to generate and encode job IDs. Defaults to proletarian.job-id-strategies/->postgresql-uuid-strategy. Use proletarian.job-id-strategies/->mysql-uuid-strategy for MySQL deployments. Must be the same strategy used by the corresponding create-queue-worker call.The
java.time.Clock instance used to determine “now” when computing process-at. Useful in tests to fix or advance time without relying on the wall clock.Return Value
Returns the job ID as generated by theJobIdStrategy’s generate-id method — a java.util.UUID with the default strategy. Returns nil if the strategy delegates ID generation to the database (e.g. ->db-generated-strategy).
Examples
Basic usage
Transactional usage (Outbox Pattern)
Enqueue a job atomically alongside a business-logic write usingnext.jdbc:
Scheduling a job in the future
Use:process-at with an explicit java.time.Instant:
:process-in with a java.time.Duration for a relative delay:
Using a custom queue and serializer
The
:proletarian/serializer and :proletarian/job-id-strategy values used in enqueue! must match those used in the corresponding proletarian.worker/create-queue-worker call. A mismatch will cause payload decode failures or job-ID lookup errors at processing time.