生成绑定文件 Message Queue Broker 4.5

Generation of binding file Message Queue Broker 4.5

我是 运行 Tomcat,它创建了一个 DefaultMessageListenerContainer bean。为此,它指的是 connectionFactory bean,它使用 jndiTemplate bean,它使用 imq/imq_admin_objects.

所在的路径

bean定义如下

<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  <property name="connectionFactory" ref="connectionFactory"/>
  <property name="destination" ref="destination"/>
  <property name="messageListener" ref="transactionMessageListener"/>
  <property name="sessionTransacted" value="true"/>
  <property name="concurrentConsumers" value="1"/>
</bean>

<!-- JMS configuration -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
  <property name="environment">
    <props>
      <prop key="java.naming.factory.initial">
        com.sun.jndi.fscontext.RefFSContextFactory
      </prop>
      <prop key="java.naming.provider.url">
        file:///var/imq/imq_admin_objects
      </prop>
    </props>
  </property>
</bean>

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiTemplate" ref="jndiTemplate"/>
  <property name="jndiName" value="factory"/>
</bean>

问题是没有生成这样的文件夹。我正在为 JMS 使用 Message Queue Broker 4.5。在 运行 服务上它只创建一个 var/mq 目录。我期待它生成一个 imq 文件夹,该文件夹将包含用于创建 JMS 的相应绑定文件。

我相信你在这里的期望是不正确的。 com.sun.jndi.fscontext.RefFSContextFactory 引用的文件系统对象存储必须 已经存在 。它不会为您创建它。您必须创建并提供它,以便可以正确初始化 bean 并且 JNDI 查找可以运行。

绑定文件包含 JNDI 查找名称等详细信息以及如何通过网络连接到服务器(例如主机名、端口等)。这些详细信息必须由管理员提供。 JNDI 实现无法自行提出它们。

如果你 browse the "Developer’s Guide for Java Clients" linked from the Open MQ 4.5 Documentation page and inspect chapter 2 titled "Using the Java API" 你会在 "Obtaining a Connection Factory" 部分看到这个:

Typically, a connection factory is created for you by a Message Queue administrator and preconfigured, using the administration tools described in "Administrative Tasks and Tools" in Oracle GlassFish Server Message Queue Administration Guide with whatever property settings are appropriate for connecting to particular JMS provider. The factory is then placed in a publicly available administered object store, where you can access it by name using the Java Naming and Directory Interface (JNDI) API.

在文档的下方,您会找到 an example of how to look up a connection factory object in the JNDI object store。这个示例使用文件系统对象存储,就像你一样,它特别指出:

The directory represented by C:/imq_admin_objects must already exist; if necessary, you must create the directory before referencing it in your code.

简而言之,您必须创建受管理的文件系统对象存储并使其公开可用,以便 JNDI 客户端可以使用它。