hi Sergey, 

I am trying to implement the failover to our rest services which take the
header content-type Multipart/formdata. 

I have noticed that when I call Invoke in ClientProxyImpl.java , the headers
are set from the OperationResourceInfo . After I implement the failover
retry strategy then when the method retryInvoke  is called then the previous
headers which has Content-type and Accept is now changed to have just Accept
and omitting the Content-Type and  hence throwing a null pointer at
org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.doWriteBody(ClientProxyImpl.java:801).
 

CODE SNIPPET. 

 InputStream excelInputStream  =
TestUploadFileService.class.getResourceAsStream(TEST_FILE); 
//            File spreadsheetURI = new File(url.toURI()); 
//            excelInputStream = new FileInputStream(spreadsheetURI); 

            final ContentDisposition cd = new
ContentDisposition("attachment;filename=spreadsheet.xls"); 
            final Attachment att = new Attachment("file", excelInputStream,
cd); 
            final Attachment spreadsheetType = new
Attachment("spreadsheetType", "text/plain", "SpreadJS"); 
            final List<Attachment> attachments = new
ArrayList<Attachment>(); 
            attachments.add(att); 
            attachments.add(spreadsheetType); 
            final MultipartBody multipartBody = new
MultipartBody(attachments); 
            FailoverFeature feature = new FailoverFeature(); 
            List<String> alternateAddresses = new ArrayList<String>(); 
           
alternateAddresses.add("http://localhost:8084/SpreadsheetTransformationService";);
 
           
alternateAddresses.add("http://icdwdpvueweb-5:8080/SpreadsheetTransformationService";);
 


            RetryStrategy strategy = new RetryStrategy(); 
            strategy.setMaxNumberOfRetries(4); 
            strategy.setAlternateAddresses(alternateAddresses); 
            strategy.setDelayBetweenRetries(5000); 
            feature.setStrategy(strategy); 
            List<Feature> features = new ArrayList<Feature>(); 
            features.add(feature); 
            List<String> prov = new ArrayList<String>(); 
            String spreadsheetTransformServiceUrl =
"http://localhost:8085/SpreadsheetTransformationService";; 

            JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); 
            bean.setAddress(spreadsheetTransformServiceUrl); 
            bean.setFeatures(features); 
            bean.setResourceClass(SpreadSheetTransformService.class); 
            WebClient  client1 = bean.createWebClient(); 
           
client1.back(true).path("http://localhost:8084/SpreadsheetTransformationService/import";);
 
            final SpreadSheetTransformService service1 =
bean.create(SpreadSheetTransformService.class); 
            final Response response =
service1.transformToJSON(multipartBody); 
            final InputStream jsonResponse = (InputStream)
response.getEntity(); 

setRequestHeaders is the method being called in invoke to set the content
type.   

Idea regarding the retry is right but i think there is bug in forwarding the
headers from the first call to the retry alternate address on failure. 

Appreciate your help. 

Thanks, 
Sree 



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Retry-Mechanism-tp5116890p5762229.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to