javax.jms.TransactionInProgressException Java Examples
The following examples show how to use
javax.jms.TransactionInProgressException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActiveMQRASession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Commit * * @throws JMSException Failed to close session. */ @Override public void commit() throws JMSException { if (cri.getType() == ActiveMQRAConnectionFactory.XA_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) { throw new TransactionInProgressException("XA connection"); } lock(); try { Session session = getSessionInternal(); if (cri.isTransacted() == false) { throw new IllegalStateException("Session is not transacted"); } if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Commit session " + this); } session.commit(); } finally { unlock(); } }
Example #2
Source File: ActiveMQRASession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Rollback * * @throws JMSException Failed to close session. */ @Override public void rollback() throws JMSException { if (cri.getType() == ActiveMQRAConnectionFactory.XA_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) { throw new TransactionInProgressException("XA connection"); } lock(); try { Session session = getSessionInternal(); if (cri.isTransacted() == false) { throw new IllegalStateException("Session is not transacted"); } if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Rollback session " + this); } session.rollback(); } finally { unlock(); } }
Example #3
Source File: TransactionAwareConnectionFactoryProxy.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on SessionProxy interface coming in... if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of Connection proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("commit")) { throw new TransactionInProgressException("Commit call not allowed within a managed transaction"); } else if (method.getName().equals("rollback")) { throw new TransactionInProgressException("Rollback call not allowed within a managed transaction"); } else if (method.getName().equals("close")) { // Handle close method: not to be closed within a transaction. return null; } else if (method.getName().equals("getTargetSession")) { // Handle getTargetSession method: return underlying Session. return this.target; } // Invoke method on target Session. try { return method.invoke(this.target, args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
Example #4
Source File: TransactionAwareConnectionFactoryProxy.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on SessionProxy interface coming in... if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of Connection proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("commit")) { throw new TransactionInProgressException("Commit call not allowed within a managed transaction"); } else if (method.getName().equals("rollback")) { throw new TransactionInProgressException("Rollback call not allowed within a managed transaction"); } else if (method.getName().equals("close")) { // Handle close method: not to be closed within a transaction. return null; } else if (method.getName().equals("getTargetSession")) { // Handle getTargetSession method: return underlying Session. return this.target; } // Invoke method on target Session. try { return method.invoke(this.target, args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
Example #5
Source File: TransactionAwareConnectionFactoryProxy.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on SessionProxy interface coming in... if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of Connection proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("commit")) { throw new TransactionInProgressException("Commit call not allowed within a managed transaction"); } else if (method.getName().equals("rollback")) { throw new TransactionInProgressException("Rollback call not allowed within a managed transaction"); } else if (method.getName().equals("close")) { // Handle close method: not to be closed within a transaction. return null; } else if (method.getName().equals("getTargetSession")) { // Handle getTargetSession method: return underlying Session. return this.target; } // Invoke method on target Session. try { return method.invoke(this.target, args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
Example #6
Source File: JmsExceptionUtils.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Converts instances of sub-classes of {@link JMSException} into the corresponding sub-class of * {@link JMSRuntimeException}. * * @param e * @return */ public static JMSRuntimeException convertToRuntimeException(JMSException e) { if (e instanceof javax.jms.IllegalStateException) { return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidClientIDException) { return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidDestinationException) { return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidSelectorException) { return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof JMSSecurityException) { return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof MessageFormatException) { return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof MessageNotWriteableException) { return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof ResourceAllocationException) { return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof TransactionInProgressException) { return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof TransactionRolledBackException) { return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e); } return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); }
Example #7
Source File: ActiveMQSession.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void commit() throws JMSException { if (!transacted) { throw new IllegalStateException("Cannot commit a non-transacted session"); } if (xa) { throw new TransactionInProgressException("Cannot call commit on an XA session"); } try { session.commit(); } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
Example #8
Source File: ActiveMQSession.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void rollback() throws JMSException { if (!transacted) { throw new IllegalStateException("Cannot rollback a non-transacted session"); } if (xa) { throw new TransactionInProgressException("Cannot call rollback on an XA session"); } try { session.rollback(); } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
Example #9
Source File: JMS2.java From tomee with Apache License 2.0 | 5 votes |
public static JMSRuntimeException toRuntimeException(final JMSException e) { if (e instanceof javax.jms.IllegalStateException) { return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidClientIDException) { return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidDestinationException) { return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof InvalidSelectorException) { return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof JMSSecurityException) { return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof MessageFormatException) { return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof MessageNotWriteableException) { return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof ResourceAllocationException) { return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof TransactionInProgressException) { return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e); } if (e instanceof TransactionRolledBackException) { return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e); } return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); }
Example #10
Source File: JMSExceptionSupportTest.java From pooled-jms with Apache License 2.0 | 4 votes |
@Test(expected = TransactionInProgressRuntimeException.class) public void testConvertsTransactionInProgressExceptionToTransactionInProgressRuntimeException() { throw JMSExceptionSupport.createRuntimeException(new TransactionInProgressException("error")); }
Example #11
Source File: JmsExceptionSupportTest.java From qpid-jms with Apache License 2.0 | 4 votes |
@Test(expected = TransactionInProgressRuntimeException.class) public void testConvertsTransactionInProgressExceptionToTransactionInProgressRuntimeException() { throw JmsExceptionSupport.createRuntimeException(new TransactionInProgressException("error")); }