Skip to content

Commit

Permalink
Implement missing camel fns (#38)
Browse files Browse the repository at this point in the history
* Add missing to-d dynamic route handler

* Add missing remove-headers handler

* Add fixed spelling for unmarshal, and deprecate misspelling

* Add missing end-choice handler

* Add changelog note, bump revision, add note about logging config
  • Loading branch information
kevinmershon authored Oct 10, 2021
1 parent 5de8ed5 commit d0484af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ All notable changes to this project will be documented in this file. This change

[1.0.0]: https://github.com/TakeoffTech/clj-camel
[2.0.0]: Migrated apache camel version from 3.8 to 3.11
[2.0.1]: Added missing handlers
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ Specified pub-sub message attributes will be added to exchange header if exist
(c/set-pubsub-attributes-propagation context {"pubsub-attribute-name" "name-of-header-field"})
```

## Logging Configuration
When configuring your logging appenders, contrary to the Camel documentation, you will need to add `clj-camel.core` as your logging namespace.

## Apache Camel 3.8 -> 3.11 Migration Notes
* authentication mechanism in google-pubsub-component was changed. `serviceAccountKey` become mandatory parameter in google pubsub endpoint string: https://camel.apache.org/components/3.11.x/google-pubsub-component.html#_authentication_configuration
* changed interface of `Exchange` class: `getAllProperties` should be used instead of `getProperties` method
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(def camel-version "3.11.0")

(defproject takeoff/clj-camel "2.0.0"
(defproject takeoff/clj-camel "2.0.1"
:description "Clojure wrapper for Apache Camel"
:url "https://github.com/TakeoffTech/clj-camel"
:license {:name "Apache License Version 2.0"
Expand Down
23 changes: 22 additions & 1 deletion src/main/clj/clj_camel/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
(.id (.to rd uri) id)
(.to rd uri)))

(defn to-d
"Sends the exchange to the given dynamic endpoint"
[^RouteDefinition rd & [^String uri]]
(.toD rd uri))

(defn get-endpoint-uri
"Get endpoint URI"
[^Exchange ex]
Expand Down Expand Up @@ -85,6 +90,11 @@
(defn set-in-headers-from-wrapper [^Exchange ex wrapped-headers]
(-> ex .getIn (.setHeaders (.m wrapped-headers))))

(defn remove-headers
"Remove headers that match the specified pattern"
[^RouteDefinition rd & [^String pattern]]
(.removeHeaders rd pattern))

(defn convert-body-to
"Converts the IN message body to the specified type"
[^RouteDefinition rd & [^Class clazz]]
Expand Down Expand Up @@ -551,11 +561,17 @@
`(-> (.otherwise ~cd)
~@body))

(defn unmarshall
(defn unmarshal
"Unmarshals the in body using the specified DataFormat"
[^ProcessorDefinition pd & [^DataFormatDefinition data-format-definition]]
(.unmarshal pd data-format-definition))

(defn ^:deprecated unmarshall
"Deprecated misspelling, keep for backward compatibility for existing
implementations."
[^ProcessorDefinition pd & [^DataFormatDefinition data-format-definition]]
(.unmarshal pd data-format-definition))

(defmacro on-completion
"Adds a hook that invoke this route as a callback when the
Exchange has finished being processed."
Expand Down Expand Up @@ -610,6 +626,11 @@
[^ProcessorDefinition pd]
(.end pd))

(defn end-choice
"Ends the current choice"
[^ChoiceDefinition cd]
(.endChoice cd))

(defn on-when
"Sets an additional predicate that should be true before the onCompletion is triggered.
To be used for fine grained controlling whether a completion callback should be invoked or not"
Expand Down

0 comments on commit d0484af

Please sign in to comment.