Data Queue 與 socket

請問用Data Queue 與 socket傳輸資料有何不同之處? 優缺點為何?
敝公司原先的應用系統用socket傳輸資料到AS400, 後來統一改用data queue, 這樣有甚麼好處?

1 個回答

iT邦大師 1 級 ‧ 2008-07-31 22:19:59

Data Queues在程式間採用非同步(asynchronous)通訊方式, Socket則是則是採同步通訊的方式作業.

Data Queues的好處有

  • performance can be dramatically improved over individual submits if the job is complex
  • record locking conflicts are eliminated if only one job is updating.
  • they can facilitate clean modular design

Data Queues的壞處為

  • they are hard to document well - the next programmer will have to think to figure them out
  • they can't really be audited, backed up, or for that matter conveniently examined.
  • the contents are almost invisible, although smart programmers have written program to read the queue, print the entry, and re-write it.
  • Once the entry is read it is gone; if the program halts the entry is lost. This can be gotten around with an audit file; write a record when the entry is written, nad have the receiver program update a status field when done.