title: JMS transaction
body: <p>Database transactions is a familiar concept.</p>
  
  <pre><code>try {
    ...
    ..
    updateDB()
    ..
    ...
    commit();
  } catch error {
    rollback();
  }
  </code></pre>
  
  <p>if any error occurs any changes made by updateDB will be discarded.</p>
  
  <p>I wanted to know what a message queue transaction rollback will undo.</p>
  
  <pre><code>try{
    ...
    ...
    //EDIT: swapped the order of receive and send
    Message m = queue1.receiveMessage(..)
    ..
    ..
    queue2.sendMessage(..)
    ..
    ..
    commit();
  } catch error {
    rollback();
  }
  </code></pre>
  
  <p>specifically, what will rollback do </p>
  
  <ol>
  <li>cancel the sending of message  </li>
  <li>un-receive the message ie put back the received
  message back to queue </li>
  </ol>
  
  <p>or am i stretching the database tx analogy too far.</p>
  
  <p>thanks</p>
  
  <p><em>EDIT</em>: i am not implying the send and receive operations are related. i just wanted to say there are two operations that change the state of the message broker -- receive will take out a message from the queue which will be unavailable for other consumers if there were any. </p>