@autofleet/rabbit 3.4.0-0 → 3.4.0-beta--beta--0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -11
- package/package.json +1 -1
- package/src/index.ts +31 -13
package/dist/index.js
CHANGED
|
@@ -631,20 +631,34 @@ class RabbitMq {
|
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
633
|
async sendToCeleryQueue(data, taskName, queueName) {
|
|
634
|
-
|
|
635
|
-
|
|
634
|
+
const taskId = (0, node_crypto_1.randomUUID)();
|
|
635
|
+
// Celery-compatible message body
|
|
636
|
+
const taskPayload = {
|
|
637
|
+
task: taskName,
|
|
638
|
+
id: taskId,
|
|
639
|
+
args: [data],
|
|
640
|
+
kwargs: {},
|
|
641
|
+
retries: 0,
|
|
642
|
+
eta: null,
|
|
643
|
+
};
|
|
644
|
+
// Celery-compatible AMQP headers
|
|
645
|
+
const publishOptions = {
|
|
646
|
+
contentType: 'application/json',
|
|
647
|
+
contentEncoding: 'utf-8',
|
|
648
|
+
deliveryMode: 2,
|
|
649
|
+
headers: {
|
|
650
|
+
lang: 'py',
|
|
636
651
|
task: taskName,
|
|
637
|
-
id:
|
|
638
|
-
|
|
639
|
-
|
|
652
|
+
id: taskId,
|
|
653
|
+
root_id: taskId,
|
|
654
|
+
parent_id: null,
|
|
655
|
+
group: null,
|
|
640
656
|
retries: 0,
|
|
641
657
|
eta: null,
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
};
|
|
647
|
-
return await this.sendToQueue(queueName, taskPayload, undefined, headers);
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
try {
|
|
661
|
+
return await this.sendToQueue(queueName, taskPayload, undefined, publishOptions);
|
|
648
662
|
}
|
|
649
663
|
catch (e) {
|
|
650
664
|
const isConnected = await this.isConnected();
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -876,25 +876,43 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
876
876
|
taskName: string,
|
|
877
877
|
queueName: string,
|
|
878
878
|
): Promise<boolean | undefined> {
|
|
879
|
-
|
|
880
|
-
|
|
879
|
+
const taskId = randomUUID();
|
|
880
|
+
|
|
881
|
+
// Celery-compatible message body
|
|
882
|
+
const taskPayload = {
|
|
883
|
+
task: taskName,
|
|
884
|
+
id: taskId,
|
|
885
|
+
args: [data],
|
|
886
|
+
kwargs: {},
|
|
887
|
+
retries: 0,
|
|
888
|
+
eta: null,
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
// Celery-compatible AMQP headers
|
|
892
|
+
const publishOptions = {
|
|
893
|
+
contentType: 'application/json',
|
|
894
|
+
contentEncoding: 'utf-8',
|
|
895
|
+
deliveryMode: 2, // persistent
|
|
896
|
+
headers: {
|
|
897
|
+
lang: 'py',
|
|
881
898
|
task: taskName,
|
|
882
|
-
id:
|
|
883
|
-
|
|
884
|
-
|
|
899
|
+
id: taskId,
|
|
900
|
+
root_id: taskId,
|
|
901
|
+
parent_id: null,
|
|
902
|
+
group: null,
|
|
885
903
|
retries: 0,
|
|
886
904
|
eta: null,
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
const headers = {
|
|
890
|
-
'content-type': 'application/json',
|
|
891
|
-
delivery_mode: 2,
|
|
892
|
-
};
|
|
905
|
+
},
|
|
906
|
+
};
|
|
893
907
|
|
|
894
|
-
|
|
908
|
+
try {
|
|
909
|
+
return await this.sendToQueue(queueName, taskPayload, undefined, publishOptions);
|
|
895
910
|
} catch (e) {
|
|
896
911
|
const isConnected = await this.isConnected();
|
|
897
|
-
logger.error(
|
|
912
|
+
logger.error(
|
|
913
|
+
`rabbit sendToQueue: failed to send to queue ${queueName}, isConnected: ${isConnected}`,
|
|
914
|
+
{ e },
|
|
915
|
+
);
|
|
898
916
|
throw e;
|
|
899
917
|
}
|
|
900
918
|
}
|