[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
GitHub user josehenriqueventura opened a pull request:

    https://github.com/apache/tomee/pull/240

    TOMEE-2291 - Fault Tolerance Microprofile example for @Retry

    I have finished the implementation of mp-faulttolerance-retry

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/josehenriqueventura/tomee mp-faulttolerance-retry

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tomee/pull/240.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #240
   
----
commit 9bb8a1aef0f81e15502be707aa620addfcad1ab7
Author: josehenriqueventura <j2705hvq*>
Date:   2018-12-03T20:13:20Z

    [TOMEE-2291] - Fault Tolerance Microprofile example for @Retry
   
    Created Rest Resource WeatherService which publish /weather
    Created WeatherGatewayTimeoutException and WeatherGatewayBusyServiceException which extends FaultToleranceException to handle the exceptions thrown by the business logic from WeatherGateway.
    Created WeatherGateway which makes the use of @Retry annotation
    Created WeatherServiceTest
    Created README.md to describe the example (incomplete)

commit bde89d72ea282652034d4b602b6bce6eadd366fb
Author: josehenriqueventura <j2705hvq*>
Date:   2018-12-03T20:17:12Z

    [TOMEE-2291] - Fault Tolerance Microprofile example for @Retry
   
    Added missed test for statusOfMonth
    Changed the return message of statusOfMonth from weekend to month

commit b45ecda462ea1fbc57c553d4e54ebcb58521cd90
Author: Jose Henrique Ventura <javawebhenrique@...>
Date:   2018-12-03T21:23:36Z

    Update README.md
   
    Removed a few things from the README.md to make the text clear.

commit 728c612429ead3711d5a3608e73ba655213cec23
Author: Jose Henrique Ventura <javawebhenrique@...>
Date:   2018-12-03T21:41:26Z

    Update README.md

commit 1396ab4409f82f4fdfcf0846bac792434c8f10fb
Author: josehenriqueventura <j2705hvq*>
Date:   2018-12-05T15:33:30Z

    [TOMEE-2291] - Fault Tolerance Microprofile example for @Retry
   
    Minimal change for statusOfYear method which had retryOn, maxRetry and delay parameter removed to retry the same operation for a RuntimeException.
    and slight change in README.md file.

commit 20496f9feb10da74c06ef401c2c74404b1a22b5e
Author: Jose Henrique Ventura <javawebhenrique@...>
Date:   2018-12-05T15:44:52Z

    Update README.md
   
    Added detail of how to run the test and the path of WeatherServiceTest.java

----


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
Github user brunobat commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239174458
 
    --- Diff: examples/mp-faulttolerance-retry/pom.xml ---
    @@ -0,0 +1,69 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<project xmlns="http://maven.apache.org/POM/4.0.0"
    +         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    +         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <parent>
    +        <artifactId>examples</artifactId>
    --- End diff --
   
    Hi José,
    You need to add this to the modules of the parent. It's missing there. See after this line: https://github.com/apache/tomee/blob/master/examples/pom.xml#L176 


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user brunobat commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239194657
 
    --- Diff: examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGatewayBusyServiceException.java ---
    @@ -0,0 +1,22 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.superbiz.rest;
    +
    +import org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceException;
    +
    +public class WeatherGatewayBusyServiceException extends FaultToleranceException {
    --- End diff --
   
    Upon further thinking about this... The FaultToleranceException is used inside the Fault Tolerance logic.
    I never actually thought someone would extend it as you did and I don't know if it's supposed to work like that.
    I've created an issue in the spec. You can follow it here: https://github.com/eclipse/microprofile-fault-tolerance/issues/367
    In the meantime, I think you should not use FaultToleranceException because it might be a bad recommendation to whoever is going to use it. One easy solution would be to use a checked and an unchecked exception.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user brunobat commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239190370
 
    --- Diff: examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java ---
    @@ -0,0 +1,115 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.superbiz.rest;
    +
    +import java.time.Duration;
    +import java.time.Instant;
    +import java.util.concurrent.atomic.AtomicInteger;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +import javax.enterprise.context.RequestScoped;
    +import org.eclipse.microprofile.faulttolerance.Retry;
    +
    +
    +@RequestScoped
    +public class WeatherGateway {
    +
    +    private static Logger LOGGER = Logger.getLogger(WeatherGateway.class.getName());
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_ATTEMPTS =
    +            "Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (%d), Attempts: (%d)";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE =
    +            "Timeout when accessing AccuWeather Forecast Service.";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_DELAY =
    +            "Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (%d)";
    +
    +    private static final String FORECAST_BUSY_MESSAGE =
    +            "Error AccuWeather Forecast Service is busy. Number of Attempts: (%d) \n";
    +
    +    /**
    +     * {@link Retry#maxRetries()}
    +     */
    +    private static final int DEFAULT_MAX_RETRY = 3;
    +
    +    private AtomicInteger counterStatusOfDay = new AtomicInteger();
    --- End diff --
   
    These AtomicInteger can be set to final


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user josehenriqueventura commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239221635
 
    --- Diff: examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java ---
    @@ -0,0 +1,115 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.superbiz.rest;
    +
    +import java.time.Duration;
    +import java.time.Instant;
    +import java.util.concurrent.atomic.AtomicInteger;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +import javax.enterprise.context.RequestScoped;
    +import org.eclipse.microprofile.faulttolerance.Retry;
    +
    +
    +@RequestScoped
    +public class WeatherGateway {
    +
    +    private static Logger LOGGER = Logger.getLogger(WeatherGateway.class.getName());
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_ATTEMPTS =
    +            "Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (%d), Attempts: (%d)";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE =
    +            "Timeout when accessing AccuWeather Forecast Service.";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_DELAY =
    +            "Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (%d)";
    +
    +    private static final String FORECAST_BUSY_MESSAGE =
    +            "Error AccuWeather Forecast Service is busy. Number of Attempts: (%d) \n";
    +
    +    /**
    +     * {@link Retry#maxRetries()}
    +     */
    +    private static final int DEFAULT_MAX_RETRY = 3;
    +
    +    private AtomicInteger counterStatusOfDay = new AtomicInteger();
    --- End diff --
   
    Yes, sure.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user josehenriqueventura commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239229848
 
    --- Diff: examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGatewayBusyServiceException.java ---
    @@ -0,0 +1,22 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.superbiz.rest;
    +
    +import org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceException;
    +
    +public class WeatherGatewayBusyServiceException extends FaultToleranceException {
    --- End diff --
   
    Definitely looks not a good look at this now. Good catch, thanks.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user josehenriqueventura commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239230074
 
    --- Diff: examples/mp-faulttolerance-retry/pom.xml ---
    @@ -0,0 +1,69 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<project xmlns="http://maven.apache.org/POM/4.0.0"
    +         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    +         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <parent>
    +        <artifactId>examples</artifactId>
    --- End diff --
   
    Yes, sure.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee issue #240: TOMEE-2291 - Fault Tolerance Microprofile example for @Ret...

otaviojava
In reply to this post by otaviojava
Github user brunobat commented on the issue:

    https://github.com/apache/tomee/pull/240
 
    Hi @josehenriqueventura you have a conflict. Please rebase your branch with the latest master.


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user brunobat commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239263289
 
    --- Diff: examples/mp-faulttolerance-retry/pom.xml ---
    @@ -0,0 +1,69 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<project xmlns="http://maven.apache.org/POM/4.0.0"
    +         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    +         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <parent>
    +        <artifactId>examples</artifactId>
    --- End diff --
   
    +1


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user brunobat commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/240#discussion_r239263340
 
    --- Diff: examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java ---
    @@ -0,0 +1,115 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.superbiz.rest;
    +
    +import java.time.Duration;
    +import java.time.Instant;
    +import java.util.concurrent.atomic.AtomicInteger;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +import javax.enterprise.context.RequestScoped;
    +import org.eclipse.microprofile.faulttolerance.Retry;
    +
    +
    +@RequestScoped
    +public class WeatherGateway {
    +
    +    private static Logger LOGGER = Logger.getLogger(WeatherGateway.class.getName());
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_ATTEMPTS =
    +            "Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (%d), Attempts: (%d)";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE =
    +            "Timeout when accessing AccuWeather Forecast Service.";
    +
    +    private static final String FORECAST_TIMEOUT_MESSAGE_DELAY =
    +            "Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (%d)";
    +
    +    private static final String FORECAST_BUSY_MESSAGE =
    +            "Error AccuWeather Forecast Service is busy. Number of Attempts: (%d) \n";
    +
    +    /**
    +     * {@link Retry#maxRetries()}
    +     */
    +    private static final int DEFAULT_MAX_RETRY = 3;
    +
    +    private AtomicInteger counterStatusOfDay = new AtomicInteger();
    --- End diff --
   
    +1


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee issue #240: TOMEE-2291 - Fault Tolerance Microprofile example for @Ret...

otaviojava
In reply to this post by otaviojava
Github user josehenriqueventura commented on the issue:

    https://github.com/apache/tomee/pull/240
 
    @brunobat Hi Bruno, could you confirm if it looks good now, please?


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee issue #240: TOMEE-2291 - Fault Tolerance Microprofile example for @Ret...

otaviojava
In reply to this post by otaviojava
Github user jeanouii commented on the issue:

    https://github.com/apache/tomee/pull/240
 
    It still has a conflict @josehenriqueventura


---
Reply | Threaded
Open this post in threaded view
|

[GitHub] tomee pull request #240: TOMEE-2291 - Fault Tolerance Microprofile example f...

otaviojava
In reply to this post by otaviojava
Github user asfgit closed the pull request at:

    https://github.com/apache/tomee/pull/240


---