Buggy code:
public abstract class AbstractPollingMessageListenerContainer extends AbstractMessageListenerContainer implements BeanNameAware { public static final long DEFAULT_RECEIVE_TIMEOUT = 1000 ; private final AbstractPollingMessageListenerContainer . MessageListenerContainerResourceFactory transactionalResourceFactory = new AbstractPollingMessageListenerContainer . MessageListenerContainerResourceFactory ( ) ; private boolean sessionTransactedCalled = false ; private boolean pubSubNoLocal = false ; private PlatformTransactionManager transactionManager ; private DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition ( ) ; private long receiveTimeout = AbstractPollingMessageListenerContainer . DEFAULT_RECEIVE_TIMEOUT ; public void setSessionTransacted ( boolean sessionTransacted ) { } public void setPubSubNoLocal ( boolean pubSubNoLocal ) { } protected boolean isPubSubNoLocal ( ) { } public void setTransactionManager ( PlatformTransactionManager transactionManager ) { } protected final PlatformTransactionManager getTransactionManager ( ) { } public void setTransactionName ( String transactionName ) { } public void setTransactionTimeout ( int transactionTimeout ) { } public void setReceiveTimeout ( long receiveTimeout ) { } public void initialize ( ) { } protected MessageConsumer createListenerConsumer ( Session session ) throws JMSException { } protected boolean receiveAndExecute ( Object invoker , Session session , MessageConsumer consumer ) throws JMSException { } protected boolean doReceiveAndExecute ( Object invoker , Session session , MessageConsumer consumer , TransactionStatus status ) throws JMSException { Connection conToClose = null ; Session sessionToClose = null ; MessageConsumer consumerToClose = null ; try { Session sessionToUse = session ; boolean transactional = false ; if ( sessionToUse == null ) { sessionToUse = ConnectionFactoryUtils . doGetTransactionalSession ( getConnectionFactory ( ) , this . transactionalResourceFactory , true ) ; transactional = sessionToUse != null ; } if ( sessionToUse == null ) { Connection conToUse ; if ( sharedConnectionEnabled ( ) ) { conToUse = getSharedConnection ( ) ; } else { conToUse = createConnection ( ) ; conToClose = conToUse ; conToUse . start ( ) ; } sessionToUse = createSession ( conToUse ) ; sessionToClose = sessionToUse ; } MessageConsumer consumerToUse = consumer ; if ( consumerToUse == null ) { consumerToUse = createListenerConsumer ( sessionToUse ) ; consumerToClose = consumerToUse ; } Message message = receiveMessage ( consumerToUse ) ; if ( message != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( ( ( ( ( ( ( ( "Received<seq2seq4repair_space>message<seq2seq4repair_space>of<seq2seq4repair_space>type<seq2seq4repair_space>[" + ( message . getClass ( ) ) ) + "]<seq2seq4repair_space>from<seq2seq4repair_space>consumer<seq2seq4repair_space>[" ) + consumerToUse ) + "]<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( transactional ? "transactional<seq2seq4repair_space>" : "" ) ) + "session<seq2seq4repair_space>[" ) + sessionToUse ) + "]" ) ) ; } messageReceived ( invoker , sessionToUse ) ; boolean exposeResource = ( ( ! transactional ) && ( isExposeListenerSession ( ) ) ) && ( ! ( TransactionSynchronizationManager . hasResource ( getConnectionFactory ( ) ) ) ) ; if ( exposeResource ) { TransactionSynchronizationManager . bindResource ( getConnectionFactory ( ) , new LocallyExposedJmsResourceHolder ( sessionToUse ) ) ; } try { doExecuteListener ( sessionToUse , message ) ; } catch ( Throwable ex ) { if ( status != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( "Rolling<seq2seq4repair_space>back<seq2seq4repair_space>transaction<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>listener<seq2seq4repair_space>exception<seq2seq4repair_space>thrown:<seq2seq4repair_space>" + ex ) ) ; } status . setRollbackOnly ( ) ; } handleListenerException ( ex ) ; if ( ex instanceof JMSException ) { throw ( ( JMSException ) ( ex ) ) ; } } finally { if ( exposeResource ) { TransactionSynchronizationManager . unbindResource ( getConnectionFactory ( ) ) ; } } return true ; } else { if ( logger . isTraceEnabled ( ) ) { logger . trace ( ( ( ( ( ( ( "Consumer<seq2seq4repair_space>[" + consumerToUse ) + "]<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( transactional ? "transactional<seq2seq4repair_space>" : "" ) ) + "session<seq2seq4repair_space>[" ) + sessionToUse ) + "]<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>receive<seq2seq4repair_space>a<seq2seq4repair_space>message" ) ) ; } noMessageReceived ( invoker , sessionToUse ) ; <START_BUG> commitIfNecessary ( session , message ) ; <END_BUG> return false ; } } finally { JmsUtils . closeMessageConsumer ( consumerToClose ) ; JmsUtils . closeSession ( sessionToClose ) ; ConnectionFactoryUtils . releaseConnection ( conToClose , getConnectionFactory ( ) , true ) ; } } protected boolean isSessionLocallyTransacted ( Session session ) { } private void rollbackOnException ( TransactionStatus status , Throwable ex ) { } protected Message receiveMessage ( MessageConsumer consumer ) throws JMSException { } protected void messageReceived ( Object invoker , Session session ) { } protected void noMessageReceived ( Object invoker , Session session ) { } protected Connection getConnection ( JmsResourceHolder holder ) { } protected Session getSession ( JmsResourceHolder holder ) { } protected MessageConsumer createConsumer ( Session session , Destination destination ) throws JMSException { } private class MessageListenerContainerResourceFactory implements ConnectionFactoryUtils . ResourceFactory { public Connection getConnection ( JmsResourceHolder holder ) { } public Session getSession ( JmsResourceHolder holder ) { } public Connection createConnection ( ) throws JMSException { } public Session createSession ( Connection con ) throws JMSException { } public boolean isSynchedLocalTransactionAllowed ( ) { } } }

Fix:
commitIfNecessary ( sessionToUse , message ) ;