Как подключить WildFly к удаленному серверу Artemis - PullRequest
0 голосов
/ 14 мая 2018

У меня есть автономный удаленный сервер Artemis с очередью, и я хочу настроить WildFly для подключения этой очереди через сам WildFly. Версии: WildFly 12.0.0. Финал и Артемида 2.5.0 .

На Артемисе я настроил очередь в broker.xml файл так:

<addresses>
     <address name="DemoQueue">
        <anycast>
           <queue name="DemoQueue" />
        </anycast>
     </address>
</addresses>

Затем я настроил на WildFly фабрику пула соединений , создав:

  • привязка к исходящему сокету , указывающая на удаленный сервер обмена сообщениями
  • a удаленный соединитель , ссылающийся на привязку к исходящему сокету
  • a фабрика соединений пула со ссылкой на разъем дистанционного управления

Моя окончательная конфигурация в standalone-full.xml файле выглядит так:

<server>
    ... 

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        ...
        <outbound-socket-binding name="remote-artemis">
            <remote-destination host="localhost" port="61616"/>
        </outbound-socket-binding>
    </socket-binding-group>

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:3.0">
        <server name="default"> 
            ...
            <remote-connector name="remote-artemis" socket-binding="remote-artemis"/>       
            <pooled-connection-factory name="remote-artemis" entries="java:/jms/RemoteArtemisCF" connectors="remote-artemis"/>
        </server>
    </subsystem>

    <subsystem xmlns="urn:jboss:domain:naming:2.0">
        <bindings>
            <external-context name="java:global/federation/remotequeue" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                <environment>
                    <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                    <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                    <property name="queue.queues/DemoQueue" value="DemoQueue"/>
                </environment>
            </external-context>
            <lookup name="java:/DemoQueue" lookup="java:global/federation/remotequeue/DemoQueue"/>
        </bindings>
        <remote-naming/>
    </subsystem>

</server>

Создание потребителя, как показано ниже, я получил это сообщение на неопределенный срок AMQ151004: Instantiating javax.jms.Queue "DemoQueue" directly since UseJNDI=false.

@ResourceAdapter("remote-artemis")
@MessageDriven(mappedName = "DemoQueue",activationConfig =
{
        @ActivationConfigProperty(propertyName = "useJNDI",         propertyValue = "false"),
        @ActivationConfigProperty(propertyName = "destination",     propertyValue = "DemoQueue"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
})

//@Component
public class Receiver implements MessageListener {
    ...
}

Создав вместо этого получателя, передающего имя JNDI для поиска в очереди, я получил эту ошибку WFLYNAM0062: Failed to lookup DemoQueue [Root exception is java.lang.RuntimeException: javax.naming.NameNotFoundException: DemoQueue].

Это код производителя: Открытый класс Продюсер {

    private Logger logger = LogManager.getLogger(this.getClass());

    @Resource(lookup="java:/jms/RemoteArtemisCF")
    private ConnectionFactory connectionFactory;

    @Resource(lookup="java:/DemoQueue")
    private Queue queue;

    public void simpleSend(String msg) {
        Connection connection = null;
        Session session = null;

        try {
            try {
                connection = connectionFactory.createConnection();
                connection.start();

                // Create a Session
                session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                // Create a MessageProducer from the Session to the Topic or Queue
                MessageProducer producer = session.createProducer(queue);

                // Create a message
                TextMessage message = session.createTextMessage(msg);

                // Tell the producer to send the message
                producer.send(message);
                logger.debug("Message sent");
            } finally {
                // Clean up
                if (session != null) session.close();
                if (connection != null) connection.close();
            }
        } catch (JMSException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

Кто-нибудь может мне помочь найти правильную конфигурацию или исходный код?

Заранее спасибо.

...