Here is my scenario:
- Pick up message off of a queue (IBM MQ)
- Pass to async process (Archive the file and get fileId from DB) Thread #1
- Shred the xml message and join to process #2 (So I can use fileId) Thread #2
- Send shredded data to DB with fileId (From Thread #1 and Thread #2)
- In Parallel with Steps #2 and #3 above I will modify the message and send to another queue Thread #3
EDIT: The reason I was thinking about using multiple threads is that for step #5 I want it to modify the xml and write to the queue regardless if Step #2 and #3 fail. I was thinking for Step #2 and #3 that I could do archive and shred xml separately to try and speed up that process.
Number of Messages a day (200,000 to 500,000)
Question: If I am using the same message for all three processes above will I run into any issues? Should I copy the message so that when I modify the message in Step #5 (Thread #3) I don’t have any issues? I am still ignroant with multi-threading so I am just trying to think through the best way to handle this scenario and have the most throughput.
Using C# 4.0.
Thanks,
S
This will be OK if the message is (treated as) immutable.
So you definitely need a copy in step 5.
For the rest: It depends, on almost everything.
You may see some advantage from threading due to the different I/O channels.
On the other hand, if there are many messages coming in then it might work just as well or better to do all 5 steps on 1 Thread per message.