ServiceMix XMPP
Work 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.
mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-xmpp-service-unit \ -DgroupId=com.mycompany.myproduct \ -DartifactId=mycomponent.artifact
Cookbook recipes
- File to XMPP Bridge — implement a simple file to xmpp forwarder
Endpoints
<xmpp:sender service="test:myJabberService" endpoint="senderEndpoint" host="my.jabberserver.lan" port="5222" user="lhein" password="myPassword" createAccount="false" participant="gertv@my.jabberserver.lan" />
<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" />
<xmpp:receiver service="test:myJabberService" endpoint="receiverEndpoint" targetService="test:myJabberProcessor" host="my.jabberserver.lan" port="5222" user="lhein" password="myPassword" createAccount="false" />
<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)
Message 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.
Receiver endpoint attributes
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 |
Poller endpoint attributes
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.
Sender endpoint attributes
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:
<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>
Links
- XMPP Integration Testing
- Smack API the client side XMPP API
- Wildfire the GPL Jabber server