Spring中整合xmpp实例
Spring integration项目中有整合xmpp的功能,参见官方文档http://www.springsource.org/spring-integration
Spring integration主要思想是通道(Channel)和消息(Message)以及Message在Channel中传输的若干机制及控制,对于xmpp同样使用。
但是由于官方文档对xmpp的讲解比较粗,也没有完整的例子,因此本文主要目的是以一个工程例子对此进行扩充。
1、配置
一般情况下在web中只要一个spring配置文件,如果在大型项目中,这将显得较为臃肿,因此可以根据功能插件采取分解的的方法。
在web.xml中加入
scan xmpp message neet to be Sent2013-09-06 23:16:00.022 INFO SendMessageService:33 - Send message(How are you 1378480560021) to stephen-13784541229172013-09-06 23:16:00.023 INFO SendMessageService:39 - Send message finish2013-09-06 23:16:00.093 INFO MessageReceiver:21 - handleMessage()2013-09-06 23:16:00.094 INFO MessageReceiver:22 - org.jivesoftware.smack.packet.Message@624fe5db2013-09-06 23:16:00.095 INFO MessageReceiver:25 - messageStr=How are you 1378480560021scan xmpp message neet to be Sent2013-09-06 23:17:00.023 INFO SendMessageService:33 - Send message(How are you 1378480620023) to stephen-13784541229172013-09-06 23:17:00.025 INFO SendMessageService:39 - Send message finish2013-09-06 23:17:00.094 INFO MessageReceiver:21 - handleMessage()2013-09-06 23:17:00.095 INFO MessageReceiver:22 - org.jivesoftware.smack.packet.Message@63cc60782013-09-06 23:17:00.096 INFO MessageReceiver:25 - messageStr=How are you 1378480620023scan xmpp message neet to be Sent2013-09-06 23:18:00.022 INFO SendMessageService:33 - Send message(How are you 1378480680022) to stephen-13784541229172013-09-06 23:18:00.024 INFO SendMessageService:39 - Send message finish2013-09-06 23:18:00.069 INFO MessageReceiver:21 - handleMessage()2013-09-06 23:18:00.070 INFO MessageReceiver:22 - org.jivesoftware.smack.packet.Message@6420ed7d2013-09-06 23:18:00.071 INFO MessageReceiver:25 - messageStr=How are you 1378480680022scan xmpp message neet to be Sent2013-09-06 23:19:00.024 INFO SendMessageService:33 - Send message(How are you 1378480740024) to stephen-13784541229172013-09-06 23:19:00.025 INFO SendMessageService:39 - Send message finish2013-09-06 23:19:00.091 INFO MessageReceiver:21 - handleMessage()2013-09-06 23:19:00.092 INFO MessageReceiver:22 - org.jivesoftware.smack.packet.Message@659d681a2013-09-06 23:19:00.092 INFO MessageReceiver:25 - messageStr=How are you 1378480740024scan xmpp message neet to be Sent2013-09-06 23:20:00.050 INFO SendMessageService:33 - Send message(How are you 1378480800050) to stephen-13784541229172013-09-06 23:20:00.052 INFO SendMessageService:39 - Send message finish2013-09-06 23:20:00.117 INFO MessageReceiver:21 - handleMessage()2013-09-06 23:20:00.118 INFO MessageReceiver:22 - org.jivesoftware.smack.packet.Message@6719e30e2013-09-06 23:20:00.119 INFO MessageReceiver:25 - messageStr=How are you 1378480800050