2017-08-02 6 views
0

2つのWildfly 10サーバーが稼動しており、JbossとHornetで動作するJMSキューがあります。そこに私はすべての設定を廃止し、野生の10のメッセージングのためのデフォルトの設定を得たので、私は正しく接続するためにJMSを取得することはできません。 私は実際に私が欲しいことをしている良い文書や例を見つけていません。私は誰かを助けることを願っています。1つのwildfly 10アプリから別のものへのリモートJMSキューへの接続に問題があります

サーバーサイド

私は、メッセージングの拡張子を取得するには、スタンドアロン・full.xmlを使用するには、サーバーサイドにwildfly 10サーバーを設定しました。ここで

は(何も追加せずにデフォルト)メッセージングに関連するスタンドアロン・full.xmlコンテンツである

<extension module="org.wildfly.extension.messaging-activemq"/> 

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"> 
     <server name="default"> 
      <security-setting name="#"> 
       <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/> 
      </security-setting> 
      <address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/> 
      <http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/> 
      <http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http"> 
       <param name="batch-delay" value="50"/> 
      </http-connector> 
      <in-vm-connector name="in-vm" server-id="0"/> 
      <http-acceptor name="http-acceptor" http-listener="default"/> 
      <http-acceptor name="http-acceptor-throughput" http-listener="default"> 
       <param name="batch-delay" value="50"/> 
       <param name="direct-deliver" value="false"/> 
      </http-acceptor> 
      <in-vm-acceptor name="in-vm" server-id="0"/> 
      <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/> 
      <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/> 
      <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/> 
      <connection-factory name="RemoteConnectionFactory" entries="java:/jms/RemoteConnectionFactory" connectors="http-connector"/> 
      <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/> 
     </server> 
    </subsystem> 

ここで私はキューを定義し、MessageDrivenBeanのを使用してメッセージを受信するために作られたコードは次のとおりです。

@MessageDriven(activationConfig = { 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:app/jms/queue/SecServerQ") 
}) 
@JMSDestinationDefinition(
    name = "java:app/jms/queue/SecServerQ", 
    interfaceName = "javax.jms.Queue", 
    destinationName = "SecServerQ" 
) 
public class SecServerMDB implements MessageListener 
{ 
    public void onMessage(Message message) 
    { 
    // my code here 
    } 
} 

私はwildflyコンソールでキューを見ることができます:

enter image description here

クライアント側

また、私は私のクライアントサーバ上のサーバーサイドconfigfileを等しくスタンドアロン・full.xmlメッセージング]セクションを持っています。

ここでは、サーバー側JMSキューへの接続を取得するために使用するコードを示します。ここで

public class WildFlyJmsQueueSender 
{ 
    private static final Logger log = LoggerFactory.getLogger(WildFlyJmsQueueSender.class); 

    public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory"; 
    public final static String JMS_QUEUE_JNDI="jms/queue/SecServerQ"; 
    public final static String JMS_USERNAME="jmsuser";  // The role for this user is "guest" in ApplicationRealm 
    public final static String JMS_PASSWORD="jms2017Pwd!"; 
    public final static String WILDFLY_REMOTING_URL="http-remoting://secserver.mydomain.com:8080"; 

    public void send(IpcoJmsMessage msg, String msgType) throws NamingException, JMSException { 

    Context namingContext = null; 

    try { 
     namingContext = getInitialContext(); 

     log.debug("Attempting to acquire connection factory {}", JMS_CONNECTION_FACTORY_JNDI); 
     ConnectionFactory conFactory = (ConnectionFactory) namingContext.lookup(JMS_CONNECTION_FACTORY_JNDI); 
     log.debug("Found connection factory {} in JNDI", JMS_CONNECTION_FACTORY_JNDI); 

     log.debug("Attempting to acquire destination {}", JMS_QUEUE_JNDI); 
     Destination destination = (Destination) namingContext.lookup(JMS_QUEUE_JNDI); 
     log.debug("Found destination {} in JNDI", JMS_QUEUE_JNDI); 

     try (JMSContext context = conFactory.createContext(JMS_USERNAME, JMS_PASSWORD)) { 
     ObjectMessage objMsg = context.createObjectMessage(); 
     objMsg.setObject(msg); 
     objMsg.setStringProperty("msgType", msgType); 

     log.info("Sending message with content msg={}, msgType={}", msg, msgType); 

     context.createProducer().send(destination, objMsg); 
     } 
    } catch (NamingException e) { 
     log.error("NamingException: {} {}", e.getMessage(), e); 
    } finally { 
     if(namingContext != null) { 
     try { 
      namingContext.close(); 
     } catch (NamingException e) { 
      log.error(e.getMessage()); 
     } 
     } 
    } 
    } 

