use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class AbstractMessageSequenceSplitter method processParts.
protected List<CoreEvent> processParts(MessageSequence<?> seq, CoreEvent originalEvent) throws MuleException {
List<CoreEvent> resultEvents = new ArrayList<>();
int correlationSequence = 0;
MessageSequence<?> messageSequence = seq;
if (batchSize > 1) {
messageSequence = new PartitionedMessageSequence<>(seq, batchSize);
}
Integer count = messageSequence.size();
CoreEvent lastResult = null;
for (; messageSequence.hasNext(); ) {
correlationSequence++;
final Builder builder = builder(originalEvent);
propagateFlowVars(lastResult, builder);
if (counterVariableName != null) {
builder.addVariable(counterVariableName, correlationSequence);
}
builder.groupCorrelation(Optional.of(count != null ? GroupCorrelation.of(correlationSequence, count) : GroupCorrelation.of(correlationSequence)));
Object nextValue = messageSequence.next();
initEventBuilder(nextValue, originalEvent, builder, resolvePropagatedFlowVars(lastResult));
try {
// TODO MULE-13052 Migrate Splitter and Foreach implementation to non-blocking
CoreEvent resultEvent = processToApplyWithChildContext(builder.build(), applyNext());
if (resultEvent != null) {
resultEvents.add(builder(originalEvent.getContext(), resultEvent).build());
lastResult = resultEvent;
}
} catch (MessagingException e) {
if (!filterOnErrorTypeAcceptor.accept(e.getEvent())) {
throw e;
}
} finally {
if (nextValue instanceof EventBuilderConfigurer) {
((EventBuilderConfigurer) nextValue).eventCompleted();
}
}
}
if (correlationSequence == 1) {
logger.debug("Splitter only returned a single result. If this is not expected, please check your split expression");
}
return resultEvents;
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ExtensionSourceExceptionCallbackTestCase method exceptionHandlingCallbackInvoked.
@Test
public void exceptionHandlingCallbackInvoked() {
ArgumentCaptor<MessagingException> exceptionCaptor = forClass(MessagingException.class);
onException();
verify(exceptionHandlingCallback).accept(exceptionCaptor.capture());
MessagingException messagingException = exceptionCaptor.getValue();
assertThat(messagingException, is(notNullValue()));
assertThat(messagingException.getCause(), is(sameInstance(exception)));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithoutCause.
@Test
public void getCauseExceptionWithoutCause() {
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent);
assertThat(exception.getRootCause(), is(exception));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithMuleCause.
@Test
public void getCauseExceptionWithMuleCause() {
DefaultMuleException causeException = new DefaultMuleException("");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.getRootCause(), is(causeException));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedExactlyByWithNonMuleCauseWithNonMuleCause.
@Test
public void causedExactlyByWithNonMuleCauseWithNonMuleCause() {
ConnectException causeCauseException = new ConnectException();
IOException causeException = new IOException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.causedExactlyBy(ConnectException.class), is(true));
assertThat(exception.causedExactlyBy(SocketException.class), is(false));
assertThat(exception.causedExactlyBy(IOException.class), is(true));
assertThat(exception.causedExactlyBy(MessagingException.class), is(true));
}
Aggregations