Search in sources :

Example 36 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractFlowConstruct method initialise.

@Override
public final void initialise() throws InitialisationException {
    try {
        lifecycleManager.fireInitialisePhase((phaseName, object) -> {
            initialiseIfNeeded(exceptionListener, muleContext);
            validateConstruct();
            doInitialise();
        });
    } catch (InitialisationException e) {
        safely(() -> dispose());
        throw e;
    } catch (MuleException e) {
        safely(() -> dispose());
        throw new InitialisationException(e, this);
    }
}
Also used : InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 37 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractPipeline method doInitialise.

@Override
protected void doInitialise() throws MuleException {
    super.doInitialise();
    pipeline = createPipeline();
    if (source != null) {
        source.setListener(new Processor() {

            @Override
            public CoreEvent process(CoreEvent event) throws MuleException {
                return processToApply(event, this);
            }

            @Override
            public Publisher<CoreEvent> apply(Publisher<CoreEvent> publisher) {
                return from(publisher).transform(dispatchToFlow());
            }
        });
    }
    initialiseIfNeeded(source, muleContext);
    initialiseIfNeeded(pipeline, muleContext);
}
Also used : ReactiveProcessor(org.mule.runtime.core.api.processor.ReactiveProcessor) Processor(org.mule.runtime.core.api.processor.Processor) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) MuleException(org.mule.runtime.api.exception.MuleException)

Example 38 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class DefaultMuleContext method dispose.

@Override
public void dispose() {
    synchronized (lifecycleStateLock) {
        if (isStarted() || (lifecycleManager.getLastPhaseExecuted() != null && (lifecycleManager.getLastPhaseExecuted().equals(Startable.PHASE_NAME) && lifecycleManager.isLastPhaseExecutionFailed()))) {
            try {
                stop();
            } catch (MuleException e) {
                logger.error("Failed to stop Mule context", e);
            }
        }
        getLifecycleManager().checkPhase(Disposable.PHASE_NAME);
        fireNotification(new MuleContextNotification(this, CONTEXT_DISPOSING));
        disposeIfNeeded(getExceptionListener(), logger);
        try {
            getLifecycleManager().fireLifecycle(Disposable.PHASE_NAME);
            // abstraction?
            if (muleRegistryHelper != null) {
                safely(() -> muleRegistryHelper.dispose());
            }
        } catch (Exception e) {
            logger.debug("Failed to cleanly dispose Mule: " + e.getMessage(), e);
        }
        notificationManager.fireNotification(new MuleContextNotification(this, CONTEXT_DISPOSED));
        disposeManagers();
        if ((getStartDate() > 0) && logger.isInfoEnabled()) {
            SplashScreen shutdownScreen = buildShutdownSplash();
            logger.info(shutdownScreen.toString());
        }
        // registryBroker.dispose();
        setExecutionClassLoader(null);
    }
}
Also used : SplashScreen(org.mule.runtime.core.internal.util.splash.SplashScreen) ServerStartupSplashScreen(org.mule.runtime.core.internal.util.splash.ServerStartupSplashScreen) ArtifactShutdownSplashScreen(org.mule.runtime.core.internal.util.splash.ArtifactShutdownSplashScreen) ServerShutdownSplashScreen(org.mule.runtime.core.internal.util.splash.ServerShutdownSplashScreen) ArtifactStartupSplashScreen(org.mule.runtime.core.internal.util.splash.ArtifactStartupSplashScreen) MuleContextNotification(org.mule.runtime.core.api.context.notification.MuleContextNotification) MuleException(org.mule.runtime.api.exception.MuleException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) MuleException(org.mule.runtime.api.exception.MuleException) ConnectException(org.mule.runtime.core.api.connector.ConnectException) LifecycleException(org.mule.runtime.api.lifecycle.LifecycleException) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException)

Example 39 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class InvokerMessageProcessor method process.

@Override
public CoreEvent process(CoreEvent event) throws MuleException {
    CoreEvent resultEvent = event;
    Object[] args = evaluateArguments(event, arguments);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(format("Invoking  '%s' of '%s' with arguments: '%s'", method.getName(), object, args));
    }
    try {
        Object result = method.invoke(object, args);
        if (!method.getReturnType().equals(void.class)) {
            resultEvent = createResultEvent(event, result);
        }
    } catch (Exception e) {
        throw new MessagingException(failedToInvoke(object.toString()), event, e, this);
    }
    return resultEvent;
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) CoreMessages.methodWithParamsNotFoundOnObject(org.mule.runtime.core.api.config.i18n.CoreMessages.methodWithParamsNotFoundOnObject) CoreMessages.methodWithNumParamsNotFoundOnObject(org.mule.runtime.core.api.config.i18n.CoreMessages.methodWithNumParamsNotFoundOnObject) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException)

