camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/3] camel git commit: Add Camel commands on the CDI Camel context and overall polish
Date Mon, 08 Feb 2016 16:46:40 GMT
Add Camel commands on the CDI Camel context and overall polish


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/06ee8182
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/06ee8182
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/06ee8182

Branch: refs/heads/master
Commit: 06ee8182dbfd3624deec4cc0dc1652321abec35f
Parents: 6a5a06c
Author: Antonin Stefanutti <antonin@stefanutti.fr>
Authored: Mon Feb 8 12:58:57 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Feb 8 17:46:11 2016 +0100

----------------------------------------------------------------------
 examples/camel-example-cdi-osgi/README.md | 153 +++++++++++++++++++------
 1 file changed, 116 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/06ee8182/examples/camel-example-cdi-osgi/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi-osgi/README.md b/examples/camel-example-cdi-osgi/README.md
index c68d26e..b5fe812 100644
--- a/examples/camel-example-cdi-osgi/README.md
+++ b/examples/camel-example-cdi-osgi/README.md
@@ -20,7 +20,9 @@ The `camel-core` and `camel-sjms` components are used in this example.
 
 You will need to build this example first:
 
-    $ mvn install
+```sh
+$ mvn install
+```
 
 ### Run
 
@@ -28,9 +30,12 @@ You will need to build this example first:
 
 You can run this example using:
 
-    $ mvn camel:run
+```sh
+$ mvn camel:run
+```
 
 When the Camel application starts, you should see the following message being logged to the
console, e.g.:
+
 ```
 2016-02-01 20:13:46,922 [cdi.Main.main()] INFO  DefaultCamelContext - Apache Camel 2.17-SNAPSHOT
(CamelContext: osgi-example) started in 0.769 seconds
 2016-02-01 20:13:47,008 [ Session Task-1] INFO  consumer-route      - Received message [Sample
Message] from [Producer]
@@ -50,66 +55,140 @@ This example can be executed within Karaf 2.x, 3.x and 4.x. From the
command lin
 
 2. For Karaf 2.x, install the following pre-requisites:
 
-    ```
-    features:addUrl mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
-    features:addUrl mvn:org.apache.activemq/activemq-karaf/5.12.1/xml/features
-    features:install activemq-broker-noweb
-    features:install pax-cdi-weld
-    features:install camel-cdi
-    features:install camel-sjms
+    ```sh
+    karaf@root()> features:addUrl mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
+    karaf@root()> features:addUrl mvn:org.apache.activemq/activemq-karaf/5.12.1/xml/features
+    karaf@root()> features:install activemq-broker-noweb pax-cdi-weld camel-sjms camel-cdi
     ```
 
 3. Then install and start the example:
 
-    ```
-    osgi:install -s mvn:org.apache.camel/camel-example-cdi-osgi/${version}
+    ```sh
+    karaf@root()> osgi:install -s mvn:org.apache.camel/camel-example-cdi-osgi/${version}
     ```
 
 Alternatively, with the new commands introduced since Karaf 3.x:
 
 2. Install the pre-requisites:
 
-    ```
-    feature:repo-add mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
-    feature:repo-add mvn:org.apache.activemq/activemq-karaf/5.12.1/xml/features
-    feature:install activemq-broker-noweb
-    feature:install pax-cdi-weld
-    feature:install camel-cdi
-    feature:install camel-sjms
+    ```sh
+    karaf@root()> feature:repo-add mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
+    karaf@root()> feature:repo-add mvn:org.apache.activemq/activemq-karaf/5.12.1/xml/features
+    karaf@root()> feature:install activemq-broker-noweb pax-cdi-weld camel-sjms camel-cdi
     ```
 
 3. Then install and start the example:
 
+    ```sh
+    karaf@root()> bundle:install -s mvn:org.apache.camel/camel-example-cdi-osgi/${version}
     ```
