5

I have a standalone remote Artemis Server with a Queue and I want configure WildFly in order to connect that Queue through WildFly itself. Versions are WildFly 12.0.0.Final and Artemis 2.5.0.

On Artemis I've configured a Queue in broker.xml file like this:

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

Then I've configured on WildFly a pooled-connection-factory creating:

  • an outbound-socket-binding pointing to the remote messaging server
  • a remote-connector referencing the outbound-socket-binding
  • a pooled-connection-factory referencing the remote-connector

My final configuration in standalone-full.xml file is like this:

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

Creating a consumer as below I got this message indefinitely 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 {
    ...
}

Creating instead a consumer passing a JNDI name for lookup the Queue I got this error WFLYNAM0062: Failed to lookup DemoQueue [Root exception is java.lang.RuntimeException: javax.naming.NameNotFoundException: DemoQueue].

This is the code of the producer: public class Producer {

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

Can anybody help me to find the right configuration or source code?

Thanks in advance.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Alessio Fiore
  • 467
  • 1
  • 7
  • 18

1 Answers1

1

I think you just need to add acceptor's prefixes in Artemis broker.xml ( note that every destination needs to be pre-created, as you did for DemoQueue).

<acceptors>
    <acceptor name="artemis">tcp://localhost:61616?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.</acceptor>
</acceptors>

This is a complete pooled-connection-factory configuration in Wildfly standalone-full.xml (note that I'm also using authentication here).

<pooled-connection-factory name="remote-artemis" entries="java:/jms/RemoteArtemisCF" connectors="remote-artemis" ha="true" transaction="xa" user="admim" password="admim" min-pool-size="15" max-pool-size="30" statistics-enabled="true">
    <inbound-config use-jndi="true" jndi-params="java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;java.naming.provider.url=tcp://localhost:61616;java.naming.security.principal=admin;java.naming.security.credentials=admin" rebalance-connections="true" setup-attempts="-1" setup-interval="5000"/>
</pooled-connection-factory>
fvaleri
  • 638
  • 1
  • 4
  • 10