Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The xmpp: component implements an XMPP (Jabber) transport.

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

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

URI format

Code Block
languagetext

xmpp://[login@]hostname[:port][/participant][?Options]

The component supports both room based and private person-person conversations.
The component supports both producer and consumer (you can get messages from xmpp XMPP or send messages to xmppXMPP). Consumer mode supports rooms starting from camel-1.5.0.

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

Options

Name

Description

room

If room this option is specified then , the component will connect to MUC (Multi User Chat). Usually, the domain name for MUC is different from the login domain. For example, if you are superman@jabber.org and want to join "the krypton" room, then the room url URL is krypton@conference.jabber.org. Note "the conference" part.
Starting from camel-1.5.0 it It is not required a requirement to provide the full room JID. If the room parameter does not contain "the @" symbol then , the domain part will be discovered and added by Camel

user

User name (without server name). If not specified then , anonymous login attempt will be performedattempted.

password

Password.

resource

XMPP resource. The default is "Camel" .

createAccount

If "true" then , an attempt to create an account will be made. Default is false.

participant

JID (Jabber ID) of person to receive messages. "room" parameter has precedence over "participant".

nickname

Use nick nickname when joining room. If room is specified and nickname is not then ", user" will be used for nick the nickname.

serviceName

The name of the service you are connecting to. For Google Talk, this would be gmail.com.

testConnectionOnStartup

Camel 2.11 Specifies whether to test the connection on startup. This is used to ensure that the XMPP client has a valid connection to the XMPP server when the route starts. Camel throws an exception on startup if a connection cannot be established. When this option is set to false, Camel will attempt to establish a "lazy" connection when needed by a producer, and will poll for a consumer connection until the connection is established. Default is true.

connectionPollDelay

Camel 2.11 The amount of time in seconds between polls to verify the health of the XMPP connection, or between attempts to establish an initial consumer connection. Camel will try to re-establish a connection if it has become inactive. Default is 10 seconds.

pubsubCamel 2.15 Accept pubsub packets on input, default is false
docCamel 2.15 Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise false
connectionConfigurationCamel 2.18: To use an existing connection configuration

Headers and setting Subject or Language

Camel sets the message IN headers as properties on the XMPP message. You can configure a HeaderFilterStategy if you need custom filtering of headers.
The Subject and Language of the XMPP message are also set if they are provided as IN headers.

Examples

User "superman" to join room krypton at jabber server with password ", secret".:

Code Block
languagetext

xmpp://superman@jabber.org/?room=krypton@conference.jabber.org&password=secret

User "superman" to send messages to joker:

Code Block
languagetext

xmpp://superman@jabber.org/joker@jabber.org?password=secret

Routing example in Java:

Code Block
languagejava

from("timer://kickoff?period=10000").
setBody(constant("I will win!\n Your Superman.")).
to("xmpp://superman@jabber.org/joker@jabber.org?password=secret");

Consumer configuration. Will write , which writes all messages from Joker joker into a the queue ", evil.talk".

Code Block
languagejava

from("xmpp://superman@jabber.org/joker@jabber.org?password=secret").
to("activemq:evil.talk");

Consumer configuration listening , which listens to a room messages (supported from camel-1.5.0):

Code Block
languagejava

from("xmpp://superman@jabber.org/?password=secret&room=krypton@conference.jabber.org").
to("activemq:krypton.talk");

Room in short notation (no domain part; for camel-1.5.0+)):

Code Block
languagejava

from("xmpp://superman@jabber.org/?password=secret&room=krypton").
to("activemq:krypton.talk");

When connecting to the Google Chat service, you'll need to specify the serviceName as well as your credentials:

Code Block
languagejava
from("direct:start").
  to("xmpp://talk.google.com:5222/touser@gmail.com?serviceName=gmail.com&user=fromuser&password=secret").
  to("mock:result");

 

Include Page

...

Endpoint See Also

...

Endpoint See Also