Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Creation

You can use Maven to create a service unit.

Code Block

mvn archetype:create \
    -DarchetypeGroupId=org.apache.servicemix.tooling \
    -DarchetypeArtifactId=servicemix-xmpp-service-unit \
    -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" /> 
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 (consumer) 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 (consumer) 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
titleReceiver endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Default

connection

string

sets the connection information

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

For all xbean file endpoint configuration take a look at Xml schemas

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 ** interface.

The marshaler interface methods

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

convertMailToJBI(...)

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

convertJBIToMail(...)

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

After finishing your marshaler you can simply configure your endpoints to use it:

Code Block
langxml
titleMarshaler example

<mail:poller service="test:myMailService" 
             endpoint="senderEndpoint"
             sender="no-reply@servicemix.org" 
             connection="imap://lhein@testserver:143?password=myPass" > 

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

</mail:poller>

URI

You can use the standard XMPP URI syntax with ServiceMix XMPP - namely RFC 4622 based URIs. For example

Code Block

xmpp://user@myserver/room@anotherServer
xmpp:user@server