IRC

Since Camel 1.1

Both producer and consumer are supported

The IRC component implements an IRC (Internet Relay Chat) transport.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-irc</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

Options

The IRC component supports 4 options, which are listed below.

Name Description Default Type

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 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

basicPropertyBinding (advanced)

Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities

false

boolean

useGlobalSslContextParameters (security)

Enable usage of global SSL context parameters.

false

boolean

The IRC endpoint is configured using URI syntax:

irc:hostname:port

with the following path and query parameters:

Path Parameters (2 parameters):

Name Description Default Type

hostname

Required Hostname for the IRC chat server

String

port

Port number for the IRC chat server. If no port is configured then a default port of either 6667, 6668 or 6669 is used.

int

Query Parameters (29 parameters):

Name Description Default Type

autoRejoin (common)

Whether to auto re-join when being kicked

true

boolean

channels (common)

Comma separated list of IRC channels.

String

commandTimeout (common)

Delay in milliseconds before sending commands after the connection is established.

5000

long

keys (common)

Comma separated list of keys for channels.

String

namesOnJoin (common)

Sends NAMES command to channel after joining it. onReply has to be true in order to process the result which will have the header value irc.num = '353'.

false

boolean

nickname (common)

The nickname used in chat.

String

persistent (common)

Deprecated Use persistent messages.

true

boolean

realname (common)

The IRC user’s actual name.

String

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 or ERROR level and ignored.

false

boolean

exceptionHandler (consumer)

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)

Sets the exchange pattern when the consumer creates an exchange. The value can be one of: InOnly, InOut, InOptionalOut

ExchangePattern

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

basicPropertyBinding (advanced)

Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities

false

boolean

colors (advanced)

Whether or not the server supports color codes.

true

boolean

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

onJoin (filter)

Handle user join events.

true

boolean

onKick (filter)

Handle kick events.

true

boolean

onMode (filter)

Handle mode change events.

true

boolean

onNick (filter)

Handle nickname change events.

true

boolean

onPart (filter)

Handle user part events.

true

boolean

onPrivmsg (filter)

Handle private message events.

true

boolean

onQuit (filter)

Handle user quit events.

true

boolean

onReply (filter)

Whether or not to handle general responses to commands or informational messages.

false

boolean

onTopic (filter)

Handle topic change events.

true

boolean

nickPassword (security)

Your IRC server nickname password.

String

password (security)

The IRC server password.

String

sslContextParameters (security)

Used for configuring security using SSL. Reference to a org.apache.camel.support.jsse.SSLContextParameters in the Registry. This reference overrides any configured SSLContextParameters at the component level. Note that this setting overrides the trustManager option.

SSLContextParameters

trustManager (security)

The trust manager used to verify the SSL server’s certificate.

SSLTrustManager

username (security)

The IRC server user name.

String

SSL Support

Using the JSSE Configuration Utility

The IRC component supports SSL/TLS configuration through the Camel JSSE Configuration Utility. This utility greatly decreases the amount of component specific code you need to write and is configurable at the endpoint and component levels. The following examples demonstrate how to use the utility with the IRC component.

Programmatic configuration of the endpoint

KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("/users/home/server/truststore.jks");
ksp.setPassword("keystorePassword");

TrustManagersParameters tmp = new TrustManagersParameters();
tmp.setKeyStore(ksp);

SSLContextParameters scp = new SSLContextParameters();
scp.setTrustManagers(tmp);

Registry registry = ...
registry.bind("sslContextParameters", scp);

...

from(...)
    .to("ircs://camel-prd-user@server:6669/#camel-test?nickname=camel-prd&password=password&sslContextParameters=#sslContextParameters");

Spring DSL based configuration of endpoint

...
  <camel:sslContextParameters
      id="sslContextParameters">
    <camel:trustManagers>
      <camel:keyStore
          resource="/users/home/server/truststore.jks"
          password="keystorePassword"/>
    </camel:keyManagers>
  </camel:sslContextParameters>...
...
  <to uri="ircs://camel-prd-user@server:6669/#camel-test?nickname=camel-prd&password=password&sslContextParameters=#sslContextParameters"/>...

Using the legacy basic configuration options

You can also connect to an SSL enabled IRC server, as follows:

ircs:host[:port]/#room?username=user&password=pass

By default, the IRC transport uses SSLDefaultTrustManager. If you need to provide your own custom trust manager, use the trustManager parameter as follows:

ircs:host[:port]/#room?username=user&password=pass&trustManager=#referenceToMyTrustManagerBean

Using keys

Since Camel 2.2

Some irc rooms requires you to provide a key to be able to join that channel. The key is just a secret word.

For example we join 3 channels where as only channel 1 and 3 uses a key.

irc:nick@irc.server.org?channels=#chan1,#chan2,#chan3&keys=chan1Key,,chan3key

Getting a list of users of the channel

Using the namesOnJoin option one can invoke the IRC-NAMES command after the component has joined a channel. The server will reply with irc.num = 353. So in order to process the result the property onReply has to be true. Furthermore one has to filter the onReply exchanges in order to get the names.

For example we want to get all exchanges that contain the usernames of the channel:

from("ircs:nick@myserver:1234/#mychannelname?namesOnJoin=true&onReply=true")
	.choice()
		.when(header("irc.messageType").isEqualToIgnoreCase("REPLY"))
			.filter(header("irc.num").isEqualTo("353"))
			.to("mock:result").stop();

Sending to different channel or a person

If you need to send messages to a different channel (or a person) which is not defined on IRC endpoint, you can specify a different destination in a message header.

You can specify the destination in the following header:

Header Type Description

irc.sendTo

String

The channel (or the person) name.

Spring Boot Auto-Configuration

When using irc with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-irc-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 5 options, which are listed below.

Name Description Default Type

camel.component.irc.autowired-enabled

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

camel.component.irc.bridge-error-handler

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 or ERROR level and ignored.

false

Boolean

camel.component.irc.enabled

Whether to enable auto configuration of the irc component. This is enabled by default.

Boolean

camel.component.irc.lazy-start-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

camel.component.irc.use-global-ssl-context-parameters

Enable usage of global SSL context parameters.

false

Boolean