I’m not sure if I understand your question completely.
If you want to write data from program A to data queue X and have that data also be written, transparently to program A, to data queue Y then I would suggest journaling data queue X, having program B receive the journal entries, and then write the data to data queue Y.
If you want to read/receive data in program A from data queue X and have that data, as it’s being read, also written to data queue Y then I suspect you are going to need to modify program A to write the data to Y.
I hope this helps,
Bruce Vining Services