/** * Rollback the Session if not within a JTA transaction. * @param session the JMS Session to rollback * @throws JMSException if committing failed */ public static void rollbackIfNecessary(Session session) throws JMSException { Assert.notNull(session, "Session must not be null"); try { session.rollback(); } catch (javax.jms.TransactionInProgressException | javax.jms.IllegalStateException ex) { // Ignore -> can only happen in case of a JTA transaction. } }
@Override protected void doFail() throws JMSException { LOG.info("Triggering session rollback"); session.rollback(); }
@Override public void rollback() throws JMSException { delegate.rollback(); }
void rollback() { try { session.rollback(); } catch (JMSException jmsException) { logger.warn("JMS Exception processing rollback", jmsException); } catch (RuntimeException runtimeException) { logger.warn("Runtime Exception processing rollback", runtimeException); } }
private void logicalClose(Session proxy) throws JMSException { // Preserve rollback-on-close semantics. if (this.transactionOpen && this.target.getTransacted()) { this.transactionOpen = false; this.target.rollback(); } // Physically close durable subscribers at time of Session close call. for (Iterator<Map.Entry<ConsumerCacheKey, MessageConsumer>> it = this.cachedConsumers.entrySet().iterator(); it.hasNext();) { Map.Entry<ConsumerCacheKey, MessageConsumer> entry = it.next(); if (entry.getKey().subscription != null) { entry.getValue().close(); it.remove(); } } // Allow for multiple close calls... boolean returned = false; synchronized (this.sessionList) { if (!this.sessionList.contains(proxy)) { this.sessionList.addLast(proxy); returned = true; } } if (returned && logger.isTraceEnabled()) { logger.trace("Returned cached Session: " + this.target); } }
protected void rollbackTx() throws Exception { session.rollback(); }
@Override protected void doRollback(DefaultTransactionStatus status) { JmsTransactionObject txObject = (JmsTransactionObject) status.getTransaction(); Session session = txObject.getResourceHolder().getSession(); if (session != null) { try { if (status.isDebug()) { logger.debug("Rolling back JMS transaction on Session [" + session + "]"); } session.rollback(); } catch (JMSException ex) { throw new TransactionSystemException("Could not roll back JMS transaction", ex); } } }
public void updateState(List<TridentTuple> tuples, TridentCollector collector) throws JMSException { try { for (TridentTuple tuple : tuples) { Message msg = this.options.msgProducer.toMessage(this.session, tuple); if (msg != null) { if (msg.getJMSDestination() != null) { this.messageProducer.send(msg.getJMSDestination(), msg); } else { this.messageProducer.send(msg); } } } } catch (JMSException e) { LOG.warn("Failed to send jmd message for a trident batch ", e); if (this.options.jmsTransactional) { session.rollback(); } throw new FailedException("Failed to write tuples", e); } }
@Override public void rollback() { threadAwareContext.assertNotCompletionListenerThreadRuntime(); checkSession(); try { session.rollback(); } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
private boolean doTestWithException(final Throwable t, boolean expectRollback, int expectGetTransactionCount) throws JMSException, IllegalAccessException { container.setAcceptMessagesWhileStopping(true); container.setMessageListener(new MessageListener() { @Override public void onMessage(Message arg0) { if (t instanceof RuntimeException) throw (RuntimeException) t; else throw (Error) t; } }); Session session = mock(Session.class); MessageConsumer consumer = mock(MessageConsumer.class); Message message = mock(Message.class); if (expectGetTransactionCount>0) { when(session.getTransacted()).thenReturn(true); } // Expect only one call to consumer (chunk size is 2, but first one // rolls back terminating batch)... when(consumer.receive(1000)).thenReturn(message); if (expectRollback) { session.rollback(); } boolean received = doExecute(session, consumer); return received; }
@Test public void testTransactionRollback() throws JMSException { ConnectionFactory cf = mock(ConnectionFactory.class); Connection con = mock(Connection.class); final Session session = mock(Session.class); given(cf.createConnection()).willReturn(con); given(con.createSession(true, Session.AUTO_ACKNOWLEDGE)).willReturn(session); JmsTransactionManager tm = new JmsTransactionManager(cf); TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition()); JmsTemplate jt = new JmsTemplate(cf); jt.execute(new SessionCallback<Void>() { @Override public Void doInJms(Session sess) { assertTrue(sess == session); return null; } }); tm.rollback(ts); verify(session).rollback(); verify(session).close(); verify(con).close(); }
verify(session).rollback(); verify(session).close(); verify(con).close();
Connection con1 = scf.createQueueConnection(); Session session1 = con1.createSession(true, Session.AUTO_ACKNOWLEDGE); session1.rollback(); session1.close(); session1 = con1.createSession(false, Session.CLIENT_ACKNOWLEDGE);
verify(session).rollback(); verify(connection).setExceptionListener(this.container); verify(connection).start();
jmsSession.rollback(); } catch (final JMSException jmse) { logger.warn("Unable to roll back JMS Session due to {}", new Object[]{jmse});
protected void safeRollBack(Session session) { try { if (session != null && session.getTransacted()) { session.rollback(); } } catch (Throwable e1) { LOG.log(Level.WARNING, "Rollback of Local transaction failed", e1); } }
private void safeRollback(Throwable t) { LOG.log(Level.WARNING, "Exception while processing jms message in cxf. Rolling back", t); try { if (session.getTransacted()) { session.rollback(); } } catch (Exception e) { LOG.log(Level.WARNING, "Rollback of Local transaction failed", e); } }
private void rollback(Session session) throws JMSException { if(session.getTransacted()) { session.rollback(); } }
/** * Rolls back current transaction. All "received" messages will be re-delivered. */ public void rollback(){ try { session.rollback(); } catch (JMSException e) { throw new AsyncException(e); } }
private void rollbackIfNeeded() { try { if (isTransacted()) { jmsSessionHolder.getSession().rollback(); } } catch (JMSException e) { logger.warn("Exception while JMS transaciotn rolling-back", e); } }