Currently, I am utilizing Azure Service Bus (@azure/service-bus) within a TypeScript-based nest.js service to schedule messages for delivery at a future date. In case the need arises, I must also have the ability to cancel these scheduled messages before their intended delivery time. My initial strategy was to create messages and set them up for delivery using the scheduleMessages
function, which would return an ID specific to each scheduled message. Subsequently, I planned to store this message ID in my mongodb database, allowing me to retrieve it later when required for cancellation through the cancelScheduledMessages
function that accepts the ID as a parameter.
However, it appears that the @azure/service-bus package utilizes its own internal Long
type for these IDs. Since this particular type is not readily accessible outside of the package, any attempts on my end to convert these IDs from the Long
type to another data type (which is necessary to store them in mongoDB) result in irreversible conversion errors.
The documentation related to the scheduleMessages
function provides insight into handling these IDs:
Save the Long type as-is in your application without converting it to a number. Attempting to convert the Long type to a number may lead to loss in precision due to JavaScript's limitation to 53-bit numbers.
Is there a feasible method available for saving these IDs to a database and subsequently retrieving them for use? Or does the instruction to "Save the Long type as-is in your application" signify a dead end in this scenario? It seems implausible that the developers behind this service bus package would offer no flexibility in saving such IDs.
Your input and suggestions are highly appreciated.
Thank you!