-    bundle:install -s mvn:org.apache.camel/camel-example-cdi-osgi/${version}
+
+By tailing the log with:
+
+```sh
+karaf@root()> log:tail
+```
+
+The following messages should be displayed:
+
+```
+2016-02-08 12:32:14,395 | INFO  | nsole user karaf | CdiCamelExtension                | 149
- org.apache.camel.camel-cdi - 2.17.0.SNAPSHOT | Camel CDI is starting Camel context [osgi-example]
+2016-02-08 12:32:14,395 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) is starting
+2016-02-08 12:32:14,395 | INFO  | nsole user karaf | ManagedManagementStrategy        | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | JMX is enabled
+2016-02-08 12:32:14,698 | INFO  | nsole user karaf | DefaultTypeConverter             | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Loaded 182 type converters
+2016-02-08 12:32:14,706 | INFO  | nsole user karaf | DefaultRuntimeEndpointRegistry   | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Runtime endpoint registry is in extended
mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
+2016-02-08 12:32:14,730 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Using Persistence Adapter: MemoryPersistenceAdapter
+2016-02-08 12:32:14,731 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp-2.local-52027-1454930701800-0:3)
is starting
+2016-02-08 12:32:14,731 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp-2.local-52027-1454930701800-0:3)
started
+2016-02-08 12:32:14,731 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | For help or more information please see: http://activemq.apache.org
+2016-02-08 12:32:14,731 | WARN  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Memory Usage for the Broker (1024 mb) is more
than the maximum available for the JVM: 455 mb - resetting to 70% of maximum available: 318
mb
+2016-02-08 12:32:14,732 | INFO  | nsole user karaf | TransportConnector               | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Connector vm://broker started
+2016-02-08 12:32:14,755 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | AllowUseOriginalMessage is enabled. If access
to the original message is not needed, then its recommended to turn this option off as it
may improve performance.
+2016-02-08 12:32:14,755 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | StreamCaching is not in use. If using streams
then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
+2016-02-08 12:32:14,762 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Route: consumer-route started and consuming
from: Endpoint[sjms://sample.queue]
+2016-02-08 12:32:14,763 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Total 1 routes, of which 1 is started.
+2016-02-08 12:32:14,763 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) started in 0.368 seconds
+2016-02-08 12:32:14,774 | INFO  | Q Session Task-1 | consumer-route                   | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Received message [Sample Message] from [Producer]
+```
+
+Hit <kbd>ctrl</kbd>+<kbd>c</kbd> to exit the log command.
+
+Camel commands can be used to gain some insights on the CDI Camel
+context, e.g.:
+
+- The `camel:context-list` displays the CDI Camel context:
+
+    ```
+    karaf@root()> camel:context-list
+     Context        Status              Total #       Failed #     Inflight #   Uptime  
     
+     -------        ------              -------       --------     ----------   ------  
     
+     osgi-example   Started                   1              0              0   1 minute
 
     ```
 
-The following messages should be logged:
+- The `camel:route-list` command displays the Camel route configured
+  by the `RouteBuilder` bean:
+
+    ```
+    karaf@root()> camel:route-list
+     Context        Route            Status              Total #       Failed #     Inflight
#   Uptime        
+     -------        -----            ------              -------       --------     ----------
  ------        
+     osgi-example   consumer-route   Started                   1              0         
    0   3 minutes
+     ```
 
+- And the `camel:route-info` command displays the exchange completed
+  when the `CamelContextStartedEvent` CDI event is fired:
+
+    ```
+    karaf@root()> camel:route-info consumer-route
+    Camel Route consumer-route
+       Camel Context: osgi-example
+       State: Started
+       State: Started
+
+    Statistics
+       Exchanges Total: 1
+       Exchanges Completed: 1
+       Exchanges Failed: 0
+       Exchanges Inflight: 0
+       Min Processing Time: 1 ms
+       Max Processing Time: 1 ms
+       Mean Processing Time: 1 ms
+       Total Processing Time: 1 ms
+       Last Processing Time: 1 ms
+       Delta Processing Time: 1 ms
+       Start Statistics Date: 2016-02-08 12:32:14
+       Reset Statistics Date: 2016-02-08 12:32:14
+       First Exchange Date: 2016-02-08 12:32:14
+       Last Exchange Date: 2016-02-08 12:32:14
+    ```
+
+Finally, you can stop the example with:
+
+```sh
+karaf@root()> bundle:uninstall camel-example-cdi-osgi
 ```
