Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The ServiceMix XMPP component provides support for receiving and sending XMPP messages via the enterprise service bus.

Installation

Installing the servicemix-xmpp component can be done in several ways:

  • drop the installer zip in an hotdeploy directory monitored by ServiceMix
  • using ant tasks

Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.

Creation

Maven Archetype

You can use Maven to create a XMPP service unit.:

Code Block
mvn archetype:create \
    -DarchetypeGroupId=org.apache.servicemix.tooling \
    -DarchetypeArtifactId=servicemix-xmpp-service-unit \
    -DarchetypeVersion=2010.01 \
    -DgroupId=com.mycompany.myproduct \
    -DartifactId=mycomponent.artifact \

Cookbook recipes

Children Display
pageSM:servicemix-xmpp cookbook
excerpttrue
excerptTypesimple

Endpoints

Code Block
langxml
titleSender (provider) endpoint (Single User Chat)

<xmpp:sender service="test:myJabberService" 
             endpoint="senderEndpoint"
             host="my.jabberserver.lan"
             port="5222"
             user="lhein"
             password="myPassword"
             createAccount="false" 
             participant="gertv@my.jabberserver.lan" /> 
    -Dversion=1.0-SNAPSHOT

Once you've customized the service unit, simply install the SU:

Code Block

mvn install
Info

Remember that to be deployable in ServiceMix, the ServiceUnit has to be embedded in a Service Assembly: only the Service Assembly zip file can be deployed in ServiceMix.
To add your SU in a SA, you need to define it in the dependency sets:

Code Block

<dependency>
  <groupId>your.group.id</groupId>
  <artifactId>your.artifact.id</artifactId>
  <version>your-version</version>
</dependency>

Endpoints Configuation

Receiver Endpoint (Consumer)

The receiver endpoint connects to the XMPP server and waiting for incoming XMPP messages.
When it receives a XMPP message, it converts it to JBI message (using the marshaler) and send to the NMR.

Note
titleMessage Exchange Pattern

The receiver endpoint will only generate InOnly exchanges.

Code Block
langxml
titleSender (provider) endpoint (Multi User Chat Room)
<xmpp:sender service="test:myJabberService" endpoint="senderEndpoint" host="my.jabberserver.lan" port="5222" user="lhein" password="myPassword" createAccount="false" room="smxchat@conference.my.jabberserver.lan" />

Code Block
langxml
titleReceiving XMPP Receiver (consumer) endpoint Endpoint (General)
<xmpp:receiver service="test:myJabberService"
               endpoint="receiverEndpoint"
               targetService="test:myJabberProcessor"
               host="my.jabberserver.lan"
               port="5222"
               user="lhein"
               password="myPassword"
               createAccount="false"  />
Code Block
langxml
titleReceiving XMPP Receiver (consumer) endpoint Endpoint (Chat Room Listener)
<xmpp:receiver service="test:myJabberService"
               endpoint="receiverEndpoint"
               targetService="test:myJabberProcessor"
               host="my.jabberserver.lan"
               port="5222"
               user="lhein"
               password="myPassword"
               createAccount="false"  
               room="smxchat@conference.my.jabberserver.lan"/>

Consumer Endpoint (Receiving)

Note
titleMessage Exchange Pattern
The receiver endpoint will only generate InOnly exchanges.

The following table shows the additional configuration possibilities of the endpoint other than the configuration of the default ConsumerEndpoint class.

Info
titleXMPP Receiver endpoint attributesEndpoint Attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

host

string

sets the host name or ip adress of the XMPP server

null (must be spec'd)

port

int

the port number of the XMPP service

5222

user

String

the user name of the XMPP account

null (must be spec'd)

password

String

the password of the XMPP account

null (must be spec'd)

resource

String

the name of the resource / client

null

room

String

full room name (for example area51@conference.myserver.com) or null

null (means no room)

proxyHost

String

the hostname of the proxy to use

null

proxyPort

String

the port of the proxy to use

3128

proxyUser

String

the user name for the proxy to use

null

proxyPass

String

the user password for the proxy to use

null

proxyType

String

the proxy type to use (NONE, HTTP, SOCKS4, SOCKS5)

null

login

boolean

a flag if the user should login to the XMPP account

true

createAccount

boolean

a flag if an account should be created for unknown users

false

filter

class

a class which implements org.jivesoftware.smack.filter.PacketFilter

null

marshaler

class

a marshaler class which converts XMPP to NMSG

DefaultXMPPMarshaler

No Format

...

Sender Endpoint (

...

Provider)

The following table shows the configuration possibilities of the endpoint.XMPP Sender endpoint expects messages coming from the NMR, converts it into a XMPP message (using the marshaler) and send to the XMPP server.

Code Block
langxml
titleXMPP Sender (Provider) Endpoint (Single User Chat)

<xmpp:sender service="test:myJabberService" 
             endpoint="senderEndpoint"
             host="my.jabberserver.lan"
             port="5222"
             user="lhein"
             password="myPassword"
             createAccount="false" 
             participant="gertv@my.jabberserver.lan" /> 
Code Block
langxml
titleXMPP Sender (Provider) Endpoint (Multi User Chat Room)

<xmpp:sender service="test:myJabberService" 
             endpoint="senderEndpoint"
             host="my.jabberserver.lan"
             port="5222"
             user="lhein"
             password="myPassword"
             createAccount="false" 
             room="smxchat@conference.my.jabberserver.lan" /> 
Info
titleXMPP Sender Endpoint Attributes
Info
titleSender endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

host

string

sets the host name or ip adress of the XMPP server

null (must be spec'd)

port

int

the port number of the XMPP service

5222

user

String

the user name of the XMPP account

null (must be spec'd)

password

String

the password of the XMPP account

null (must be spec'd)

resource

String

the name of the resource / client

null

participant

String

the name of the person to chat with (if you specify this, leave room null)

null

room

String

full room name (if you specify this, leave participant null)

null

proxyHost

String

the hostname of the proxy to use

null

proxyPort

String

the port of the proxy to use

3128

proxyUser

String

the user name for the proxy to use

null

proxyPass

String

the user password for the proxy to use

null

proxyType

String

the proxy type to use (NONE, HTTP, SOCKS4, SOCKS5)

null

login

boolean

a flag if the user should login to the XMPP account

true

createAccount

boolean

a flag if an account should be created for unknown users

false

marshaler

class

a marshaler class which converts XMPP to NMSG

DefaultXMPPMarshaler

...

Cookbook recipes

Children Display
pageservicemix-xmpp cookbook
excerpttrue

Marshalers

You can write your own marshalers for conversion between XMPP and normalized message and vice versa.
To do this you simply need to subclass the org.apache.servicemix.xmpp.marshaler.impl.DefaultXMPPMarshaler or start from scratch
by implementing the ** org.apache.servicemix.xmpp.marshaler.XMPPMarshalerSupport interface.

The marshaler interface methods

...