http://www.mulesoft.org/schema/mule/xmpp
XMPP Transport Reference
Introduction
The XMPP transport enables receiving and sending Mule messages over the Extensible Messaging and Presence Protocol (aka Jabber).
Namespace and Syntax
XML Namespace
XML schema location
http://www.mulesoft.org/schema/mule/xmpp/3.1/mule-xmpp.xsd
Endpoint syntax
-
raw URLs
xmpp://MESSAGE/theUser@jabber.server.com xmpp://CHAT/theUser@jabber.server.com xmpp://GROUPCHAT/theGroupChat
-
transport specific endpoints in XML
<xmpp:inbound-endpoint type="MESSAGE" from="theUser@jabber.server.com"/> <xmpp:outbound-endpoint type="MESSAGE" recipient="theUser@jabber.server.com"/> <xmpp:inbound-endpoint type="CHAT" from="theUser@jabber.server.com"/> <xmpp:outbound-endpoint type="CHAT" recipient="theUser@jabber.server.com"/> <xmpp:inbound-endpoint type="GROUPCHAT" from="theGroupChat" nickname="muley"/> <xmpp:outbound-endpoint type="GROUPCHAT" recipient="theGroupChat" nickname="muley"/>
Connector and endpoint syntax
<xmpp:connector name="xmpp" host="localhost" user="theUser" password="secret"/>
Filters
There are several filters in the org.mule.transport.xmpp.filters package that filter XMPP messages. AbstractXmppFilter
is an abstract filter adapter that allows Smack filters to be configured as Mule filters. The following filter classes extend the abstract filter:
-
XmppAndFilter
-
XmppFromContainsFilter
-
XmppMessageTypeFilter
-
XmppNotFilter
-
XmppOrFilter
-
XmppPacketIDFilter
-
XmppPacketTypeFilter
-
XmppThreadFilter
-
XmppToContainsFilter
Features
-
Send and receive messages to/from an individual Jabber user
-
Send and receive messages to/from a Jabber one on one chat
-
Send and receive messages to/from a Jabber multi user chat
Usage
The configuration of a connector is mandatory as it represents the Jabber server that will be connected. Thus, all information to establish the connection such as the host to contact and the user credentials to use are configured here.
Configuration options on an endpoint include the type (whether it’s a chat, a message or a groupchat) and the Jabber ID the endpoint is talking to.
The XMPP transport does not support transactions as the XMPP protocol is not transactional.
Example Configurations
Receive messages in a flow
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xmpp="http://www.mulesoft.org/schema/mule/xmpp"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.2/mule-xmpp.xsd">
<xmpp:connector name="xmppConnector" host="localhost" user="theUser" password="secret"/>
<flow name="receiveMessage">
<xmpp:inbound-endpoint type="MESSAGE" from="other@jabber.server.com"/>
<component class="com.mycompany.mule.JabberMessageHandler"/>
</flow>
</mule>
Receive messages in a service
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xmpp="http://www.mulesoft.org/schema/mule/xmpp"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.2/mule-xmpp.xsd">
<xmpp:connector name="xmppConnector" host="localhost" user="theUser" password="secret"/>
<model>
<service name="receiveFromJabber">
<inbound>
<xmpp:inbound-endpoint type="MESSAGE" from="otherUser@jabber.server.com"/>
</inbound>
<component class="com.mycompany.mule.JabberMessageHandler"/>
</service>
</mule>
Simple Jabber chat client
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xmpp="http://www.mulesoft.org/schema/mule/xmpp"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.2/mule-xmpp.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd">
<xmpp:connector name="xmppConnector" host="localhost" user="theUser" password="secret"/>
<flow name="stdio2xmpp">
<stdio:inbound-endpoint system="IN"/>
<xmpp:outbound-endpoint type="CHAT" recipient="otheruser@localhost"/>
</flow>
<flow name="xmpp2stdio">
<xmpp:inbound-endpoint type="CHAT" from="otheruser@localhost"/>
<xmpp:xmpp-to-object-transformer/>
<stdio:outbound-endpoint system="OUT"/>
</flow>
</mule>
Connector
Connect Mule to an XMPP (Jabber) server to send or receive data via the network.
Attributes of <connector…>
Name | Type | Required | Default | Description |
---|---|---|---|---|
host |
string |
no |
Host name or IP address of the Jabber server. |
|
port |
port number |
no |
The port number to connect on. Default port is 5222. |
|
serviceName |
string |
no |
The service name to use when connecting the Jabber server. |
|
user |
string |
no |
The username used for authenitcation. |
|
password |
string |
no |
The password for the user being authenticated. |
|
resource |
string |
no |
The resource portion of the address, such as user@host/resource or domain/resource. |
|
createAccount |
boolean |
no |
If true, an attempt is made to create an account using the user and password while connecting. Default is false. |
No Child Elements of <connector…>
Inbound endpoint
The endpoint on which this connector receives messages from the xmpp connection.
Attributes of <inbound-endpoint…>
Name | Type | Required | Default | Description |
---|---|---|---|---|
recipient |
string |
no |
The Jabber ID of the intended recipient of the messages, such as ross@myco.com. For GROUPCHAT type endpoints, this is the address of the chat to join. |
|
from |
string |
no |
The user who sent the message. Ignored in GROUPCHAT type endpoints. |
|
type |
enumeration |
no |
CHAT |
The type of the Jabber message to send: MESSAGE, CHAT or GROUPCHAT. |
subject |
string |
no |
The subject of the message (applies to type=MESSAGE endpoints only). |
|
thread |
string |
no |
The thread to which the message belongs. |
|
nickname |
string |
no |
The user’s nickname in a groupchat. |
No Child Elements of <inbound-endpoint…>
Outbound endpoint
The endpoint to which this connector sends messages.
Attributes of <outbound-endpoint…>
Name | Type | Required | Default | Description |
---|---|---|---|---|
recipient |
string |
no |
The Jabber ID of the intended recipient of the messages, such as ross@myco.com. For GROUPCHAT type endpoints, this is the address of the chat to join. |
|
from |
string |
no |
The user who sent the message. Ignored in GROUPCHAT type endpoints. |
|
type |
enumeration |
no |
CHAT |
The type of the Jabber message to send: MESSAGE, CHAT or GROUPCHAT. |
subject |
string |
no |
The subject of the message (applies to type=MESSAGE endpoints only). |
|
thread |
string |
no |
The thread to which the message belongs. |
|
nickname |
string |
no |
The user’s nickname in a groupchat. |
No Child Elements of <outbound-endpoint…>
Endpoint
An endpoint "template" that can be used to construct an inbound or outbound endpoint elsewhere in the configuration by referencing the endpoint name.
Attributes of <endpoint…>
Name | Type | Required | Default | Description |
---|---|---|---|---|
recipient |
string |
no |
The Jabber ID of the intended recipient of the messages, such as ross@myco.com. For GROUPCHAT type endpoints, this is the address of the chat to join. |
|
from |
string |
no |
The user who sent the message. Ignored in GROUPCHAT type endpoints. |
|
type |
enumeration |
no |
CHAT |
The type of the Jabber message to send: MESSAGE, CHAT or GROUPCHAT. |
subject |
string |
no |
The subject of the message (applies to type=MESSAGE endpoints only). |
|
thread |
string |
no |
The thread to which the message belongs. |
|
nickname |
string |
no |
The user’s nickname in a groupchat. |
No Child Elements of <endpoint…>
Transformers
These are transformers specific to this transport. Note that these are added automatically to the Mule registry at start up. When doing automatic transformations these will be included when searching for the correct transformers.
Name | Description |
---|---|
xmpp-to-object-transformer |
The xmpp-to-object-transformer element configures a transformer that converts an XMPP message into an object by extracting the message payload. |
object-to-xmpp-transformer |
The object-to-xmpp-transformer element configures a transformer that converts an object into an XMPP message. |
Javadoc API Reference
The Javadoc for this module can be found here.
Maven
This transport is part of the following maven module:
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-xmpp</artifactId>
<version>3.2.0</version>
</dependency>