The ServiceMix XMPP component provides support for receiving and sending XMPP messages via the bus.
You can use Maven to create a XMPP service unit:
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-xmpp-service-unit \
-DarchetypeVersion=2010.01 \
-DgroupId=com.mycompany.myproduct \
-DartifactId=mycomponent.artifact \
-Dversion=1.0-SNAPSHOT
|
Once you've customized the service unit, simply install the SU:
mvn install |
|
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.
|
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.
|
The receiver endpoint will only generate InOnly exchanges. |
<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"/>
|
|
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.
<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" />
|
|
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.
For providing your own marshaler you only need to implement two methods:
This method is responsible for translating a received XMPP message into a jbi compliant normalized message ready to be sent to the bus.
This method is responsible for translating a received normalized message into a XMPP message ready to be sent to the mail server.
After finishing your marshaler you can simply configure your endpoints to use it:
<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" >
<property name="marshaler">
<bean class="com.mycompany.MyXMPPMarshaler" />
</property>
</xmpp:receiver>
|