-2016-02-01 20:28:43,446 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) is starting
-2016-02-01 20:28:43,447 | INFO  | nsole user karaf | ManagedManagementStrategy        | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | JMX is enabled
-2016-02-01 20:28:43,565 | INFO  | nsole user karaf | DefaultTypeConverter             | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Loaded 182 type converters
-2016-02-01 20:28:43,585 | INFO  | nsole user karaf | DefaultRuntimeEndpointRegistry   | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Runtime endpoint registry is in extended
mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
-2016-02-01 20:28:43,675 | INFO  | nsole user karaf | BrokerService                    | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | Using Persistence Adapter: MemoryPersistenceAdapter
-2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp.local-50823-1454354911797-0:2)
is starting
-2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp.local-50823-1454354911797-0:2)
started
-2016-02-01 20:28:43,679 | INFO  | nsole user karaf | BrokerService                    | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | For help or more information please see: http://activemq.apache.org
-2016-02-01 20:28:43,679 | WARN  | nsole user karaf | BrokerService                    | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | Memory Usage for the Broker (1024 mb) is more
than the maximum available for the JVM: 455 mb - resetting to 70% of maximum available: 318
mb
-2016-02-01 20:28:43,681 | INFO  | nsole user karaf | TransportConnector               | 187
- org.apache.activemq.activemq-osgi - 5.12.1 | Connector vm://broker started
-2016-02-01 20:28:43,784 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | AllowUseOriginalMessage is enabled. If access
to the original message is not needed, then its recommended to turn this option off as it
may improve performance.
-2016-02-01 20:28:43,784 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | StreamCaching is not in use. If using streams
then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
-2016-02-01 20:28:43,845 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Route: consumer-route started and consuming
from: Endpoint[sjms://sample.queue]
-2016-02-01 20:28:43,845 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Total 1 routes, of which 1 is started.
-2016-02-01 20:28:43,846 | INFO  | nsole user karaf | DefaultCamelContext              | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) started in 0.400 seconds
-2016-02-01 20:28:43,899 | INFO  | Q Session Task-1 | consumer-route                   | 58
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Received message [Sample Message] from [Producer]
 
+And check in the log that the Camel context has been gracefully
+shutdown:
+
+```
+2016-02-08 12:39:34,295 | INFO  | nsole user karaf | CamelContextProducer             | 149
- org.apache.camel.camel-cdi - 2.17.0.SNAPSHOT | Camel CDI is stopping Camel context [osgi-example]
+2016-02-08 12:39:34,295 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) is shutting down
+2016-02-08 12:39:34,297 | INFO  | nsole user karaf | DefaultShutdownStrategy          | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Starting to graceful shutdown 1 routes (timeout
300 seconds)
+2016-02-08 12:39:34,299 | INFO  | 1 - ShutdownTask | DefaultShutdownStrategy          | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Route: consumer-route shutdown complete,
was consuming from: Endpoint[sjms://sample.queue]
+2016-02-08 12:39:34,300 | INFO  | nsole user karaf | DefaultShutdownStrategy          | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Graceful shutdown of 1 routes completed
in 0 seconds
+2016-02-08 12:39:34,310 | INFO  | nsole user karaf | TransportConnector               | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Connector vm://broker stopped
+2016-02-08 12:39:34,310 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp-2.local-52027-1454930701800-0:3)
is shutting down
+2016-02-08 12:39:34,311 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp-2.local-52027-1454930701800-0:3)
uptime 7 minutes
+2016-02-08 12:39:34,311 | INFO  | nsole user karaf | BrokerService                    | 61
- org.apache.activemq.activemq-osgi - 5.12.1 | Apache ActiveMQ 5.12.1 (broker, ID:mbp-2.local-52027-1454930701800-0:3)
is shutdown
+2016-02-08 12:39:34,313 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) uptime 7 minutes
+2016-02-08 12:39:34,313 | INFO  | nsole user karaf | DefaultCamelContext              | 151
- org.apache.camel.camel-core - 2.17.0.SNAPSHOT | Apache Camel 2.17-SNAPSHOT (CamelContext:
osgi-example) is shutdown in 0.018 seconds
 ```
 
 ### Forum, Help, etc
 
 If you hit an problems please let us know on the Camel Forums
-	<http://camel.apache.org/discussion-forums.html>
+    <http://camel.apache.org/discussion-forums.html>
 
 Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
 


Mime
View raw message