이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 164. IRC Component


Available as of Camel version 1.1

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>

164.1. URI format

irc:nick@host[:port]/#room[?options]
irc:nick@host[:port]?channels=#channel1,#channel2,#channel3[?options]

You can append query options to the URI in the following format, ?option=value&option=value&…​

164.2. Options

The IRC component supports 2 options which are listed below.

NameDescriptionDefaultType

useGlobalSslContext Parameters (security)

Enable usage of global SSL context parameters.

false

boolean

resolveProperty Placeholders (advanced)

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

boolean

The IRC endpoint is configured using URI syntax:

irc:hostname:port

with the following path and query parameters:

164.2.1. Path Parameters (2 parameters):

NameDescriptionDefaultType

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

164.2.2. Query Parameters (24 parameters):

NameDescriptionDefaultType

autoRejoin (common)

Whether to auto re-join when being kicked

true

boolean

namesOnJoin (common)

Sends NAMES command to channel after joining it. link 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 options 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.

 

ExchangePattern

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

164.3. SSL Support

164.3.1. Using the JSSE Configuration Utility

As of Camel 2.9, 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"/>...

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

164.4. Using keys

Available as of 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

164.5. 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();

164.6. See Also

  • Configuring Camel
  • Component
  • Endpoint
  • Getting Started
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.