-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graceful shutdown strategy used as default one
- Loading branch information
1 parent
5a06580
commit 40cea3e
Showing
9 changed files
with
200 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
= Camel Quarkus 2.6.0 Migration Guide | ||
|
||
The following guide outlines how to adapt your code to changes that were made in Camel Quarkus 2.6.0 & Quarkus 2.6.0.Final. | ||
|
||
== Graceful shutdown strategy is used by default | ||
|
||
In previous releases, graceful shutdown strategy (default strategy in Camel, see https://camel.apache.org/manual/graceful-shutdown.html[documentation] ) wasn't used by default. | ||
Shutdown wasn't controlled by any strategy. | ||
|
||
This is no longer the case. | ||
Graceful shutdown strategy is enabled by default (see https://camel.apache.org/manual/graceful-shutdown.html[documentation]) with one exception only. | ||
If timeout for graceful shutdown is not set and application runs in a development mode, no shutdown strategy is used (behavior for the development mode without timeout for graceful timeout wasn't changed). | ||
|
||
`DefaultShutdownStrategy` could be configured via `application.properties`. | ||
For example: | ||
``` | ||
#set graceful timeout to 15 seconds | ||
camel.main.shutdownTimeout = 15 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...c/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.apache.camel.quarkus.core.deployment; | ||
|
||
import javax.inject.Inject; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.impl.engine.DefaultShutdownStrategy; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CamelContextDefaultStrategyTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest(); | ||
|
||
@Inject | ||
CamelContext camelContext; | ||
|
||
@Test | ||
public void testRestConfiguration() { | ||
assertThat(camelContext.getShutdownStrategy() instanceof DefaultShutdownStrategy); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...st/java/org/apache/camel/quarkus/main/CamelContextDefaultShutdownStrategyDevModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.apache.camel.quarkus.main; | ||
|
||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.io.Writer; | ||
import java.util.Properties; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
import org.apache.camel.impl.engine.DefaultShutdownStrategy; | ||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CamelContextDefaultShutdownStrategyDevModeTest { | ||
@RegisterExtension | ||
static final QuarkusDevModeTest TEST = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(applicationProperties(), "application.properties") | ||
.addClass(CamelSupportResource.class)); | ||
|
||
public static Asset applicationProperties() { | ||
Writer writer = new StringWriter(); | ||
|
||
Properties props = new Properties(); | ||
props.setProperty("camel.main.shutdownTimeout", "15"); | ||
|
||
try { | ||
props.store(writer, ""); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
return new StringAsset(writer.toString()); | ||
} | ||
|
||
@Test | ||
public void test() throws IOException { | ||
RestAssured.when().get("/test/getShutdownStrategy").then().assertThat() | ||
.body(Matchers.is(DefaultShutdownStrategy.class.getSimpleName())); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...rc/test/java/org/apache/camel/quarkus/main/CamelContextNoShutdownStrategyDevModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.apache.camel.quarkus.main; | ||
|
||
import java.io.IOException; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
import org.apache.camel.quarkus.core.NoShutdownStrategy; | ||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CamelContextNoShutdownStrategyDevModeTest { | ||
@RegisterExtension | ||
static final QuarkusDevModeTest TEST = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(CamelSupportResource.class)); | ||
|
||
@Test | ||
public void test() throws IOException { | ||
RestAssured.when().get("/test/getShutdownStrategy").then().assertThat() | ||
.body(Matchers.is(NoShutdownStrategy.class.getSimpleName())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters