在改造1.6.1

时间:2016-09-20 09:08:43

标签: java rest java-ee retrofit retrofit2

我使用改装1.6.1作为restclient包装到我的休息api。

如果我向网络服务发送请求,并且如果网络服务提供200以外的其他响应,我的代码会在1秒的时间内自动重试7次。

以下是代码段。

    public interface Client 
    {
        @POST("/message/messageId")
        Response postMessages(@Path("messageId") String messageId, @Body SomeObject object);
    }

    **Initialization of retrofit using rest adapter is as follows**

    private void Config() {
        final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();
        restAdapter = new RestAdapter.Builder()
            .setEndpoint("http://someurl.com")
            .setConverter(new GsonConverter(gson))
            .build();
    }

    public <T> T getService(final Class<T> iFace) {
        return restAdapter.create(iFace);
    }

我将在我的业务逻辑类中调用postMessages API,我只是检查响应200 OK,没有别的,并在那里结束我的逻辑。

如果我得到除了200 OK之外的任何其他响应,则每1秒发生一次对Web服务URL的重试。这是为什么?

0 个答案:

没有答案