2009-12-14 35 views
5

Tôi muốn gửi tin nhắn đến hàng đợi từ xa? những bước nào tôi nên làm tôi không thể tìm thấy bất kỳ tài liệu nào về điều đó? ai cũng có thể giúp ?? ?Hàng đợi từ xa JBoss JMS?

Trả lời

6

Thêm một "JMSProvider" khác vào $ {JBOSS_CONF} /deploy/messaging/jms-ds.xml của bạn. Tôi sử dụng tên nhà cung cấp "RemoteJMSProvider" trong ví dụ này:

<!-- 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> 

Tiếp theo, thêm một "Nhà máy kết nối từ xa":

<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> 

Bây giờ, bất cứ khi nào bạn tạo ra một liên kết nhà máy tham chiếu đến "RemoteJMSFactory", bất kỳ hàng đợi nào bạn tham chiếu sẽ được tra cứu trên máy chủ từ xa:

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); 

Xem thêm: http://community.jboss.org/wiki/HowDoIConfigureAnMDBToTalkToARemoteQueue

+0

thank u rất nhiều tôi đã thực hiện nó –

+0

Sẽ làm việc này cho Chủ đề từ xa. Tôi đang sử dụng EJB3 MDB trên JBOSS để nghe một chủ đề từ xa trên IBM MQ. –

0

Tìm tài liệu/ví dụ về cài đặt jboss của bạn. Thay đổi duy nhất cần thiết để kết nối với hàng đợi từ xa là thiết lập ngữ cảnh ban đầu của bạn để tham chiếu đến cổng JNDI của máy chủ ứng dụng từ xa.

Các vấn đề liên quan