Wiki Markup |
---|
h2. XMPP Component |
...
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 | ||
: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 |
---|
{code} h3. URI format {code} xmpp://[login@]hostname[:port][/participant][?Options] {code} The component supports both room based and private person-person conversations. |
...
The component supports both producer and consumer (you can get messages from XMPP or send messages to XMPP). 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&...}} h3. |
...
Options
...
Name
...
Description
...
room
...
Options {div:class=confluenceTableSmall} || Name || Description || | {{room}} | If this option is specified, 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 is {{krypton@conference.jabber.org}}. Note the {{conference}} part. Starting from camel-1.5.0, it is not a requirement to provide the full room JID. If the {{room}} parameter does not contain the {{@}} symbol, the domain part will be discovered and added by |
...
user
...
Camel| | {{user}} | User name (without server name). If not specified, anonymous login will be attempted. |
...
password
...
Password.
...
resource
...
XMPP resource. The default is Camel
.
...
createAccount
...
If true
, 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 nickname when joining room. If room is specified and nickname is not, user
will be used for the nickname.
...
serviceName
...
| | {{password}} | Password. | | {{resource}} | XMPP resource. The default is {{Camel}}. | | {{createAccount}} | If {{true}}, 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 nickname when joining room. If room is specified and nickname is not, {{user}} will be used for the nickname. | | {{serviceName}} | *Camel 1.6/2.0* The name of the service you are connecting to. For Google Talk, this would be {{gmail.com |
...
Headers and setting Subject or Language
...
}}. | {div} h3. 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. In *Camel 1.6.2/2.0* the *Subject* and *Language* of the XMPP message are also set if they are provided as IN headers. h3. |
...
Examples |
...
User {{superman}} to join room {{krypton}} at {{jabber}} server with password, {{secret}}: |
...
{code |
} xmpp://superman@jabber.org/?room=krypton@conference.jabber.org&password=secret {code} User {{superman}} to send messages to {{joker}}: |
...
{code |
} xmpp://superman@jabber.org/joker@jabber.org?password=secret {code} Routing example in Java: |
...
{code |
} from("timer://kickoff?period=10000"). setBody(constant("I will win!\n Your Superman.")). to("xmpp://superman@jabber.org/joker@jabber.org?password=secret"); {code} Consumer configuration, which writes all messages from {{joker}} into the queue, {{evil.talk}}. |
...
{code |
} from("xmpp://superman@jabber.org/joker@jabber.org?password=secret"). to("activemq:evil.talk"); {code} Consumer configuration, which listens to room messages (supported from camel-1.5.0): |
...
{code |
} from("xmpp://superman@jabber.org/?password=secret&room=krypton@conference.jabber.org"). to("activemq:krypton.talk"); {code} Room in short notation (no domain part; for camel-1.5.0+): |
...
{code |
} from("xmpp://superman@jabber.org/?password=secret&room=krypton"). to("activemq:krypton.talk"); {code} When connecting to the Google Chat service, you'll need to specify the {{serviceName}} as well as your credentials (as of *Camel 1.6/2.0*): |
...
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/GoogleTalkTest.java} {include |
...
:Endpoint See |
...
Also} |