Search in sources :

Example 1 with SimpleRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate in project mule by mulesoft.

the class RetryPolicyTemplateObjectFactory method doGetObject.

@Override
public RetryPolicyTemplate doGetObject() throws Exception {
    SimpleRetryPolicyTemplate retryPolicyTemplate = new SimpleRetryPolicyTemplate(frequency, count);
    retryPolicyTemplate.setNotificationFirer(notificationFirer);
    if (retryNotifier != null) {
        retryPolicyTemplate.setNotifier(retryNotifier);
    }
    if (!blocking) {
        return new AsynchronousRetryTemplate(retryPolicyTemplate);
    }
    return retryPolicyTemplate;
}
Also used : SimpleRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate) AsynchronousRetryTemplate(org.mule.runtime.core.api.retry.async.AsynchronousRetryTemplate)

Example 2 with SimpleRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate in project mule by mulesoft.

the class UntilSuccessful method initialise.

@Override
public void initialise() throws InitialisationException {
    if (processors == null) {
        throw new InitialisationException(createStaticMessage("One message processor must be configured within 'until-successful'."), this);
    }
    this.nestedChain = newChain(getProcessingStrategy(locator, getRootContainerLocation()), processors);
    super.initialise();
    timer = muleContext.getSchedulerService().cpuLightScheduler();
    policyTemplate = new SimpleRetryPolicyTemplate(millisBetweenRetries, maxRetries);
    shouldRetry = event -> event.getError().isPresent();
    Object rootContainer = getFromAnnotatedObject(componentLocator, this).orElse(null);
    if (rootContainer instanceof FlowConstruct) {
        processingStrategy = ((FlowConstruct) rootContainer).getProcessingStrategy();
    } else {
        processingStrategy = DIRECT_PROCESSING_STRATEGY_INSTANCE;
    }
}
Also used : SimpleRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate) FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) ComponentUtils.getFromAnnotatedObject(org.mule.runtime.core.internal.component.ComponentUtils.getFromAnnotatedObject) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Example 3 with SimpleRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate in project mule by mulesoft.

the class DefaultExecutionMediatorTestCase method before.

@Before
public void before() throws Exception {
    when(configurationInstance.getStatistics()).thenReturn(configurationStats);
    when(configurationInstance.getName()).thenReturn(DUMMY_NAME);
    when(configurationInstance.getModel()).thenReturn(configurationModel);
    when(extensionModel.getName()).thenReturn(DUMMY_NAME);
    when(extensionModel.getModelProperty(ClassLoaderModelProperty.class)).thenReturn(empty());
    mockExceptionEnricher(extensionModel, null);
    mockExceptionEnricher(operationModel, null);
    when(operationExecutor.execute(operationContext)).thenReturn(just(result));
    when(operationExceptionExecutor.execute(operationContext)).thenReturn(error(exception));
    when(operationContext.getConfiguration()).thenReturn(Optional.of(configurationInstance));
    when(operationContext.getExtensionModel()).thenReturn(extensionModel);
    when(operationContext.getTransactionConfig()).thenReturn(empty());
    when(operationContext.getRetryPolicyTemplate()).thenReturn(empty());
    when(operationContext.getCurrentScheduler()).thenReturn(IMMEDIATE_SCHEDULER);
    when(extensionModel.getXmlDslModel()).thenReturn(XmlDslModel.builder().setPrefix("test-extension").build());
    mediator = new DefaultExecutionMediator(extensionModel, operationModel, new DefaultConnectionManager(muleContext), muleContext.getErrorTypeRepository());
    final ReconnectableConnectionProviderWrapper<Object> connectionProviderWrapper = new ReconnectableConnectionProviderWrapper<>(null, new ReconnectionConfig(true, new SimpleRetryPolicyTemplate(10, RETRY_COUNT)));
    initialiseIfNeeded(connectionProviderWrapper, true, muleContext);
    Optional<ConnectionProvider> connectionProvider = Optional.of(connectionProviderWrapper);
    when(configurationInstance.getConnectionProvider()).thenReturn(connectionProvider);
    when(exceptionEnricher.enrichException(exception)).thenReturn(new HeisenbergException(ERROR));
    setInterceptors((Interceptable) configurationInstance, configurationInterceptor1, configurationInterceptor2);
    setInterceptors((Interceptable) operationExecutor, operationInterceptor1, operationInterceptor2);
    defineOrder(configurationInterceptor1, configurationInterceptor2, operationInterceptor1, operationInterceptor2);
}
Also used : DefaultConnectionManager(org.mule.runtime.core.internal.connection.DefaultConnectionManager) SimpleRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate) DefaultExecutionMediator(org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) ReconnectionConfig(org.mule.runtime.core.internal.retry.ReconnectionConfig) ReconnectableConnectionProviderWrapper(org.mule.runtime.core.internal.connection.ReconnectableConnectionProviderWrapper) ConnectionProvider(org.mule.runtime.api.connection.ConnectionProvider) Before(org.junit.Before)

Aggregations

SimpleRetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate)3 Before (org.junit.Before)1 ConnectionProvider (org.mule.runtime.api.connection.ConnectionProvider)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1 AsynchronousRetryTemplate (org.mule.runtime.core.api.retry.async.AsynchronousRetryTemplate)1 ComponentUtils.getFromAnnotatedObject (org.mule.runtime.core.internal.component.ComponentUtils.getFromAnnotatedObject)1 DefaultConnectionManager (org.mule.runtime.core.internal.connection.DefaultConnectionManager)1 ReconnectableConnectionProviderWrapper (org.mule.runtime.core.internal.connection.ReconnectableConnectionProviderWrapper)1 ReconnectionConfig (org.mule.runtime.core.internal.retry.ReconnectionConfig)1 DefaultExecutionMediator (org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator)1 HeisenbergException (org.mule.test.heisenberg.extension.exception.HeisenbergException)1