servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache ServiceMix > servicemix-xmpp
Date Fri, 10 Sep 2010 08:27:01 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/13/_/styles/combined.css?spaceKey=SM&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SM/servicemix-xmpp">servicemix-xmpp</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~lhein">Lars
Heinemann</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{info} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{noformat}
 <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. Sender Endpoint (Provider) <br>
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >You can write your own marshalers
for conversion between XMPP and normalized message and vice versa. <br>To do this you
simply need to subclass the *org.apache.servicemix.xmpp.marshaler.impl.DefaultXMPPMarshaler*
or start from scratch <br></td></tr>
            <tr><td class="diff-changed-lines" >by implementing the <span class="diff-changed-words">*<span
class="diff-added-chars"style="background-color: #dfd;">org.apache.servicemix.xmpp.marshaler.XMPPMarshalerSupport</span>*</span>
interface. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. The marshaler interface
methods <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="servicemix-xmpp-ServiceMixXMPP"></a>ServiceMix XMPP</h1>

<p>The ServiceMix XMPP component provides support for receiving and sending XMPP messages
via the bus.</p>

<h2><a name="servicemix-xmpp-MavenArchetype"></a>Maven Archetype</h2>

<p>You can use Maven to create a XMPP service unit:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
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
</pre>
</div></div>

<p>Once you've customized the service unit, simply install the SU:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn install
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td>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.<br/>
To add your SU in a SA, you need to define it in the dependency sets:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
  &lt;groupId&gt;your.group.id&lt;/groupId&gt;
  &lt;artifactId&gt;your.artifact.id&lt;/artifactId&gt;
  &lt;version&gt;your-version&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div></td></tr></table></div>

<h2><a name="servicemix-xmpp-EndpointsConfiguation"></a>Endpoints Configuation</h2>

<h3><a name="servicemix-xmpp-ReceiverEndpoint%28Consumer%29"></a>Receiver
Endpoint (Consumer)</h3>

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

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Message Exchange Pattern</b><br
/>The receiver endpoint will only generate InOnly exchanges.</td></tr></table></div>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>XMPP Receiver (consumer) Endpoint (General)</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;xmpp:receiver service=<span class="code-quote">"test:myJabberService"</span>
               endpoint=<span class="code-quote">"receiverEndpoint"</span>
               targetService=<span class="code-quote">"test:myJabberProcessor"</span>
               host=<span class="code-quote">"my.jabberserver.lan"</span>
               port=<span class="code-quote">"5222"</span>
               user=<span class="code-quote">"lhein"</span>
               password=<span class="code-quote">"myPassword"</span>
               createAccount=<span class="code-quote">"false"</span>  /&gt;
</pre>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>XMPP Receiver (consumer) Endpoint (Chat Room
Listener)</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;xmpp:receiver service=<span class="code-quote">"test:myJabberService"</span>
               endpoint=<span class="code-quote">"receiverEndpoint"</span>
               targetService=<span class="code-quote">"test:myJabberProcessor"</span>
               host=<span class="code-quote">"my.jabberserver.lan"</span>
               port=<span class="code-quote">"5222"</span>
               user=<span class="code-quote">"lhein"</span>
               password=<span class="code-quote">"myPassword"</span>
               createAccount=<span class="code-quote">"false"</span>  
               room=<span class="code-quote">"smxchat@conference.my.jabberserver.lan"</span>/&gt;
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>XMPP Receiver
Endpoint Attributes</b><br /><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name 		                </th>
<th class='confluenceTh'> Type 	</th>
<th class='confluenceTh'> Description 							        </th>
<th class='confluenceTh'> Default 		</th>
</tr>
<tr>
<td class='confluenceTd'> host  		                </td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets the host name or ip adress of the XMPP server		     
  </td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> port                  		</td>
<td class='confluenceTd'> int   	</td>
<td class='confluenceTd'> the port number of the XMPP service    				</td>
<td class='confluenceTd'> 5222			</td>
</tr>
<tr>
<td class='confluenceTd'> user                  		</td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user name of the XMPP account        				</td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> password		                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the password of the XMPP account                        	
</td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> resource                              </td>
<td class='confluenceTd'> String        </td>
<td class='confluenceTd'> the name of the resource / client                        
            </td>
