本附录介绍启用 Event Notification Service Publisher (ENS Publisher) 以及管理 Messaging Server 中的 Event Notification Service (ENS) 所需的操作。
本章/附录包含以下各节:
有关 ENS 和 ENS API 的更多信息,请参见《Sun Java System Communications Services 6 2005Q4 Event Notification Service Guide》。
Event Notification Service (ENS) 是基本的发布和订阅服务。ENS 起着分发程序的作用,Sun Java System 应用程序将它用作这些应用程序感兴趣的、某些类型事件的集合的中心点。事件是对资源的一个或多个属性的值所作的更改。任何要了解这些类型的事件何时发生的应用程序将使用 ENS 注册,ENS 按顺序标识事件,并使通知与订阅相匹配。
启动 Messaging Server 时,ENS 和 iBiff(用于 Messaging Server 的 ENS Publisher)被绑定在一起。默认情况下启用了 ENS,但是未装入 iBIFF。(请参见在 Messaging Server 中装入 ENS Publisher。)
要在 Messaging Server 中订阅通知,您需要在 Messaging Server 主机上装入 libibiff 文件,然后停止并重新启动 Messaging Server。
从命令行执行以下步骤。在这些步骤中,Messaging Server 安装目录的位置为 msg_svr_base,Messaging Server 用户为 inetuser。这些变量的典型值分别为 /opt/SUNWmsgsr 和 inetuser。
作为 inetuser 时,请运行 configutil 实用程序以装入 libibiff 文件。
cd msg_svr_base ./configutil -o "local.store.notifyplugin" -v "msg_svr_base/lib/libibiff" |
作为 root 时,请先停止然后重新启动 Messaging Server。
cd msg_svr_base /sbin
./stop-msg
./start-msg
现在准备通过 ENS 接收通知。请参见运行样例 Event Notification Service 程序
Messaging Server 包含帮助您了解如何接收通知的样例程序。这些样例程序位于 msg_svr_base/examples 目录中。
转至 msg_svr_base/examples 目录。
使用 C 编译器编译使用 Makefile.sample 文件的 apub 和 asub 示例。将库搜索路径设置为包含 msg_svr_base/examples 目录。
编译了程序之后,您可以在不同的窗口中按如下所示运行这些程序:
apub localhost 7997
asub localhost 7997
在 apub 窗口中键入的任何内容都应显示在 asub 窗口中。此外,如果您使用默认设置,则所有 iBiff 通知都应显示在 asub 窗口中。
要接收由 iBiff 发布的通知,请写入与 asub.c 类似的程序。
有关样例程序以及编写您自己的用于 ENS 的程序的更多信息,请参见《Sun Java System Communications Services 6 2005Q4 Event Notification Service Guide》。
将库搜索路径设置为包含 msg_svr_base/lib 目录之后,您将不能再停止和启动目录服务器。解决方法是从库搜索路径中删除该条目。
管理 ENS 包括启动和停止该服务以及更改配置参数以控制用于 ENS 的 iBiff Publisher 的性能。
您可以使用 start-msg ens 和 stop-message ens 命令启动和停止 ENS 服务器。您必须是 root 才能运行这些命令。
要启动 ENS,请运行以下命令:
msg_svr_base/sbin/start-msg ens
要停止 ENS,请运行以下命令:
msg_svr_base/sbin/stop-msg ens
若干配置参数控制 iBiff 的性能。可以使用 configutil 实用程序来设置这些参数。
表 B–1 iBiff 配置参数
参数 |
说明 |
---|---|
指定将与通知一起传送的标题的最大大小(以字节为单位)。默认值为 0 字节。 |
|
local.store.notifyplugin.maxBodySize |
指定将与通知一起传送的主体的最大大小(以字节为单位)。默认值为 0 字节。 |
local.store.notifyplugin.eventType.enable |
指定给定的事件类型是否将生成通知。合法值为 1(要启用)和 0(要禁用)。默认值为 1;即,将 local.store.notifyplugin.ReadMsg.enable 设置为 0 将禁用 ReadMsg 通知。 |
local.store.notifyplugin.ensHost |
指定 ENS 服务器的主机名。默认值为 127.0.0.1。 |
local.store.notifyplugin.ensPort |
指定 ENS 服务器的 TCP 端口。默认值为 7997。 |
local.store.notifyplugin.ensEventKey |
指定要用于 ENS 通知的事件密钥。默认值为 enp://127.0.0.1/store。事件密钥的主机名部分不用来确定 ENS 主机。它只是 ENS 所使用的唯一标识符。 此密钥是订户应订阅的,以便获得与该密钥相匹配的事件的通知。 |