Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a section about BuildIfProfile and conditional channel configuration in the amqp and kafka reference guides.

(cherry picked from commit ecb8783)
  • Loading branch information
cescoffier authored and gsmet committed Aug 26, 2023
1 parent 55c85da commit 0729d46
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/src/main/asciidoc/amqp-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -817,3 +817,18 @@ Type: _string_ | false |
Type: _string_ | false |

|===

=== Conditionally configure channels

You can configure the channels using a specific profile.
Thus, the channels are only configured (and added to the application) when the specified profile is enabled.

To achieve this, you need:

1. Prefix the `mp.messaging.[incoming|outgoing].$channel` entries with `%my-profile` such as `%my-profile.mp.messaging.[incoming|outgoing].$channel.key=value`
2. Use the `@IfBuildProfile("my-profile")` on the CDI beans containing `@Incoming(channel)` and `@Outgoing(channel)` annotations that need only to be enabled when the profile is enabled.

Note that reactive messaging verifies that the graph is complete.
So, when using such a conditional configuration, ensure the application works with and without the profile enabled.

Note that this approach can also be used to change the channel configuration based on a profile.
15 changes: 15 additions & 0 deletions docs/src/main/asciidoc/kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,21 @@ Attribute values are resolved as follows:
2. if not set, the connector looks for a `Map` with the channel name or the configured `kafka-configuration` (if set) and the value is retrieved from that `Map`
3. If the resolved `Map` does not contain the value the default `Map` is used (exposed with the `default-kafka-broker` name)

=== Conditionally configure channels

You can configure the channels using a specific profile.
Thus, the channels are only configured (and added to the application) when the specified profile is enabled.

To achieve this, you need:

1. Prefix the `mp.messaging.[incoming|outgoing].$channel` entries with `%my-profile` such as `%my-profile.mp.messaging.[incoming|outgoing].$channel.key=value`
2. Use the `@IfBuildProfile("my-profile")` on the CDI beans containing `@Incoming(channel)` and `@Outgoing(channel)` annotations that need only to be enabled when the profile is enabled.

Note that reactive messaging verifies that the graph is complete.
So, when using such a conditional configuration, ensure the application works with and without the profile enabled.

Note that this approach can also be used to change the channel configuration based on a profile.

== Integrating with Kafka - Common patterns

=== Writing to Kafka from an HTTP endpoint
Expand Down

0 comments on commit 0729d46

Please sign in to comment.