<td class='confluenceTd'> null                  </td>
</tr>
<tr>
<td class='confluenceTd'> room      		                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> full room name (for example area51@conference.myserver.com)
or null   </td>
<td class='confluenceTd'> null (means no room)	</td>
</tr>
<tr>
<td class='confluenceTd'> proxyHost     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the hostname of the proxy to use                      		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyPort     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the port of the proxy to use                           		</td>
<td class='confluenceTd'> 3128		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyUser     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user name for the proxy to use                      	
</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyPass     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user password for the proxy to use                   
  		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyType     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the proxy type to use (NONE, HTTP, SOCKS4, SOCKS5)       
   		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> login           	                </td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> a flag if the user should login to the XMPP account      
   		</td>
<td class='confluenceTd'> true		        </td>
</tr>
<tr>
<td class='confluenceTd'> createAccount     	                </td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> a flag if an account should be created for unknown users 
   		</td>
<td class='confluenceTd'> false		        </td>
</tr>
<tr>
<td class='confluenceTd'> filter     	                        </td>
<td class='confluenceTd'> class 	</td>
<td class='confluenceTd'> a class which implements org.jivesoftware.smack.filter.PacketFilter
  </td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> marshaler                             </td>
<td class='confluenceTd'> class         </td>
<td class='confluenceTd'> a marshaler class which converts XMPP to NMSG            
            </td>
<td class='confluenceTd'> DefaultXMPPMarshaler  </td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>

<h2><a name="servicemix-xmpp-SenderEndpoint%28Provider%29"></a>Sender Endpoint
(Provider)</h2>

<p>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.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>XMPP Sender (Provider) Endpoint (Single User
Chat)</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;xmpp:sender service=<span class="code-quote">"test:myJabberService"</span>

             endpoint=<span class="code-quote">"senderEndpoint"</span>
             host=<span class="code-quote">"my.jabberserver.lan"</span>
             port=<span class="code-quote">"5222"</span>
             user=<span class="code-quote">"lhein"</span>
             password=<span class="code-quote">"myPassword"</span>
             createAccount=<span class="code-quote">"false"</span> 
             participant=<span class="code-quote">"gertv@my.jabberserver.lan"</span>
/&gt; 
</pre>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>XMPP Sender (Provider) Endpoint (Multi User
Chat Room)</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;xmpp:sender service=<span class="code-quote">"test:myJabberService"</span>

             endpoint=<span class="code-quote">"senderEndpoint"</span>
             host=<span class="code-quote">"my.jabberserver.lan"</span>
             port=<span class="code-quote">"5222"</span>
             user=<span class="code-quote">"lhein"</span>
             password=<span class="code-quote">"myPassword"</span>
             createAccount=<span class="code-quote">"false"</span> 
             room=<span class="code-quote">"smxchat@conference.my.jabberserver.lan"</span>
/&gt; 
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>XMPP Sender
Endpoint Attributes</b><br /><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name 		</th>
<th class='confluenceTh'> Type 	</th>
<th class='confluenceTh'> Description 							</th>
<th class='confluenceTh'> Default 		</th>
</tr>
<tr>
<td class='confluenceTd'> host  		                </td>
<td class='confluenceTd'> string	</td>
<td class='confluenceTd'> sets the host name or ip adress of the XMPP server		     
  </td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> port                  		</td>
