mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-30 05:09:44 -06:00
fix: don't need acks on queue checks (#926)
This commit is contained in:
@@ -136,6 +136,9 @@ type Message struct {
|
||||
// RetryDelay is the delay between retries.
|
||||
RetryDelay int `json:"retry_delay"`
|
||||
|
||||
// Whether the message should immediately expire if it reaches the queue without an active consumer.
|
||||
ImmediatelyExpire bool `json:"immediately_expire"`
|
||||
|
||||
// OtelCarrier is the OpenTelemetry carrier for the task.
|
||||
OtelCarrier map[string]string `json:"otel_carrier"`
|
||||
}
|
||||
|
||||
@@ -341,9 +341,15 @@ func (t *MessageQueueImpl) startPublishing() func() error {
|
||||
|
||||
t.l.Debug().Msgf("publishing msg %s to queue %s", msg.ID, msg.q.Name())
|
||||
|
||||
err = pub.PublishWithContext(ctx, "", msg.q.Name(), false, false, amqp.Publishing{
|
||||
pubMsg := amqp.Publishing{
|
||||
Body: body,
|
||||
})
|
||||
}
|
||||
|
||||
if msg.ImmediatelyExpire {
|
||||
pubMsg.Expiration = "0"
|
||||
}
|
||||
|
||||
err = pub.PublishWithContext(ctx, "", msg.q.Name(), false, false, pubMsg)
|
||||
|
||||
// retry failed delivery on the next session
|
||||
if err != nil {
|
||||
|
||||
@@ -116,7 +116,7 @@ func (q *queue) Start() (func() error, error) {
|
||||
|
||||
q.s.Start()
|
||||
|
||||
f := func(task *msgqueue.Message) error {
|
||||
postAck := func(task *msgqueue.Message) error {
|
||||
wg.Add(1)
|
||||
defer wg.Done()
|
||||
|
||||
@@ -129,7 +129,11 @@ func (q *queue) Start() (func() error, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
cleanupQueue, err := q.mq.Subscribe(msgqueue.QueueTypeFromPartitionIDAndController(q.p.GetControllerPartitionId(), msgqueue.JobController), f, msgqueue.NoOpHook)
|
||||
cleanupQueue, err := q.mq.Subscribe(
|
||||
msgqueue.QueueTypeFromPartitionIDAndController(q.p.GetControllerPartitionId(), msgqueue.JobController),
|
||||
msgqueue.NoOpHook, // the only handler is to check the queue, so we acknowledge immediately with the NoOpHook
|
||||
postAck,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
@@ -267,7 +267,11 @@ func (wc *WorkflowsControllerImpl) Start() (func() error, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
cleanupQueue2, err := wc.mq.Subscribe(msgqueue.QueueTypeFromPartitionIDAndController(wc.p.GetControllerPartitionId(), msgqueue.WorkflowController), f2, msgqueue.NoOpHook)
|
||||
cleanupQueue2, err := wc.mq.Subscribe(
|
||||
msgqueue.QueueTypeFromPartitionIDAndController(wc.p.GetControllerPartitionId(), msgqueue.WorkflowController),
|
||||
msgqueue.NoOpHook, // the only handler is to check the queue, so we acknowledge immediately with the NoOpHook
|
||||
f2,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
@@ -40,10 +40,11 @@ func CheckTenantQueueToTask(tenantId string) *msgqueue.Message {
|
||||
})
|
||||
|
||||
return &msgqueue.Message{
|
||||
ID: "check-tenant-queue",
|
||||
Payload: nil,
|
||||
Metadata: metadata,
|
||||
Retries: 3,
|
||||
ID: "check-tenant-queue",
|
||||
Payload: nil,
|
||||
Metadata: metadata,
|
||||
ImmediatelyExpire: true,
|
||||
Retries: 3,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user