Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

XMPP Transport Reference

The XMPP transport enables receiving and sending Mule messages over the Extensible Messaging and Presence Protocol (aka Jabber).

Transport Info

Transport Doc Inbound Outbound Request Transactions Streaming Retries MEPs Default MEP Maven Artifact

XMPP

JavaDoc SchemaDoc

check

check

check

image

image

image

one-way, request-response

one-way

org.mule.transport:mule-transport-xmpp

Legend

Transport - The name/protocol of the transport
Docs - Links to the JavaDoc and SchemaDoc for the transport
Inbound - Whether the transport can receive inbound events and can be used for an inbound endpoint
Outbound - Whether the transport can produce outbound events and be used with an outbound endpoint
Request - Whether this endpoint can be queried directly with a request call (via MuleClinet or the EventContext)
Transactions - Whether transactions are supported by the transport. Transports that support transactions can be configured in either local or distributed two-phase commit (XA) transaction.
Streaming - Whether this transport can process messages that come in on an input stream. This allows for very efficient processing of large data. For more information, see Streaming.
Retry - Whether this transport supports retry policies. Note that all transports can be configured with Retry policies, but only the ones marked here are officially supported by MuleSoft
MEPs - Message Exchange Patterns supported by this transport
Default MEP - The default MEP for endpoints that use this transport that do not explicitly configure a MEP
Maven Artifact - The group name a artifact name for this transport in Maven

Namespace and Syntax

XML Namespace


         
      
1
http://www.mulesoft.org/schema/mule/xmpp

XML Schema Location


         
      
1
http://www.mulesoft.org/schema/mule/xmpp/3.3/mule-xmpp.xsd

Endpoint syntax

  1. Raw URLs

    
                
             
    1
    2
    3
    
    xmpp://MESSAGE/theUser@jabber.server.com
    xmpp://CHAT/theUser@jabber.server.com
    xmpp://GROUPCHAT/theGroupChat
  2. Transport-specific endpoints in XML

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    
    <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


         
      
1
<xmpp:connector name="xmpp" host="localhost" user="theUser" password="secret"/>

Filters

There are several filters in the

package that filter XMPP messages. AbstractXmppFilter is an abstract filter adapter that allows http://www.igniterealtime.org/projects/smack/index.jsp[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


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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.3/mule.xsd
      http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.3/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>

Simple Jabber chat client


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?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-current.xsd
        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd
        http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.3/mule-xmpp.xsd
        http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.3/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>

Note: In this code example, spring-beans-current.xsd is a placeholder. To locate the correct version, see http://www.springframework.org/schema/beans/[http://www.springframework.org/schema/beans/].

Configuration Reference

Element Listing

XMPP Transport

The XMPP transport connects Mule to an XMPP (Jabber) server.

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.

Child Elements of <connector…​>

Name Cardinality Description

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.

Child Elements of <inbound-endpoint…​>

Name Cardinality Description

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.

Child Elements of <outbound-endpoint…​>

Name Cardinality Description

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.

Child Elements of <endpoint…​>

Name Cardinality Description

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.

Schema

Complete http://www.mulesoft.org/docs/site/current3/schemadocs/namespaces/http_www_mulesoft_org_schema_mule_xmpp/namespace-overview.html[schema reference documentation].

Javadoc API Reference

The Javadoc for this module can be found below:

Maven

This transport is part of the following maven module (for version 3.1):


         
      
1
2
3
4
5
<dependency>
  <groupId>org.mule.transports</groupId>
  <artifactId>mule-transport-xmpp</artifactId>
  <version>3.3.0</version>
</dependency>

Best Practices

Put your login credentials in a properties file, not hard-coded in the configuration. This also allows you to use different settings between development, test and production systems.

Notes

The current implementation of the transport is limited to one-way endpoints only. The logic that supports request-response endpoints is currently not implemented.