Search in sources :

Example 1 with CouldNotRouteOutboundMessageException

use of org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException in project mule by mulesoft.

the class RoundRobin method route.

/**
 * Process the event using the next target route in sequence
 */
@Override
public CoreEvent route(CoreEvent event) throws MuleException {
    int modulo = getAndIncrementModuloN(routes.size());
    if (modulo < 0) {
        throw new CouldNotRouteOutboundMessageException(this);
    }
    Processor mp = routes.get(modulo);
    try {
        return doProcessRoute(mp, event);
    } catch (MuleException ex) {
        throw new RoutingException(this, ex);
    }
}
Also used : CouldNotRouteOutboundMessageException(org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException) RoutingException(org.mule.runtime.core.privileged.routing.RoutingException) Processor(org.mule.runtime.core.api.processor.Processor) MuleException(org.mule.runtime.api.exception.MuleException)

Example 2 with CouldNotRouteOutboundMessageException

use of org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException in project mule by mulesoft.

the class FirstSuccessfulTestCase method testRouteReturnsNullMessage.

@Test
public void testRouteReturnsNullMessage() throws Exception {
    Processor nullEventMp = event -> CoreEvent.builder(event).message(null).build();
    FirstSuccessful fs = createFirstSuccessfulRouter(nullEventMp);
    fs.setAnnotations(getAppleFlowComponentLocationAnnotations());
    fs.initialise();
    try {
        fs.process(testEvent());
        fail("Exception expected");
    } catch (CouldNotRouteOutboundMessageException e) {
    // this one was expected
    }
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Message(org.mule.runtime.api.message.Message) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) Processor(org.mule.runtime.core.api.processor.Processor) Assert.assertThat(org.junit.Assert.assertThat) DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession) CouldNotRouteOutboundMessageException(org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException) MuleException(org.mule.runtime.api.exception.MuleException) Arrays.asList(java.util.Arrays.asList) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Component(org.mule.runtime.api.component.Component) Assert.fail(org.junit.Assert.fail) MuleContextUtils.eventBuilder(org.mule.tck.util.MuleContextUtils.eventBuilder) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) DefaultExceptionPayload(org.mule.runtime.core.internal.message.DefaultExceptionPayload) Error(org.mule.runtime.api.message.Error) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Message.of(org.mule.runtime.api.message.Message.of) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MuleTestUtils.createErrorMock(org.mule.tck.MuleTestUtils.createErrorMock) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) Matchers.is(org.hamcrest.Matchers.is) Mockito.withSettings(org.mockito.Mockito.withSettings) FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) Mockito.mock(org.mockito.Mockito.mock) InternalEvent(org.mule.runtime.core.internal.message.InternalEvent) CouldNotRouteOutboundMessageException(org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException) Processor(org.mule.runtime.core.api.processor.Processor) Test(org.junit.Test)

Aggregations

MuleException (org.mule.runtime.api.exception.MuleException)2 Processor (org.mule.runtime.core.api.processor.Processor)2 CouldNotRouteOutboundMessageException (org.mule.runtime.core.privileged.routing.CouldNotRouteOutboundMessageException)2 Arrays.asList (java.util.Arrays.asList)1 Matchers.is (org.hamcrest.Matchers.is)1 Matchers.nullValue (org.hamcrest.Matchers.nullValue)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Mockito.withSettings (org.mockito.Mockito.withSettings)1 Component (org.mule.runtime.api.component.Component)1 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)1 Error (org.mule.runtime.api.message.Error)1 Message (org.mule.runtime.api.message.Message)1 Message.of (org.mule.runtime.api.message.Message.of)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 DefaultExceptionPayload (org.mule.runtime.core.internal.message.DefaultExceptionPayload)1