tigase增加离线消息和保存历史记录

http://www.verydemo.com/article_c81_i83197.html
 
init.properties增加配置
--comp-name-1=message-archive
--comp-class-1=tigase.archive.MessageArchiveComponent

message-archive/archive-repo-uri=jdbc:mysql://192.168.1.15:3306/tigasedb?user=tigase&password=tigase&useUnicode=true&characterEncoding=UTF-8

--sm-plugins=+message-archive-xep-0136
sess-man/plugins-conf/message-archive-xep-0136/component-jid=message-archive@s3-1

sess-man/plugins-conf/message-archive-xep-0136/default-store-method=body
sess-man/plugins-conf/message-archive-xep-0136/required-store-method=body


历史记录全部保存,和记录类型指定为body,修改类MessageArchivePlugin

//~--- get methods ----------------------------------------------------------

	private boolean getAutoSave(final XMPPResourceConnection session)
					throws NotAuthorizedException {
		/** comment by guahao
		if (requiredStoreMethod != StoreMethod.False)
			return true;
		
		Boolean auto = (Boolean) session.getCommonSessionData(ID + "/" + AUTO);

		if (auto == null) {
			try {
				String data = session.getData(SETTINGS, AUTO, "false");

				auto = Boolean.parseBoolean(data);
				session.putCommonSessionData(ID + "/" + AUTO, auto);
			} catch (TigaseDBException ex) {
				log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
						.getMessage());
				auto = false;
			}
		}

		return auto;
		**/
		//modified for all save;
		return true;
	}

	private StoreMethod getStoreMethod(XMPPResourceConnection session) 
					throws NotAuthorizedException {
		/**comment by guahao
		StoreMethod save = (StoreMethod) session.getCommonSessionData(ID + "/" + DEFAULT_SAVE);
		
		if (save == null) {
			try {
				String data = session.getData(SETTINGS, DEFAULT_SAVE, defaultStoreMethod.toString());

				save = StoreMethod.valueof(data);
				session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
			} catch (TigaseDBException ex) {
				log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
						.getMessage());
				save = StoreMethod.False;
			}			
		}

		if (save.ordinal() < requiredStoreMethod.ordinal()) {
			save = requiredStoreMethod;
			session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
			try {
				setStoreMethod(session, save);
			} catch (TigaseDBException ex) {
				log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
			}
		}
		return save;
		**/
		
		StoreMethod save = requiredStoreMethod;
		session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
		try {
			setStoreMethod(session, save);
		} catch (TigaseDBException ex) {
			log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
		}
		return save;
	}


知道这个后,你会知道,并非安装了message-archive 组件后,日志就可以记录了;而是要客户端允许了;

那么如何安装?

把message-archive.jar 拷贝到 jars/tigase-message-archiving.jar 然后再 etc/init.properties 写下如下配置;

####begin

--comp-name-1=m



参考如下文章一切ok

http://hi.baidu.com/bngoogle/archive/tag/tigase

https://projects.tigase.org/projects/message-archiving/wiki/Configuration


https://projects.tigase.org/projects/message-archiving/wiki/Configuration

Configuration

Basic configuration

Below is example configuration required by component:

--comp-name-3=message-archive
--comp-class-3=tigase.archive.MessageArchiveComponent

message-archive/archive-repo-uri=jdbc:mysql://localhost/messagearchivedb?user=test&password=test

--sm-plugins=message-archive-xep-0136
sess-man/plugins-conf/message-archive-xep-0136/component-jid=message-archive@local-machine-name

In this example configuration is passed connection string to database (if connection string is empty default user repository will be used as database to store archived messages) and JID of message archive component.

If component-jid option is omitted message-archive@local-machine-name will be used as component-jid.

Additional options

We added following additional features, which are available since 1.0.1 release.

Setting default value of archiving level for messages on a server

Settting this property will change default archiving level for messages for every account on server for which per account default archiving level is not set. User will be able to change this value setting default modes as described in XEP-0136 section 2.4

Example in which we set default server message archiving level to message:

sess-man/plugins-conf/message-archive-xep-0136/default-store-method=message

Setting required value of archiving level for messages on a server

Settting this property will change required archiving level for messages for every account on server. User will be able to change this to any lower value by setting default modes as described in XEP-0136 section 2.4, but user will be allowed to set higher archiving level. If this property is set to higher value then default archiving level is set then this setting will be used as default archiving level setting.

Example in which we set required server message archiving level to body:

sess-man/plugins-conf/message-archive-xep-0136/required-store-method=body


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值