Iggy
Since Camel 4.17
Both producer and consumer are supported
The Iggy component is used for communicating with Iggy message broker.
Maven users will need to add the following dependency to their pom.xml for this component.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-iggy</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> Netty Version Requirement
The Iggy client library requires Netty 4.2.x or later. If your application uses an older version of Netty (e.g., 4.1.x), you will need to import the Netty 4.2.x BOM in your dependencyManagement section to ensure compatibility with the Iggy client:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.2.7.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Iggy component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
Whether to create the stream if it does not exist. The producer and the consumer check it when they start, and the producer again for each message that has an override header. | true | boolean | |
Whether to create the topic if it does not exist, with the partitionsCount, compressionAlgorithm, messageExpiry, maxTopicSize and iggyHeaderOptions options. The producer and the consumer check it when they start, and the producer again for each message that has an override header. | true | boolean | |
The transport that the client uses to connect to the Iggy server. Enum values:
| TCP | String | |
The compression algorithm of a topic that autoCreateTopic creates. Enum values:
| None | CompressionAlgorithm | |
Allows to pre-configure the Iggy component with common options that the endpoints will reuse. | IggyConfiguration | ||
The hostname or IP address of the Iggy server. | localhost | String | |
Additional options of a topic that autoCreateTopic creates, as key-value pairs that are sent to the server as strings, for example durability. | Map | ||
The maximum size in bytes of a topic that autoCreateTopic creates. With 0 no maximum size is set on the topic. | 0 | Long | |
The time in seconds after which the server deletes the messages of a topic that autoCreateTopic creates. With 0 no expiry is set on the topic. | 0 | Long | |
The number of partitions of a topic that autoCreateTopic creates. | 1 | Long | |
The port of the Iggy server. The default 8090 is the default port of the TCP transport of the server, so set the HTTP port of the server when clientTransport is HTTP. | 8090 | int | |
The ID of a stream that autoCreateStream looks up for the stream of the endpoint: if no stream has this ID, a stream named streamName is created. The stream of a CamelIggyStreamOverride header is looked up and created by its name. The producer and the consumer always address the stream by its name. | Long | ||
The name of the stream that holds the topic. Required. The CamelIggyStreamOverride header replaces it for the producer. | String | ||
Whether the server stores the offset of the consumer group when it returns the polled messages, before the route processes them. If false, the consumer polls from startingOffset and keeps the offset in memory only, so it starts again from startingOffset after a restart. | true | boolean | |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
The name of the consumer group that the consumer joins, and creates if it does not exist. Required for the consumer. | String | ||
Deprecated The number of threads of the thread pool of the consumer. The consumer runs one polling task, so one thread polls the topic. Deprecation note: The consumer polls the topic with one task, so a value above 1 only adds idle threads. | 1 | int | |
The ID of the partition that the consumer polls. If not set, the server chooses the partition for the member of the consumer group. | Long | ||
The maximum number of messages that the consumer polls in one request. | 10 | Long | |
Where the consumer polls from when autoCommit is true: next polls the messages after the offset stored for the consumer group, first the first messages of the partition, and last the last messages of the partition. Enum values:
| next | String | |
The time in milliseconds that the consumer waits for its polling thread to finish when it stops, before it interrupts the thread. | 30000 | int | |
The offset of the first message that the consumer polls when autoCommit is false. 0 is the first message of the partition. | 0 | Long | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
How the producer chooses the partition of the messages it sends, as an org.apache.iggy.message.Partitioning or as text: balanced() (the text balanced) spreads them over the partitions, partitionId(Long) (for example the text partitionId:2) sends to one partition and messagesKey(String) (for example the text messagesKey:order-1) to the partition of a key. | balanced | Partitioning | |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
The password that the client logs in with to the Iggy server. Required, together with the username option: the client fails to connect without them. | String | ||
SSL configuration using an org.apache.camel.support.jsse.SSLContextParameters instance. This takes precedence over tlsEnabled and tlsCertificatePath when configured. | SSLContextParameters | ||
The path to a certificate file in PEM format that the client trusts for the TLS connection to the Iggy server. If not set, the client uses the default trust store of the JVM. | String | ||
Whether the client connects to the Iggy server over TLS. | false | boolean | |
Enable usage of global SSL context parameters. | false | boolean | |
The username that the client logs in with to the Iggy server. Required, together with the password option: the client fails to connect without them. | String |
Endpoint Options
The Iggy endpoint is configured using URI syntax:
iggy:topicName
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Whether to create the stream if it does not exist. The producer and the consumer check it when they start, and the producer again for each message that has an override header. | true | boolean | |
Whether to create the topic if it does not exist, with the partitionsCount, compressionAlgorithm, messageExpiry, maxTopicSize and iggyHeaderOptions options. The producer and the consumer check it when they start, and the producer again for each message that has an override header. | true | boolean | |
The transport that the client uses to connect to the Iggy server. Enum values:
| TCP | String | |
The compression algorithm of a topic that autoCreateTopic creates. Enum values:
| None | CompressionAlgorithm | |
The hostname or IP address of the Iggy server. | localhost | String | |
Additional options of a topic that autoCreateTopic creates, as key-value pairs that are sent to the server as strings, for example durability. | Map | ||
The maximum size in bytes of a topic that autoCreateTopic creates. With 0 no maximum size is set on the topic. | 0 | Long | |
The time in seconds after which the server deletes the messages of a topic that autoCreateTopic creates. With 0 no expiry is set on the topic. | 0 | Long | |
The number of partitions of a topic that autoCreateTopic creates. | 1 | Long | |
The port of the Iggy server. The default 8090 is the default port of the TCP transport of the server, so set the HTTP port of the server when clientTransport is HTTP. | 8090 | int | |
The ID of a stream that autoCreateStream looks up for the stream of the endpoint: if no stream has this ID, a stream named streamName is created. The stream of a CamelIggyStreamOverride header is looked up and created by its name. The producer and the consumer always address the stream by its name. | Long | ||
The name of the stream that holds the topic. Required. The CamelIggyStreamOverride header replaces it for the producer. | String | ||
Whether the server stores the offset of the consumer group when it returns the polled messages, before the route processes them. If false, the consumer polls from startingOffset and keeps the offset in memory only, so it starts again from startingOffset after a restart. | true | boolean | |
The name of the consumer group that the consumer joins, and creates if it does not exist. Required for the consumer. | String | ||
Deprecated The number of threads of the thread pool of the consumer. The consumer runs one polling task, so one thread polls the topic. Deprecation note: The consumer polls the topic with one task, so a value above 1 only adds idle threads. | 1 | int | |
The ID of the partition that the consumer polls. If not set, the server chooses the partition for the member of the consumer group. | Long | ||
The maximum number of messages that the consumer polls in one request. | 10 | Long | |
Where the consumer polls from when autoCommit is true: next polls the messages after the offset stored for the consumer group, first the first messages of the partition, and last the last messages of the partition. Enum values:
| next | String | |
The time in milliseconds that the consumer waits for its polling thread to finish when it stops, before it interrupts the thread. | 30000 | int | |
The offset of the first message that the consumer polls when autoCommit is false. 0 is the first message of the partition. | 0 | Long | |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
How the producer chooses the partition of the messages it sends, as an org.apache.iggy.message.Partitioning or as text: balanced() (the text balanced) spreads them over the partitions, partitionId(Long) (for example the text partitionId:2) sends to one partition and messagesKey(String) (for example the text messagesKey:order-1) to the partition of a key. | balanced | Partitioning | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
To use a custom HeaderFilterStrategy to filter the user headers of a consumed Iggy message before the consumer sets them as Camel headers. The producer does not send Camel headers. | HeaderFilterStrategy | ||
The password that the client logs in with to the Iggy server. Required, together with the username option: the client fails to connect without them. | String | ||
SSL configuration using an org.apache.camel.support.jsse.SSLContextParameters instance. This takes precedence over tlsEnabled and tlsCertificatePath when configured. | SSLContextParameters | ||
The path to a certificate file in PEM format that the client trusts for the TLS connection to the Iggy server. If not set, the client uses the default trust store of the JVM. | String | ||
Whether the client connects to the Iggy server over TLS. | false | boolean | |
The username that the client logs in with to the Iggy server. Required, together with the password option: the client fails to connect without them. | String |
Message Headers
The Iggy component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
| Constant: | The unique identifier of the message. | MessageId | |
CamelIggyMessageOffset (consumer) Constant: | The offset of the message in the partition. | BigInteger | |
CamelIggyMessageTimestamp (consumer) Constant: | The time at which the server stored the message, in microseconds since the Unix epoch. | BigInteger | |
CamelIggyMessageOriginTimestamp (consumer) Constant: | The time at which the client created the message, in microseconds since the Unix epoch. | BigInteger | |
CamelIggyMessageChecksum (consumer) Constant: | The checksum of the message, which the server computes. | BigInteger | |
CamelIggyMessageLength (consumer) Constant: | The length of the payload of the message, in bytes. | Long | |
CamelIggyMessageSize (consumer) Constant: | The size of the message in bytes: the header, the payload and the user headers. | int | |
CamelIggyTopicOverride (producer) Constant: | The name of the topic to send to, instead of the topic of the endpoint. The producer creates the topic if it does not exist and autoCreateTopic is true. | String | |
CamelIggyStreamOverride (producer) Constant: | The name of the stream to send to, instead of the streamName of the endpoint. The producer creates the stream if it does not exist, when autoCreateStream is true; streamId is used only for the stream of the endpoint. | String |
Message Body
The message body at each side of the Iggy component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Consumer |
| The payload of the Iggy message as a byte array: convert or unmarshal it. |
Producer input |
| Bytes, a stream or a file is sent as its bytes, and any other body is converted to text and sent as UTF-8, so a Map or a POJO is sent as its toString(): marshal it first. A List of String or of Iggy Message is sent as one message per element, and an Iggy Message as it is. An empty List sends nothing, and no body or a List with a null element fails. |
Producer output |
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Message body
The producer sends a byte[], an InputStream, a ByteBuffer or a file body as its bytes, unchanged. Any other body is converted to text and sent as UTF-8, so marshal a Map or a POJO first, or it is sent as its toString(). A List of String or of Iggy Message is sent as one message per element, and an Iggy Message as it is. An empty List sends nothing. No body, or a List with a null element, fails the exchange.
The consumer sets the payload of the Iggy message as a byte[] body. Convert it to a String (for example with convertBodyTo(String.class)) or unmarshal it.
Examples
Consuming messages from Iggy
Here is a minimal route to read messages from an Iggy topic:
-
Java
-
XML
-
YAML
from("iggy:my_topic?streamName=my_stream&consumerGroupName=my_consumer_group&host=localhost&port=8090")
.log("Message received from Iggy : ${body}")
.log(" with id ${headers[CamelIggyMessageId]}")
.log(" and offset ${headers[CamelIggyMessageOffset]}"); <route>
<from uri="iggy:my_topic?streamName=my_stream&consumerGroupName=my_consumer_group&host=localhost&port=8090"/>
<log message="Message received from Iggy : ${body}"/>
<log message=" with id ${headers[CamelIggyMessageId]}"/>
<log message=" and offset ${headers[CamelIggyMessageOffset]}"/>
</route> - route:
from:
uri: iggy:my_topic
parameters:
streamName: my_stream
consumerGroupName: my_consumer_group
host: localhost
port: 8090
steps:
- log:
message: "Message received from Iggy : ${body}"
- log:
message: " with id ${headers[CamelIggyMessageId]}"
- log:
message: " and offset ${headers[CamelIggyMessageOffset]}" Producing messages to Iggy
Here is a minimal route to produce messages to an Iggy topic:
-
Java
-
XML
-
YAML
from("direct:start")
.setBody(constant("Message from Camel"))
.to("iggy:my_topic?streamName=my_stream&host=localhost&port=8090"); <route>
<from uri="direct:start"/>
<setBody>
<constant>Message from Camel</constant>
</setBody>
<to uri="iggy:my_topic?streamName=my_stream&host=localhost&port=8090"/>
</route> - route:
from:
uri: direct:start
steps:
- setBody:
constant: "Message from Camel"
- to:
uri: iggy:my_topic
parameters:
streamName: my_stream
host: localhost
port: 8090