🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
How to publish and consume an attachment(.txt) file along with each message in queue?
Best Answer
-
Hi Leo, thanks for the question.
It really comes down to what you mean by "attachment". In PubSub+ you can have messages published that have a binary attachment. The contents of a binary attachment are up to you, so it certainly could be a serialized .txt file. The consuming applications would need to be aware of the format of that binary attachment in the message payload in order to know to deserialize to a .txt file. This can be done in a number of ways. A common way is publishing to a certain topic (which could then be subscribed to by the queue for persistence) and have your consumer applications consume from that queue. The message headers could be interrogated to see what topic the messages were published to and confirm that you should treat them as .txt in your consumer logic.
Some links to concepts I mention are:
https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Adding-Data-Payloads.htm
https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Publishing-Guaranteed-Messages.htm
https://docs.solace.com/PubSub-Basics/Core-Concepts-Endpoints-Queues.htm#topic-queue-mapping2
Answers
-
Hi Leo, thanks for the question.
It really comes down to what you mean by "attachment". In PubSub+ you can have messages published that have a binary attachment. The contents of a binary attachment are up to you, so it certainly could be a serialized .txt file. The consuming applications would need to be aware of the format of that binary attachment in the message payload in order to know to deserialize to a .txt file. This can be done in a number of ways. A common way is publishing to a certain topic (which could then be subscribed to by the queue for persistence) and have your consumer applications consume from that queue. The message headers could be interrogated to see what topic the messages were published to and confirm that you should treat them as .txt in your consumer logic.
Some links to concepts I mention are:
https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Adding-Data-Payloads.htm
https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Publishing-Guaranteed-Messages.htm
https://docs.solace.com/PubSub-Basics/Core-Concepts-Endpoints-Queues.htm#topic-queue-mapping2 -
@Leo stany Assuming your .txt is small, this works well. What if your file is large? Like gigabytes? Well, another way to view this is the "event notification" pattern. Here you publish an event that details where the file is, its name etc. The consuming application uses this as a notification that the file is ready and that it should read it, getting the location of the file, size, who placed the file and other meta data from the event. It can then locate the file and do what it needs to do to read it.
1 -
You would need to put the location of the file in the message payload so that your receiving application could locate it. If you need to store the file in a queue, as you mentioned, then you'll need to follow @amackenzie 's advice above, but you'll be subject to the maximum message size of 30MB. If your file is bigger than that, you'll need to split the file in to chunks and re-assemble it.
1