Versions Compared

Key

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

ServiceMix XMPP

Warning
titleWork in progress

This page is currently being reworked...Check back later.

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.

...

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
    -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 XMPP Receiver (providerconsumer) endpoint Endpoint (Single User ChatGeneral)
<xmpp:senderreceiver service="test:myJabberService"
  
             endpoint="senderEndpointreceiverEndpoint"
               hosttargetService="my.jabberserver.lantest:myJabberProcessor"
             port  host="5222my.jabberserver.lan"
               userport="lhein5222"
               passworduser="myPasswordlhein"
             createAccount  password="falsemyPassword"
 
              participantcreateAccount="gertv@my.jabberserver.lanfalse"  /> 
Code Block
langxml
titleSender XMPP Receiver (providerconsumer) endpoint Endpoint (Multi User Chat Room Listener)
<xmpp:senderreceiver service="test:myJabberService"
               endpoint="receiverEndpoint"
             endpoint  targetService="senderEndpointtest:myJabberProcessor"
               host="my.jabberserver.lan"
               port="5222"
               user="lhein"
               password="myPassword"
               createAccount="false"  
               room="smxchat@conference.my.jabberserver.lan" /> 

Info
titleXMPP Receiver 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

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

Sender Endpoint (Provider)

The 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
titleReceiving XMPP Sender (consumerProvider) endpoint Endpoint (GeneralSingle User Chat)
<xmpp:receiversender service="test:myJabberService" 
               endpoint="receiverEndpointsenderEndpoint"
               targetServicehost="test:myJabberProcessormy.jabberserver.lan"
               hostport="my.jabberserver.lan5222"
               portuser="5222lhein"
               userpassword="lheinmyPassword"
               passwordcreateAccount="myPasswordfalse" 
               createAccountparticipant="falsegertv@my.jabberserver.lan"  /> 
Code Block
langxml
titleReceiving XMPP Sender (consumerProvider) endpoint Endpoint (Multi User Chat Room Listener)
<xmpp:receiversender service="test:myJabberService" 
               endpoint="receiverEndpoint"
               targetService="test:myJabberProcessor"
  senderEndpoint"
             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.

...

 
Info
titleReceiver endpoint attributesXMPP Sender Endpoint Attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

connection host

string

sets the connection information the host name or ip adress of the XMPP server

null (must be spec'd)

deleteProcessedMessages

boolean

delete mail from server when it is processed

false

processOnlyUnseenMessages

boolean

process only mails which are new (unseen)

true

marshaler

class

org.apache.servicemix.mail.marshaler.AbstractMailMarshaler

DefaultMailMarshaler

maxFetchSize

int

sets max amount of mails to fetch, -1 means no limit

-1

debugMode

boolean

sets the debug mode for the javamail api

false

customTrustManagers

string

sets one or more custom trust managers for use with ssl

null

No Format
Info
titlePoller endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Description

protocol

the protocol to use (example: pop3 or imap)

user

the user name used to log into an account

host

the name or ip address of the mail server

port

the port number to use (optional)

folder

the folder to poll from (optional)

password

the password for the login

 
 

Provider Endpoint (Sending)

The following table shows the configuration possibilities of the endpoint.

Info
titleSender endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

connection

string

sets the connection information

null (must be spec'd)

sender

string

defines the sender address of the mail

no-reply@localhost

receiver

string

defines the receiver address of the mail

null

marshaler

class

org.apache.servicemix.mail.marshaler.AbstractMailMarshaler

DefaultMailMarshaler

debugMode

boolean

sets the debug mode for the javamail api

false

ignoreMessageProperties

java.util.List

a list of properties of the IN message which will be ignored

false

customProperties

java.util.Map

a map of custom properties for the connection

null

customTrustManagers

string

sets one or more custom trust managers for use with ssl

null

...

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

For providing your own marshaler you only need to implement two methods:

...

toJBI(...)

This method is responsible for translating a received mail XMPP message into a jbi compliant normalized message ready to be sent to the bus.

...

fromJBI(...)

This method is responsible for translating a received normalized message into a mail XMPP message ready to be sent to the mail server.

...

Code Block
langxml
titleMarshaler example
<mail<xmpp:pollerreceiver service="test:myMailServicemyJabberService"
               endpoint="receiverEndpoint"
              endpoint targetService="senderEndpointtest:myJabberProcessor"
              sender host="no-reply@servicemix.org" 
my.jabberserver.lan"
               port="5222"
               connection="imap://lhein@testserver:143?password=myPass" > user="lhein"
               password="myPassword"
               createAccount="false"  
               room="smxchat@conference.my.jabberserver.lan" >

    <property name="marshaler">
        <bean class="com.mycompany.MyMailMarshalerMyXMPPMarshaler" />
    </property>

</mailxmpp:poller>receiver>