Grails执行程序 - 不能异步使用OauthService

时间:2012-01-12 23:02:51

标签: grails oauth executorservice

我安装了grails executor插件,因此我可以运行一些需要一段时间才能执行的后台任务。该任务要求我使用OauthService调用LinkedIn API。问题是我似乎无法在异步块中调用OauthService.accessResource,而完全相同的代码执行正常。这是代码,简化为说明问题:

import org.grails.plugins.oauth.OauthService

class DemoController {
    OauthService oauthService

    def demo() {
     runAsync {
      println "ASYNC BEGIN"
      def baseURL = "http://api.linkedin.com/v1/people-search?keywords=blah"
      def async_response = oauthService.accessResource( baseURL, 'linkedin', [key:session.oauthToken.key, secret:session.oauthToken.secret], 'GET')
      println "ASYNC END"
     }
      println "SYNC BEGIN"
      def baseURL = "http://api.linkedin.com/v1/people-search?keywords=blah"
      def sync_response = oauthService.accessResource( baseURL, 'linkedin', [key:session.oauthToken.key, secret:session.oauthToken.secret], 'GET')
      println "SYNC END"
    }
}

这是输出:

SYNC BEGIN
2012-01-12 14:55:07,163 ["http-bio-8080"-exec-10] DEBUG oauth.OauthService  - Attempting to access protected resource
2012-01-12 14:55:07,163 ["http-bio-8080"-exec-10] DEBUG oauth.OauthService  - Executing GET to http://api.linkedin.com/v1/people-search?keywords=blah
ASYNC BEGIN
2012-01-12 14:55:07,780 ["http-bio-8080"-exec-10] DEBUG oauth.OauthService  - Reading response body
2012-01-12 14:55:07,781 ["http-bio-8080"-exec-10] DEBUG oauth.OauthService  - Response body read successfully
SYNC END

异步进程似乎停止在oauthService.accessResource上,之后没有任何内容被执行。我没有其他输出......

有什么想法吗?

感谢您的帮助。

(顺便说一句,我正在使用grails 2.0,groovy 1.8.5)

0 个答案:

没有答案