/** * Process the given messages. A Unit of Work must be created for this processing. * <p> * This implementation creates a Batching unit of work for the given batch of {@code eventMessages}. * * @param eventMessages The messages to process */ protected void process(List<? extends EventMessage<?>> eventMessages) { try { processInUnitOfWork(eventMessages, new BatchingUnitOfWork<>(eventMessages), Segment.ROOT_SEGMENT); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new EventProcessingException("Exception occurred while processing events", e); } }
if (phase() == Phase.NOT_STARTED) { start(); Assert.state(phase() == Phase.STARTED, () -> String.format("The UnitOfWork has an incompatible phase: %s", phase())); R result = null; ResultMessage<R> resultMessage = asResultMessage(result); rollback(e); return asResultMessage(e); setExecutionResult(new ExecutionResult(asResultMessage(e))); if (cause != null) { cause.addSuppressed(e); continue; setExecutionResult(new ExecutionResult(resultMessage)); commit(); } catch (Exception e) { resultMessage = asResultMessage(e);
/** * Checks if the message being processed now is the last of the batch being processed in this unit of work. * * @return {@code true} if the message is the last of this batch, {@code false} otherwise */ public boolean isLastMessage() { return isLastMessage(getMessage()); }
/** * Checks if the message being processed now is the first of the batch being processed in this unit of work. * * @return {@code true} if the message is the first of this batch, {@code false} otherwise */ public boolean isFirstMessage() { return isFirstMessage(getMessage()); }
if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isFirstMessage()) { tokenStore.extendClaim(getName(), unitOfWork.getResource(segmentIdResourceKey)); if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isLastMessage()) { unitOfWork.onPrepareCommit(uow -> tokenStore.storeToken(unitOfWork.getResource(lastTokenResourceKey), builder.name,
@Override public Boolean resolveParameterValue(Message<?> message) { return CurrentUnitOfWork.map(unitOfWork -> !(unitOfWork instanceof BatchingUnitOfWork<?>) || ((BatchingUnitOfWork<?>) unitOfWork).isLastMessage(message)).orElse(true); }
/** * Checks if the message being processed now is the first of the batch being processed in this unit of work. * * @return {@code true} if the message is the first of this batch, {@code false} otherwise */ public boolean isFirstMessage() { return isFirstMessage(getMessage()); }
if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isFirstMessage()) { tokenStore.extendClaim(getName(), unitOfWork.getResource(segmentIdResourceKey)); if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isLastMessage()) { unitOfWork.onPrepareCommit(uow -> tokenStore.storeToken(unitOfWork.getResource(lastTokenResourceKey), name,
@Override public Boolean resolveParameterValue(Message<?> message) { return CurrentUnitOfWork.map(unitOfWork -> !(unitOfWork instanceof BatchingUnitOfWork<?>) || ((BatchingUnitOfWork<?>) unitOfWork).isLastMessage(message)).orElse(true); }
if (phase() == Phase.NOT_STARTED) { start(); Assert.state(phase() == Phase.STARTED, () -> String.format("The UnitOfWork has an incompatible phase: %s", phase())); R result = null; Exception exception = null; } catch (Exception e) { if (rollbackConfiguration.rollBackOn(e)) { rollback(e); throw e; setExecutionResult(new ExecutionResult(e)); if (exception != null) { exception.addSuppressed(e); setExecutionResult(new ExecutionResult(result)); commit(); if (exception != null) { throw exception;
/** * Checks if the message being processed now is the last of the batch being processed in this unit of work. * * @return {@code true} if the message is the last of this batch, {@code false} otherwise */ public boolean isLastMessage() { return isLastMessage(getMessage()); }
/** * Checks if the message being processed now is the first of the batch being processed in this unit of work. * * @return {@code true} if the message is the first of this batch, {@code false} otherwise */ public boolean isFirstMessage() { return isFirstMessage(getMessage()); }
if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isFirstMessage()) { tokenStore.extendClaim(getName(), unitOfWork.getResource(segmentIdResourceKey)); if (!(unitOfWork instanceof BatchingUnitOfWork) || ((BatchingUnitOfWork) unitOfWork).isLastMessage()) { unitOfWork.onPrepareCommit(uow -> tokenStore.storeToken(unitOfWork.getResource(lastTokenResourceKey), builder.name,
UnitOfWork<? extends EventMessage<?>> unitOfWork = new BatchingUnitOfWork<>(batch); unitOfWork.attachTransaction(transactionManager); unitOfWork.resources().put(segmentIdResourceKey, segment.getSegmentId());
@Override public Boolean resolveParameterValue(Message<?> message) { return CurrentUnitOfWork.map(unitOfWork -> !(unitOfWork instanceof BatchingUnitOfWork<?>) || ((BatchingUnitOfWork<?>) unitOfWork).isLastMessage(message)).orElse(true); }
if (phase() == Phase.NOT_STARTED) { start(); Assert.state(phase() == Phase.STARTED, () -> String.format("The UnitOfWork has an incompatible phase: %s", phase())); R result = null; ResultMessage<R> resultMessage = asResultMessage(result); rollback(e); return asResultMessage(e); setExecutionResult(new ExecutionResult(asResultMessage(e))); if (cause != null) { cause.addSuppressed(e); continue; setExecutionResult(new ExecutionResult(resultMessage)); commit(); } catch (Exception e) { resultMessage = asResultMessage(e);
/** * Checks if the message being processed now is the last of the batch being processed in this unit of work. * * @return {@code true} if the message is the last of this batch, {@code false} otherwise */ public boolean isLastMessage() { return isLastMessage(getMessage()); }
/** * Process the given messages. A Unit of Work must be created for this processing. * <p> * This implementation creates a Batching unit of work for the given batch of {@code eventMessages}. * * @param eventMessages The messages to process */ protected void process(List<? extends EventMessage<?>> eventMessages) { try { processInUnitOfWork(eventMessages, new BatchingUnitOfWork<>(eventMessages), Segment.ROOT_SEGMENT); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new EventProcessingException("Exception occurred while processing events", e); } }
/** * Process the given messages. A Unit of Work must be created for this processing. * <p> * This implementation creates a Batching unit of work for the given batch of {@code eventMessages}. * * @param eventMessages The messages to process */ protected void process(List<? extends EventMessage<?>> eventMessages) { try { processInUnitOfWork(eventMessages, new BatchingUnitOfWork<>(eventMessages), Segment.ROOT_SEGMENT); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new EventProcessingException("Exception occurred while processing events", e); } }
UnitOfWork<? extends EventMessage<?>> unitOfWork = new BatchingUnitOfWork<>(batch); unitOfWork.attachTransaction(transactionManager); unitOfWork.resources().put(segmentIdResourceKey, segment.getSegmentId());