question: public void testSendSessionClose ( ) throws Exception { Message [ ] outbound = new Message [ ] { session . createTextMessage ( "First Message" ) , session . createTextMessage ( "Second Message" ) } ; beginTx ( ) ; producer . send ( outbound [ 0 ] ) ; commitTx ( ) ; beginTx ( ) ; producer . send ( session . createTextMessage ( "I'm going to get rolled back." ) ) ; consumer . close ( ) ; reconnectSession ( ) ; producer . send ( outbound [ 1 ] ) ; commitTx ( ) ; ArrayList < Message > messages = new ArrayList < > ( ) ; LOG . info ( "About to consume message 1" ) ; beginTx ( ) ; Message message = consumer . receive ( 1000 ) ; messages . add ( message ) ; LOG . info ( "Received: " + message ) ; LOG . info ( "About to consume message 2" ) ; message = consumer . receive ( 4000 ) ; messages . add ( message ) ; LOG . info ( "Received: " + message ) ; commitTx ( ) ; Message inbound [ ] = new Message [ messages . size ( ) ] ; messages . toArray ( inbound ) ; assertTextMessagesEqual ( "Rollback did not work." , outbound , inbound ) ; }
target:  Sends a batch of messages and validates that the message sent before session close is not consumed. This test only works with local transactions, not xa.