为单个 Liberty 服务器配置发布/预订消息传递
在单个 Liberty 服务器上,可以配置从主题空间进行发布/预订消息传递。
过程
- 在 server.xml 文件中配置消息传递功能部件。如果要执行 JNDI 查找,那么还必须添加 jndi-1.0 功能部件。
<featureManager> <feature>wasJmsServer-1.0</feature> <feature>wasJmsClient-2.0</feature> <feature>jndi-1.0</feature> </featureManager>
- 配置消息传递引擎以创建一个称为 SPORTS 的主题空间,如以下示例中所示。
<messagingEngine> <topicSpace id="SPORTS" forceReliability="ReliablePersistent" maintainStrictOrder="true" maxMessageDepth="5000"> </topicSpace> </messagingEngine>
- 声明主题连接工厂资源以创建与消息传递引擎的连接,如以下示例中所示。
<jmsTopicConnectionFactory jndiName="jms/libertyTCF" connectionManagerRef="ConMgr1"> <properties.wasJms clientID="clientId" nonPersistentMapping="ExpressNonPersistent" password="password" persistentMapping="ReliablePersistent"/> </jmsTopicConnectionFactory> <connectionManager id="ConMgr1" maxPoolSize="2"/>
- 声明主题空间资源,以创建与 TopicSpace SPORTS 的发布者/订户会话。
<jmsTopic jndiName="jms/libertyTopic"> <properties.wasJms topicName="Cricket" deliveryMode="Application" timeToLive="500000" priority="1" readAhead="AsConnection" /> </jmsTopic>
- 对 Liberty 上部署的消息驱动的 bean 声明激活规范。消息驱动的 bean 使用激活规范以异步使用发布至 jmsTopic 资源的消息。
<jmsActivationSpec id="JMSSample/JMSApp/SampleMDB"> <properties.wasJms destinationRef="jms/libertyTopic" /> </jmsActivationSpec>
标识值必须按以下格式给出:application name/module name/bean name format,其中 application name 是所部署应用程序的名称,module name 是打包该 bean 的模块的名称,bean name 是企业 bean 的 ejb-name。请确保 destinationRef 属性指向有效 jmsTopic 资源标识。注: 仅当该 bean 打包到 EAR 文件中时,应用程序名称才适用。 - 可选: 可以配置 wasJmsSecurity-1.0 功能部件,以使 wasJmsServer-1.0 功能部件能以安全方式工作。有关更多信息,请参阅对 Liberty 启用安全 JMS 消息传递。 为主题队列配置了发布/预订消息传递。
相关任务:

文件名:twlp_msg_single_pubsub.html