    private static InitialContext getInitialContext() throws NamingException { 
    InitialContext context=null; 
    try { 
     Properties props = new Properties(); 
     props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); 
     props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL); 
     props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME); 
     props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD); 
     context = new InitialContext(props); 

     log.debug("Got initial Context: "+context); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return context; 
    } 

} 

は、私がクライアントで取得例外で:

14:11:04.965 DEBUG [LoggerProviders.java:158] - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 
14:11:04.966 INFO [Version.java:61] - WildFly Naming version 1.0.0.Beta13 
14:11:04.969 DEBUG [WildFlyJmsQueueSender.java:82] - Got initial Context: [email protected] 
14:11:04.969 DEBUG [WildFlyJmsQueueSender.java:42] - Attempting to acquire connection factory jms/RemoteConnectionFactory 
14:11:05.033 INFO [Xnio.java:95] - XNIO version 3.5.0.Beta2 
14:11:05.043 INFO [NioXnio.java:57] - XNIO NIO Implementation Version 3.5.0.Beta2 
14:11:05.069 DEBUG [WorkerThread.java:433] - Started channel thread 'XNIO-1 Accept', selector [email protected] 
14:11:05.069 DEBUG [WorkerThread.java:433] - Started channel thread 'XNIO-1 I/O-1', selector [email protected] 
14:11:05.081 INFO [EndpointImpl.java:97] - JBoss Remoting version 5.0.0.Beta19 
14:11:05.087 DEBUG [WorkerThread.java:433] - Started channel thread 'Remoting (anonymous) I/O-1', selector [email protected] 
14:11:05.087 DEBUG [WorkerThread.java:433] - Started channel thread 'Remoting (anonymous) Accept', selector [email protected] 
14:11:05.141 INFO [Version.java:57] - ELY00001: WildFly Elytron version 1.1.0.Beta33 
14:11:05.382 ERROR [WildFlyJmsQueueSender.java:60] - NamingException: {}WFNAM00018: Failed to connect to remote host 
javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host 
at org.wildfly.naming.client.remote.RemoteNamingProvider.getPeerIdentityForNaming(RemoteNamingProvider.java:65) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.remote.RemoteContext.lambda$lookupNative$0(RemoteContext.java:109) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.NamingProvider.performExceptionAction(NamingProvider.java:99) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.remote.RemoteContext.lookupNative(RemoteContext.java:108) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:78) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:64) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144) ~[wildfly-naming-client-1.0.0.Beta13.jar:1.0.0.Beta13] 
at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_121] 
at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_121] 
at no.ipco.common.WildFlyJmsQueueSender.send(WildFlyJmsQueueSender.java:43) ~[ipco-common-jmsclient-0.1.jar:na] 

答えて

0

私は問題を解決しました。

まず、@ JMSDestinationDefinitionを使用してMessageDrivenBeanサーバーサイドにドロップしました。 代わりにjboss-cliを使ってキューを定義しました。

マイスタンドアロン・full.xml設定ファイルは現在、次の行は、私はポートを切り替え、クライアント側で

<jms-queue name="SecServerQ" entries="jms/queue/SecServerQ java:jboss/exported/jms/queue/SecServerQ"/> 

を追加しました。私は8080(旧ポート)にtelnet接続しようとしましたが、そこにはオープンしていなかったので、代わりに28080を試しました。

public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory"; 
public final static String JMS_QUEUE_JNDI="jms/queue/SecServerQ"; 
public final static String JMS_USERNAME="jmsuser";  // The role for this user is "guest" in ApplicationRealm 
public final static String JMS_PASSWORD="jms2017Pwd!"; 
public final static String WILDFLY_REMOTING_URL="http-remoting://secserver.mydomain.com:28080"; 

この後、クライアントは例外なく接続でき、JMSメッセージが流れ始めました。

関連する問題