JBoss JMS远程队列?

时间:2009-12-14 12:59:53

标签: jboss jms message-queue

我想将消息发送到远程队列?我应该做什么步骤 我找不到任何相关的文件? 谁都可以帮忙? ?

2 个答案:

答案 0 :(得分:6)

在$ {JBOSS_CONF} /deploy/messaging/jms-ds.xml中添加另一个“JMSProvider”。我在此示例中使用提供程序名称“RemoteJMSProvider”:

<!-- Remote JMS Server-->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
  name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=your_remote_host">
    <attribute name="ProviderName">RemoteJMSProvider</attribute>
    <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
    <!-- The connection factory -->
    <attribute name="FactoryRef">XAConnectionFactory</attribute>
    <!-- The queue connection factory -->
    <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
    <!-- The topic factory -->
    <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
    <!-- Connect to JNDI on the host "the-remote-host-name" port 1099-->
    <attribute name="Properties">
       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
       java.naming.factory.url.pkgs=org.jnp.interfaces
       java.naming.provider.url=your_remote_host:1099
    </attribute>

接下来,添加“远程连接工厂”:

<tx-connection-factory>
  <jndi-name>RemoteJMSConnectionFactory</jndi-name>
  <xa-transaction/>
  <rar-name>jms-ra.rar</rar-name>
  <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
  <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
  <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/RemoteJMSProvider</config-property>
  <max-pool-size>20</max-pool-size>
  <security-domain-and-application>JmsXARealm</security-domain-and-application>
  <depends>jboss.messaging:service=ServerPeer</depends>

现在,只要您创建对“RemoteJMSFactory”的连接工厂引用,就会在远程服务器上查找您引用的任何队列:

ConnectionFactory factory =(ConnectionFactory)JNDIContext.lookup("java:/RemoteJMSConnectionFactory");
queue = (Destination) JNDIContext.lookup("queue/myqueue");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(queue);
sender.send(jmsMessage);

另见: http://community.jboss.org/wiki/HowDoIConfigureAnMDBToTalkToARemoteQueue

答案 1 :(得分:0)

查看jboss安装的docs / examples。连接到远程队列所需的唯一更改是设置初始上下文以引用远程appserver的JNDI端口。