Search in sources :

Example 6 with SyncTaskExecutor

use of org.springframework.core.task.SyncTaskExecutor in project spring-integration by spring-projects.

the class ExecutorChannelTests method interceptorWithModifiedMessage.

@Test
public void interceptorWithModifiedMessage() {
    ExecutorChannel channel = new ExecutorChannel(new SyncTaskExecutor());
    channel.setBeanFactory(mock(BeanFactory.class));
    channel.afterPropertiesSet();
    MessageHandler handler = mock(MessageHandler.class);
    Message<?> expected = mock(Message.class);
    BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
    interceptor.setMessageToReturn(expected);
    channel.addInterceptor(interceptor);
    channel.subscribe(handler);
    channel.send(new GenericMessage<Object>("foo"));
    verify(handler).handleMessage(expected);
    assertEquals(1, interceptor.getCounter().get());
    assertTrue(interceptor.wasAfterHandledInvoked());
}
Also used : SyncTaskExecutor(org.springframework.core.task.SyncTaskExecutor) MessageHandler(org.springframework.messaging.MessageHandler) BeanFactory(org.springframework.beans.factory.BeanFactory) Test(org.junit.Test)

Example 7 with SyncTaskExecutor

use of org.springframework.core.task.SyncTaskExecutor in project iaf by ibissource.

the class OpenApiTestBase method getTaskExecutor.

/**
 * TaskExecutor used to start and configure adapters
 */
private static TaskExecutor getTaskExecutor() {
    if (taskExecutor == null) {
        // Make sure all threads are joining the calling thread
        SyncTaskExecutor executor = new SyncTaskExecutor();
        taskExecutor = executor;
    }
    return taskExecutor;
}
Also used : SyncTaskExecutor(org.springframework.core.task.SyncTaskExecutor)

Example 8 with SyncTaskExecutor

use of org.springframework.core.task.SyncTaskExecutor in project cloudbreak by hortonworks.

the class AbstractActionTest method setup.

@Before
public void setup() throws Exception {
    underTest = spy(new TestAction());
    underTest.setFailureEvent(Event.FAILURE);
    MockitoAnnotations.initMocks(this);
    BDDMockito.given(flow.getFlowId()).willReturn(FLOW_ID);
    BDDMockito.given(runningFlows.get(anyString())).willReturn(flow);
    StateMachineConfigurationBuilder<State, Event> configurationBuilder = new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    configurationBuilder.setTaskExecutor(new SyncTaskExecutor());
    StateMachineStateBuilder<State, Event> stateBuilder = new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    stateBuilder.withStates().initial(State.INIT).state(State.DOING, underTest, null);
    StateMachineTransitionBuilder<State, Event> transitionBuilder = new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    transitionBuilder.withExternal().source(State.INIT).target(State.DOING).event(Event.DOIT);
    stateMachine = new ObjectStateMachineFactory<>(configurationBuilder.build(), transitionBuilder.build(), stateBuilder.build()).getStateMachine();
    stateMachine.start();
}
Also used : SyncTaskExecutor(org.springframework.core.task.SyncTaskExecutor) StateMachineConfigurationBuilder(org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder) StateMachineTransitionBuilder(org.springframework.statemachine.config.builders.StateMachineTransitionBuilder) StateMachineStateBuilder(org.springframework.statemachine.config.builders.StateMachineStateBuilder) ObjectStateMachineFactory(org.springframework.statemachine.config.ObjectStateMachineFactory) Before(org.junit.Before)

Example 9 with SyncTaskExecutor

use of org.springframework.core.task.SyncTaskExecutor in project spring-framework by spring-projects.

the class WebAsyncManager method logExecutorWarning.

private void logExecutorWarning() {
    if (taskExecutorWarning && logger.isWarnEnabled()) {
        synchronized (DEFAULT_TASK_EXECUTOR) {
            AsyncTaskExecutor executor = this.taskExecutor;
            if (taskExecutorWarning && (executor instanceof SimpleAsyncTaskExecutor || executor instanceof SyncTaskExecutor)) {
                String executorTypeName = executor.getClass().getSimpleName();
                logger.warn("\n!!!\n" + "An Executor is required to handle java.util.concurrent.Callable return values.\n" + "Please, configure a TaskExecutor in the MVC config under \"async support\".\n" + "The " + executorTypeName + " currently in use is not suitable under load.\n" + "-------------------------------\n" + "Request URI: '" + formatRequestUri() + "'\n" + "!!!");
                taskExecutorWarning = false;
            }
        }
    }
}
Also used : SyncTaskExecutor(org.springframework.core.task.SyncTaskExecutor) SimpleAsyncTaskExecutor(org.springframework.core.task.SimpleAsyncTaskExecutor) AsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor) SimpleAsyncTaskExecutor(org.springframework.core.task.SimpleAsyncTaskExecutor)

Aggregations

SyncTaskExecutor (org.springframework.core.task.SyncTaskExecutor)9 Test (org.junit.Test)3 BeanFactory (org.springframework.beans.factory.BeanFactory)2 MessageHandler (org.springframework.messaging.MessageHandler)2 StateMachineConfigurationBuilder (org.springframework.statemachine.config.builders.StateMachineConfigurationBuilder)2 StateMachineStateBuilder (org.springframework.statemachine.config.builders.StateMachineStateBuilder)2 StateMachineTransitionBuilder (org.springframework.statemachine.config.builders.StateMachineTransitionBuilder)2 FlowState (com.sequenceiq.cloudbreak.core.flow2.FlowState)1 URI (java.net.URI)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)1 AsyncTaskExecutor (org.springframework.core.task.AsyncTaskExecutor)1 SimpleAsyncTaskExecutor (org.springframework.core.task.SimpleAsyncTaskExecutor)1 ExecutorServiceAdapter (org.springframework.core.task.support.ExecutorServiceAdapter)1 HttpHeaders (org.springframework.http.HttpHeaders)1