2014-05-20 90 views
1

我錯過了爲JMS隊列服務配置的JBoss AS 7.1.1 standlone.xml。在Java中用於發送隊列消息jboss 7.1.1 jndi的最終配置

<subsystem xmlns="urn:jboss:domain:messaging:1.1"> 
    <hornetq-server> 
     <persistence-enabled>true</persistence-enabled> 
     <journal-file-size>102400</journal-file-size> 
     <journal-min-files>2</journal-min-files> 
     <security-enabled>false</security-enabled> 
     <connectors> 
      <netty-connector name="netty" socket-binding="messaging"/> 
      <netty-connector name="netty-throughput" socket-binding="messaging-throughput"> 
       <param key="batch-delay" value="50"/> 
      </netty-connector> 
      <in-vm-connector name="in-vm" server-id="0"/> 
     </connectors> 
     <acceptors> 
      <netty-acceptor name="netty" socket-binding="messaging"/> 
      <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> 
       <param key="batch-delay" value="50"/> 
       <param key="direct-deliver" value="false"/> 
      </netty-acceptor> 
      <in-vm-acceptor name="in-vm" server-id="0"/> 
     </acceptors> 
     <security-settings> 
      <security-setting match="#"> 
       <permission type="send" roles="guest"/> 
       <permission type="consume" roles="guest"/> 
       <permission type="createNonDurableQueue" roles="guest"/> 
       <permission type="deleteNonDurableQueue" roles="guest"/> 
      </security-setting> 
     </security-settings> 
     <address-settings> 
      <address-setting match="#"> 
       <dead-letter-address>jms.queue.DLQ</dead-letter-address> 
       <expiry-address>jms.queue.ExpiryQueue</expiry-address> 
       <redelivery-delay>0</redelivery-delay> 
       <max-size-bytes>10485760</max-size-bytes> 
       <address-full-policy>BLOCK</address-full-policy> 
       <message-counter-history-day-limit>10</message-counter-history-day-limit> 
      </address-setting> 
     </address-settings> 
     <jms-connection-factories> 
      <connection-factory name="InVmConnectionFactory"> 
       <connectors> 
        <connector-ref connector-name="in-vm"/> 
       </connectors> 
       <entries> 
        <entry name="java:/ConnectionFactory"/> 
       </entries> 
      </connection-factory> 
      <connection-factory name="RemoteConnectionFactory"> 
       <connectors> 
        <connector-ref connector-name="netty"/> 
       </connectors> 
       <entries> 
        <entry name="RemoteConnectionFactory"/> 
        <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/> 
       </entries> 
      </connection-factory> 
      <pooled-connection-factory name="hornetq-ra"> 
       <transaction mode="xa"/> 
       <connectors> 
        <connector-ref connector-name="in-vm"/> 
       </connectors> 
       <entries> 
        <entry name="java:/JmsXA"/> 
       </entries> 
      </pooled-connection-factory> 
     </jms-connection-factories> 
     <jms-destinations> 
      <jms-queue name="testQueue"> 
       <entry name="queue/MyQueue"/> 
      </jms-queue> 
      <jms-topic name="testTopic"> 
       <entry name="topic/MyTopic"/> 
      </jms-topic> 
     </jms-destinations> 
    </hornetq-server> 
</subsystem> 

我的屬性代碼

Properties props = new Properties(); 
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
props.put(Context.PROVIDER_URL, "remote://localhost:4447"); 
props.put(Context.SECURITY_PRINCIPAL, "user"); 
props.put(Context.SECURITY_CREDENTIALS, "pass"); 

//用戶名/密碼是ManagementRealm的usrname /密碼

我用Java代碼隊列的發送消息和編碼之前我測試屬性JNDI查找連接。

InitialContext initialContext = new InitialContext(props); 
// Context initialContext=new InitialContext(props); 
ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("jms/RemoteConnectionFactory"); 
System.out.println("connection success"); 

我沒有得到連接我也沒有得到任何錯誤。

如果我用下面的屬性然後我沒有得到錯誤是

Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]........etc 
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming"); 
props.setProperty("java.naming.provider.url", "remote://localhost:4447"); 

任何建議或任何其他的想法是Googleing也。請在我的代碼中保存我的日子或任何mi堆棧,並使用spring 3.0.1。

+0

你有[閱讀DOC(http://docs.jboss.org/hornetq/2.2.5.Final /user-manual/en/html/using-jms.html#d0e1227)?這個'remote://'是什麼?根據鏈接配置您的jndi屬性並再次檢查。 –

回答