Example 40 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class TryScope method process.

@Override
public CoreEvent process(final CoreEvent event) throws MuleException {
    if (nestedChain == null) {
        return event;
    } else {
        ExecutionTemplate<CoreEvent> executionTemplate = createScopeTransactionalExecutionTemplate(muleContext, transactionConfig);
        ExecutionCallback<CoreEvent> processingCallback = () -> {
            try {
                CoreEvent e = processToApply(event, p -> from(p).flatMap(request -> processWithChildContext(request, nestedChain, ofNullable(getLocation()), messagingExceptionHandler)));
                return e;
            } catch (Exception e) {
                throw e;
            }
        };
        try {
            return executionTemplate.execute(processingCallback);
        } catch (MuleException e) {
            throw e;
        } catch (Exception e) {
            throw new DefaultMuleException(errorInvokingMessageProcessorWithinTransaction(nestedChain, transactionConfig), e);
        }
    }
}
Also used : CoreMessages.errorInvokingMessageProcessorWithinTransaction(org.mule.runtime.core.api.config.i18n.CoreMessages.errorInvokingMessageProcessorWithinTransaction) TransactionalExecutionTemplate.createScopeTransactionalExecutionTemplate(org.mule.runtime.core.api.execution.TransactionalExecutionTemplate.createScopeTransactionalExecutionTemplate) MessageProcessors.newChain(org.mule.runtime.core.privileged.processor.MessageProcessors.newChain) Optional.of(java.util.Optional.of) Flux.from(reactor.core.publisher.Flux.from) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) LoggerFactory(org.slf4j.LoggerFactory) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) Processor(org.mule.runtime.core.api.processor.Processor) TransactionCoordination.isTransactionActive(org.mule.runtime.core.api.transaction.TransactionCoordination.isTransactionActive) Collections.singletonList(java.util.Collections.singletonList) Scope(org.mule.runtime.core.privileged.processor.Scope) TransactionConfig(org.mule.runtime.core.api.transaction.TransactionConfig) MuleException(org.mule.runtime.api.exception.MuleException) AbstractMessageProcessorOwner(org.mule.runtime.core.api.processor.AbstractMessageProcessorOwner) LifecycleUtils.stopIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded) MuleTransactionConfig(org.mule.runtime.core.api.transaction.MuleTransactionConfig) Logger(org.slf4j.Logger) MessageProcessors.processToApply(org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply) Optional.ofNullable(java.util.Optional.ofNullable) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) LifecycleUtils.startIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.startIfNeeded) ACTION_INDIFFERENT(org.mule.runtime.core.api.transaction.TransactionConfig.ACTION_INDIFFERENT) FlowExceptionHandler(org.mule.runtime.core.api.exception.FlowExceptionHandler) MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) LifecycleUtils.disposeIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.disposeIfNeeded) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) List(java.util.List) ExecutionTemplate(org.mule.runtime.core.api.execution.ExecutionTemplate) MessageProcessors.processWithChildContext(org.mule.runtime.core.privileged.processor.MessageProcessors.processWithChildContext) MessageProcessors.getProcessingStrategy(org.mule.runtime.core.privileged.processor.MessageProcessors.getProcessingStrategy) ExecutionCallback(org.mule.runtime.core.api.execution.ExecutionCallback) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MuleException(org.mule.runtime.api.exception.MuleException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException)

Aggregations

MuleException (org.mule.runtime.api.exception.MuleException)68 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)21 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)19 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)19 Test (org.junit.Test)15 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)14 Processor (org.mule.runtime.core.api.processor.Processor)12 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)9 Logger (org.slf4j.Logger)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)6 Map (java.util.Map)5 ConnectionException (org.mule.runtime.api.connection.ConnectionException)5 MuleContext (org.mule.runtime.core.api.MuleContext)5 LifecycleUtils.stopIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded)5 Thread.currentThread (java.lang.Thread.currentThread)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Startable (org.mule.runtime.api.lifecycle.Startable)4