Table of Contents
Available since Camel 2.17.0
NATS is a fast and reliable messaging platform.
Maven users will need to add the following dependency to
their pom.xml for this component.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-nats</artifactId>
<!-- use the same version as your Camel core version -->
<version>x.y.z</version>
</dependency>The Nats component has no options.
The Nats component supports 18 endpoint options which are listed below:
{% raw %}
| Name | Group | Default | Java Type | Description |
|---|---|---|---|---|
servers | common |
| Required URLs to one or more NAT servers. Use comma to separate URLs when specifying multiple servers. | |
maxReconnectAttempts | common |
|
| Max reconnection attempts |
noRandomizeServers | common |
|
| Whether or not randomizing the order of servers for the connection attempts |
pedantic | common |
|
| Whether or not running in pedantic mode (this affects performace) |
pingInterval | common |
|
| Ping interval to be aware if connection is still alive (in milliseconds) |
reconnect | common |
|
| Whether or not using reconnection feature |
reconnectTimeWait | common |
|
| Waiting time before attempts reconnection (in milliseconds) |
ssl | common |
|
| Whether or not using SSL |
topic | common |
| Required The name of topic we want to use | |
verbose | common |
|
| Whether or not running in verbose mode |
bridgeErrorHandler | consumer |
|
| Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. |
maxMessages | consumer |
| Stop receiving messages from a topic we are subscribing to after maxMessages | |
poolSize | consumer |
|
| Consumer pool size |
queueName | consumer |
| The Queue name if we are using nats for a queue configuration | |
exceptionHandler | consumer (advanced) |
| To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | |
exchangePattern | consumer (advanced) |
| Sets the exchange pattern when the consumer creates an exchange. | |
replySubject | producer |
| the subject to which subscribers should send response | |
synchronous | advanced |
|
| Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). |
{% endraw %}
| Name | Type | Description |
|---|---|---|
CamelNatsMessageTimestamp | long | The timestamp of a consumed message. |
CamelNatsSubscriptionId | Integer | The subscription ID of a consumer. |
Producer example:
from("direct:send").to("nats://localhost:4222?topic=test");
Consumer example:
from("nats://localhost:4222?topic=test&maxMessages=5&queueName=test").to("mock:result");