<td class='confluenceTd'> int   	</td>
<td class='confluenceTd'> the port number of the XMPP service    				</td>
<td class='confluenceTd'> 5222			</td>
</tr>
<tr>
<td class='confluenceTd'> user                  		</td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user name of the XMPP account        				</td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> password		                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the password of the XMPP account                        	
</td>
<td class='confluenceTd'> null (must be spec'd)	</td>
</tr>
<tr>
<td class='confluenceTd'> resource                              </td>
<td class='confluenceTd'> String        </td>
<td class='confluenceTd'> the name of the resource / client                        
            </td>
<td class='confluenceTd'> null                  </td>
</tr>
<tr>
<td class='confluenceTd'> participant  		                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the name of the person to chat with (if you specify this,
leave room null)   </td>
<td class='confluenceTd'> null	</td>
</tr>
<tr>
<td class='confluenceTd'> room      		                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> full room name (if you specify this, leave participant null)
         </td>
<td class='confluenceTd'> null 	                </td>
</tr>
<tr>
<td class='confluenceTd'> proxyHost     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the hostname of the proxy to use                      		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyPort     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the port of the proxy to use                           		</td>
<td class='confluenceTd'> 3128		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyUser     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user name for the proxy to use                      	
</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyPass     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the user password for the proxy to use                   
  		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> proxyType     	                </td>
<td class='confluenceTd'> String	</td>
<td class='confluenceTd'> the proxy type to use (NONE, HTTP, SOCKS4, SOCKS5)       
   		</td>
<td class='confluenceTd'> null		        </td>
</tr>
<tr>
<td class='confluenceTd'> login           	                </td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> a flag if the user should login to the XMPP account      
   		</td>
<td class='confluenceTd'> true		        </td>
</tr>
<tr>
<td class='confluenceTd'> createAccount     	                </td>
<td class='confluenceTd'> boolean	</td>
<td class='confluenceTd'> a flag if an account should be created for unknown users 
   		</td>
<td class='confluenceTd'> false		        </td>
</tr>
<tr>
<td class='confluenceTd'> marshaler                             </td>
<td class='confluenceTd'> class         </td>
<td class='confluenceTd'> a marshaler class which converts XMPP to NMSG            
            </td>
<td class='confluenceTd'> DefaultXMPPMarshaler  </td>
</tr>
</tbody></table>
</div>
</td></tr></table></div>

<h2><a name="servicemix-xmpp-Marshalers"></a>Marshalers</h2>

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

<h3><a name="servicemix-xmpp-Themarshalerinterfacemethods"></a>The marshaler
interface methods</h3>
<p>For providing your own marshaler you only need to implement two methods:</p>

<h4><a name="servicemix-xmpp-toJBI%28...%29"></a>toJBI(...)</h4>
<p>This method is responsible for translating a received XMPP message into a jbi compliant
normalized message ready to be sent to the bus.</p>


<h4><a name="servicemix-xmpp-fromJBI%28...%29"></a>fromJBI(...)</h4>
<p>This method is responsible for translating a received normalized message into a XMPP
message ready to be sent to the mail server.</p>


<p>After finishing your marshaler you can simply configure your endpoints to use it:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Marshaler example</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
&lt;xmpp:receiver service=<span class="code-quote">"test:myJabberService"</span>
               endpoint=<span class="code-quote">"receiverEndpoint"</span>
               targetService=<span class="code-quote">"test:myJabberProcessor"</span>
               host=<span class="code-quote">"my.jabberserver.lan"</span>
               port=<span class="code-quote">"5222"</span>
               user=<span class="code-quote">"lhein"</span>
               password=<span class="code-quote">"myPassword"</span>
               createAccount=<span class="code-quote">"false"</span>  
               room=<span class="code-quote">"smxchat@conference.my.jabberserver.lan"</span>
&gt;

    <span class="code-tag">&lt;property name=<span class="code-quote">"marshaler"</span>&gt;</span>
        <span class="code-tag">&lt;bean class=<span class="code-quote">"com.mycompany.MyXMPPMarshaler"</span>
/&gt;</span>
    <span class="code-tag">&lt;/property&gt;</span>

<span class="code-tag">&lt;/xmpp:receiver&gt;</span>
</pre>
</div></div>

<h3><a name="servicemix-xmpp-Links"></a>Links</h3>

<ul>
	<li><a href="http://www.igniterealtime.org/projects/smack/index.jsp" class="external-link"
rel="nofollow">Smack API</a> the client side XMPP API</li>
	<li><a href="http://www.igniterealtime.org/projects/openfire/index.jsp" class="external-link"
rel="nofollow">OpenFire</a> the GPL Jabber server</li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SM/servicemix-xmpp">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=39132&revisedVersion=11&originalVersion=10">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SM/servicemix-xmpp?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message