Camel Components

Ignite Messaging

Since Camel 2.17

Both producer and consumer are supported

The Ignite Messaging endpoint is one of camel-ignite endpoints that allow you to send and consume messages from an Ignite topic.

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, *.yaml files, 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 Ignite Messaging component supports the following options which are listed below.

Name Description Default Type

configurationResource (common)

A Spring XML configuration of Ignite to start a new Ignite node with (Ignition.start): a URL, an InputStream, or a String with the path or URL of the file. It takes precedence over igniteConfiguration, and is ignored when ignite is set. The component stops the node when it stops.

Object

ignite (common)

An existing Ignite instance to use, instead of starting a new Ignite node. The component neither starts nor stops it, and ignores configurationResource and igniteConfiguration.

Ignite

igniteConfiguration (common)

An IgniteConfiguration to start a new Ignite node with (Ignition.start), used when neither ignite nor configurationResource is set. The component stops the node when it stops.

IgniteConfiguration

bridgeErrorHandler (consumer)

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

lazyStartProducer (producer)

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

autowiredEnabled (advanced)

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

Endpoint Options

The Ignite Messaging endpoint is configured using URI syntax:

ignite-messaging:topic

With the following path and query parameters:

Path Parameters

Name Description Default Type

topic (common)

Required The Ignite topic to send messages to, or to receive messages from. The CamelIgniteMessagingTopic header overrides it for the producer.

String

Query Parameters

Name Description Default Type

clusterGroupExpression (common)

A ClusterGroupExpression that returns the ClusterGroup whose nodes the producer sends the messages to (Ignite.message(ClusterGroup)). By default all nodes of the cluster. The consumer listens on the local node (IgniteMessaging.localListen), and receives the messages of the topic from any node.

ClusterGroupExpression

propagateIncomingBodyIfNoReturnValue (common)

Whether the producer keeps the incoming message body when the Ignite operation has no result, such as a cache PUT, REMOVE or CLEAR, a queue PUT or CLEAR, a set CLEAR, a compute RUN or AFFINITY_RUN, or a messaging send. When false, the body is null after such an operation. Not used by ignite-idgen and ignite-events.

true

boolean

treatCollectionsAsCacheObjects (common)

Whether a Collection in the body is one object, instead of several elements. By default a cache PUT of a Map without the CamelIgniteCacheKey header puts each of its entries, a cache GET or REMOVE of a Set works on each of its keys, a queue or set ADD, CONTAINS or REMOVE works on each element, and an UNORDERED messaging send sends each element as a message. When true, the Collection is stored, looked up or sent as one object. Not used by ignite-compute, ignite-idgen and ignite-events.

false

boolean

bridgeErrorHandler (consumer (advanced))

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

exceptionHandler (consumer (advanced))

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

exchangePattern (consumer (advanced))

Sets the exchange pattern when the consumer creates an exchange.

Enum values:

  • InOnly

  • InOut

ExchangePattern

sendMode (producer)

How the producer sends: UNORDERED with IgniteMessaging.send, or ORDERED with IgniteMessaging.sendOrdered, which delivers the messages of the topic in the order they were sent and needs the timeout option. Ignite does not allow ordered and unordered messages on the same topic.

Enum values:

  • ORDERED

  • UNORDERED

UNORDERED

IgniteMessagingSendMode

timeout (producer)

For the ORDERED send mode, how long in milliseconds a message that arrives out of order waits for the messages ordered ahead of it; when it expires, the missing messages are skipped. 0 uses the networkTimeout of the IgniteConfiguration. Required with ORDERED, not used with UNORDERED.

Long

lazyStartProducer (producer (advanced))

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

Message Headers

The Ignite Messaging component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelIgniteMessagingTopic (common)

Constant: IGNITE_MESSAGING_TOPIC

The topic the producer sends to, overriding the topic of the endpoint. The consumer sets it to the topic it received the message on; while the header still holds that topic, the producer ignores it and sends to the topic of its endpoint.

String

CamelIgniteMessagingUUID (consumer)

Constant: IGNITE_MESSAGING_UUID

The ID of the cluster node that sent the message.

UUID

Message Body

The message body at each side of the Ignite Messaging 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

unknown

The message as it was sent to the topic, with the topic in the CamelIgniteMessagingTopic header and the ID of the node that sent it in CamelIgniteMessagingUUID.

Producer input

text, bytes, value, map, list or pojo

The message to send, as the object: it must be serializable for the other nodes, so a stream is not read. In UNORDERED mode a Collection is one message per element, unless treatCollectionsAsCacheObjects=true. No body fails. The topic is the CamelIgniteMessagingTopic header, or else the endpoint topic.

Producer output

unchanged

  • With propagateIncomingBodyIfNoReturnValue=false: null

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.

Usage

The component needs an Ignite node: Ignite describes the ways to give it one.

The producer sends the body to the orders topic, and the consumer receives the messages of that topic:

- route:
    from:
      uri: direct:publish
      steps:
        - to:
            uri: ignite-messaging:orders
- route:
    from:
      uri: ignite-messaging:orders
      steps:
        - log:
            message: "Received: ${body}"

The consumer sets the CamelIgniteMessagingTopic header to the topic it received a message on. While the header still holds that topic, the producer sends to the topic of its endpoint, so a route from one topic to another sends each message to the second topic, not back to the first one. A topic header set by the route is used. To send a received message back to its topic through the header, remove the CamelIgniteMessagingReceivedTopic exchange property (which the consumer sets to the received topic) before the producer, such as with .removeProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC) in Java. The property name is CamelIgniteMessagingReceivedTopic, so in YAML it is a removeProperty step with name: CamelIgniteMessagingReceivedTopic, and in XML <removeProperty name="CamelIgniteMessagingReceivedTopic"/>.