Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-1476

Transaction interface: Expose "clearAbortCause" for don't pick up handled persistence Exceptions

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.13.0
    • Fix Version/s: 1.13.1
    • Component/s: None
    • Labels:
      None

      Description

      That way we avoid casting from "Transaction" to "IsisTransaction", and can support use cases that properly handle the Exception without further consequences.

      For example, creating an idempotent action that first tries to create an object and, if an SQLIntegrityConstraintViolationException occurs, return the previously persisted entity, avoiding one SELECT on massive bulk actions.

       // {{ addMessage (action)
          @Action(semantics=SemanticsOf.IDEMPOTENT)
          public Message addMessageIdempotent(
      	    final String receiptHandle, final String notificationId,
      	    final Clob xmlContent, final String notificationType, 
      	    final DateTime publishTime, final String payloadVersion) {
      	Notification unprocessedNotification = null;
      
      	try {
      	    unprocessedMessage = this.wrap(this).createMessage(receiptHandle,
      		    notificationId, amazonMarketplace, xmlContent,
      		    notificationType, publishTime, payloadVersion, sellerId);
      	} catch (final JDODataStoreException e) {
      	    if (Iterables.filter(Throwables.getCausalChain(e),
      		    SQLIntegrityConstraintViolationException.class) != null) {
      
      		((IsisTransaction) this.transactionService.currentTransaction())
      			.clearAbortCause();
      
      		unprocessedMessage = this.wrap(this).findByReceiptHandle(
      			receiptHandle);
      	    } else {
      		throw e;
      	    }
      	}
      
      	return unprocessedMessage;
      
          }
      
          // }}
      

      If published in the "Transaction" interface, the casting can be avoided, being simply:

      		this.transactionService.currentTransaction()
      			.clearAbortCause();
      

        Attachments

          Activity

            People

            • Assignee:
              danhaywood Dan Haywood
              Reporter:
              oscarbou Oscar Bou
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: