How to use RestTemplate efficiently in Multithreaded environment?

后端 未结 3 1330
耶瑟儿~
耶瑟儿~ 2020-12-08 02:42

I am working on a project in which I need to make a HTTP URL call to my server which is running Restful Service which returns back the response as a JSON String

3条回答
  •  -上瘾入骨i
    2020-12-08 03:48

    I have my multi-thread-safe singleton REST template wired like this in spring:

    
        
    
    
        
    
    
        
        
    
    
        
        
    
    
        
    
    
        
        
        
            
                
            
        
    
    

    Please note I'm using an OAuthRestTemplate, and myResource refers to the oauth resource stuff which I've omitted as it's not relevant. Instead of an OAuthRestTemplate you could just as easily use a org.springframework.web.client.RestTemplate http://docs.spring.io/spring/docs/3.2.4.RELEASE/javadoc-api/org/springframework/web/client/RestTemplate.html

提交回复
热议问题