我有一个将消息发送到服务器和服务器通过 qpid 消息接收它的工作示例。这是发送到服务器的简单 hello world :
这是接收请求并发送响应的服务器(当前客户端未收到响应):
这是我的属性文件:
它们都工作得很好,我可以通过 Qpid JMX 管理控制台看到 qpid 队列中的消息。这些示例是从https://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/example下载的(可能也有人需要它)。
我之前使用 spring 完成了 Jboss 消息传递,但我无法用 qpid 做同样的事情。在 applicationsContext 中使用 jboss,我有 bean jndiTemplate、conectionFactory、destinationQueue 和 jmscontainer,如下所示:
<!-- Queue configuration -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
<prop key="java.naming.security.principal">admin</prop>
<prop key="java.naming.security.credentials">admin</prop>
</props>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="ConnectionFactory" />
</bean>
<bean id="queueDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName">
<value>queue/testQueue</value>
</property>
</bean>
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="queueDestination" />
<property name="messageListener" ref="listener" />
</bean>
当然还有发送者和监听者:
<bean id="sender" class="com.practice.Sender">
<property name="connectionFactory" ref="connectionFactory" />
<property name="queueDestination" ref="queueDestination" />
</bean>
<bean id="listener" class="com.practice.MsgListener" />
现在我想使用 spring 上下文逻辑重写这个 qpid 示例。谁能帮我?