0

I was trying to implement a asynchronous method on my service using @Async and returning ListenableFuture and the controller method returning a @ResponseBody Callable, I have a thread pool as bean configured to Async Support for Spring . It is running like a charm on Tomcat 8.0.15, on Wildfly, the service method is executed on controller method but the controller never returns on the web page the container just returns "Service Unavailable" . I tried to remove "ee" module at Jboss structure deployment descriptor but then the WAR wasn't deployed. Anyone have some tips to make this work?

EDIT

Log don't output nothing wrong.

The controller:

@RequestMapping(value = {"search/{query}"}, method = RequestMethod.GET)
    public Callable<GithubResult> printResult(@PathVariable String query) {
        Assert.notNull(query, "Query must be not null");
        ListenableFuture<ResponseEntity<GithubResult>> result = githubLookupService.lookup(query);
        return () -> result.get().getBody();
    }

The Service:

    @Async
    @Override
    public ListenableFuture<ResponseEntity<GithubResult>> lookup(String query) {
        Assert.notNull(query,"Query must be not null");
        String url = String.format("https://api.github.com/search/repositories?q=%s+language:java", query);
        ListenableFuture<ResponseEntity<GithubResult>> reponseFuture = asyncTemplate
                .getForEntity(url, GithubResult.class);
        try {
            return new AsyncResult<>(reponseFuture.get());
        } catch (InterruptedException | ExecutionException  e) {
            log.error("Cannot retrieve the response entitiy");
            return reponseFuture;
        }
    }

And the Spring configuration:

<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<task:scheduler id="scheduler" pool-size="10"/>
<task:annotation-driven executor="taskExecutor" scheduler="scheduler" proxy-target-class="true"/>

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="50"/>
    <property name="maxPoolSize" value="50"/>
    <property name="queueCapacity" value="20"/>
    <property name="waitForTasksToCompleteOnShutdown" value="true"/>
</bean>

<bean id="schedulerFacotryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="true"/>
    <property name="taskExecutor" ref="taskExecutor"/>
</bean>
Joao Evangelista
  • 2,407
  • 2
  • 26
  • 37

0 Answers0