Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
Hi All!

I posted a question in the JBoss forums:
https://developer.jboss.org/thread/278535
<https://developer.jboss.org/thread/278535>  

But thought I might get a little quicker help here.  The problem I am having
and trying to solve is that as per that article I had originally gone the
route of trying to bundle the JBoss EAP 6 related libraries with the EJB
application and specifying the following in the EAR
jboss-deployment-structure:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclude-subsystems>
            <subsystem name="messaging-activemq"></subsystem>
        </exclude-subsystems>
        <exclusions>
            <module name="javax.jms.api"></module>
            <module name="org.jboss.ejb"></module>
            <module name="org.jboss.as.remoting"></module>
        </exclusions>
    </deployment>
</jboss-deployment-structure>

Which works on initial deployment however when I restart the server I get
the following exception when trying to send a JMS message so it appears that
the jboss-deployment-structure isn't always being honored.  I also end up
getting that exception at random intervals (a day, days or weeks later) and
when it occurs all future JMS messages fail to be sent almost as if JBoss
forgets the application is supposed to be using its own libraries.

Caused by: java.lang.LinkageError: loader constraint violation: when
resolving method
"org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/remoting3/Connection;)V"
the class loader (instance of org/jboss/modules/ModuleClassLoader) of the
current class,
org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and
the class loader (instance of org/jboss/modules/ModuleClassLoader) for the
method's defining class, org/jboss/ejb/client/EJBClientContext, have
different Class objects for the type org/jboss/remoting3/Connection used in
the signature

So as per that same forum post, I'm now trying to use Red Hats overly
simplified (at least to me) example here:
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuring_messaging/messaging_forward_and_backward_compatiblity#messaging_backward_compatiblity
<https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuring_messaging/messaging_forward_and_backward_compatiblity#messaging_backward_compatiblity>  

But since I was using JNDI - I'm really confused as to how to setup the
connection factory and queue - does anyone by chance have a working example?
I can add all the code after I clean it up a bit if it helps!

Thank you!

Jay




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

jbertram
This looks more like an application server issue than a message broker
issue (whether that's ActiveMQ Artemis or HornetQ).  If you could (mostly)
eliminate the application server from the picture and narrow down your
question to just the broker and/or broker client you may get some help on
this list otherwise I think your best bet is the application server forum.


Justin

On Tue, Aug 7, 2018 at 12:22 PM, JGlass <[hidden email]> wrote:

> Hi All!
>
> I posted a question in the JBoss forums:
> https://developer.jboss.org/thread/278535
> <https://developer.jboss.org/thread/278535>
>
> But thought I might get a little quicker help here.  The problem I am
> having
> and trying to solve is that as per that article I had originally gone the
> route of trying to bundle the JBoss EAP 6 related libraries with the EJB
> application and specifying the following in the EAR
> jboss-deployment-structure:
> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
>     <deployment>
>         <exclude-subsystems>
>             <subsystem name="messaging-activemq"></subsystem>
>         </exclude-subsystems>
>         <exclusions>
>             <module name="javax.jms.api"></module>
>             <module name="org.jboss.ejb"></module>
>             <module name="org.jboss.as.remoting"></module>
>         </exclusions>
>     </deployment>
> </jboss-deployment-structure>
>
> Which works on initial deployment however when I restart the server I get
> the following exception when trying to send a JMS message so it appears
> that
> the jboss-deployment-structure isn't always being honored.  I also end up
> getting that exception at random intervals (a day, days or weeks later) and
> when it occurs all future JMS messages fail to be sent almost as if JBoss
> forgets the application is supposed to be using its own libraries.
>
> Caused by: java.lang.LinkageError: loader constraint violation: when
> resolving method
> "org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/
> remoting3/Connection;)V"
> the class loader (instance of org/jboss/modules/ModuleClassLoader) of the
> current class,
> org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and
> the class loader (instance of org/jboss/modules/ModuleClassLoader) for the
> method's defining class, org/jboss/ejb/client/EJBClientContext, have
> different Class objects for the type org/jboss/remoting3/Connection used in
> the signature
>
> So as per that same forum post, I'm now trying to use Red Hats overly
> simplified (at least to me) example here:
> https://access.redhat.com/documentation/en-us/red_hat_
> jboss_enterprise_application_platform/7.0/html/configuring_
> messaging/messaging_forward_and_backward_compatiblity#messaging_backward_
> compatiblity
> <https://access.redhat.com/documentation/en-us/red_hat_
> jboss_enterprise_application_platform/7.0/html/configuring_
> messaging/messaging_forward_and_backward_compatiblity#messaging_backward_
> compatiblity>
>
> But since I was using JNDI - I'm really confused as to how to setup the
> connection factory and queue - does anyone by chance have a working
> example?
> I can add all the code after I clean it up a bit if it helps!
>
> Thank you!
>
> Jay
>
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
Hi Justin!  Nice to hear from you again - hope all is well!  It does seem to
be an application server issue, if I run the code standalone in eclipse,
everything works fine but when it was deployed to JBoss EAP 7 - JBoss didnt
like any of the JBoss 6 related jars so I had to try and exclude the
messaging sub system which sort of worked except for the random failures.

I dont mind eliminating the app server from the picture as right now I'm
just trying to get the code to run in eclipse without an app server and
thats where I'm running into issues.  Let me clean up the code and possibly
someone here can explain what I might be doing wrong!  Last resort is a Red
Hat ticket as I think it would be beneficial for them to give an example for
others as well.  I'll follow up with the code.  Thanks again for the quick
reply!

Jay



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
In reply to this post by jbertram
This is the code I'm trying - currently just trying to run it from eclipse -
but it's also technically an EJB being deployed in an EAR (not really
important at the moment)

I'm also going to try and attach it for easier reading like in notepad++
TestSender2.java
<http://activemq.2283324.n4.nabble.com/file/t379195/TestSender2.java>  

*I tried to comment the changes made for Artemis per the Red Hat post/link:*
package net.myco.utility;

import java.io.StringReader;
import java.util.Properties;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Stateless;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

@Startup
@Singleton
//@Stateless
public class TestSender2 {

    /**
     * Default constructor.
     */
    public TestSender2() {
        // TODO Auto-generated constructor stub
    }
   
    public static void main(String [] args){
    System.out.println("Trying to Send message");
    sendJMSMessage("myself", "<testXML>Hello IAT</testXML>");
    System.out.println("Sent message");
    }
   
    /*
     * This is just for testing in JBoss when the app is first deployed
     */
    @PostConstruct
    public void autoSendMessage(){
    System.out.println("Trying Auto Send message");
    sendJMSMessage("myself", "<testXML>Hello IAT Auto</testXML>");
    System.out.println("Auto sent message");
    }
   
    public static boolean sendJMSMessage(String caller, String xml) {
                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->For " +
caller + " with:\r\n" + xml);
               
                /////////////////////
                QueueSender sender = null;
        QueueSession session = null;
        QueueConnectionFactory factory = null;
        QueueConnection queueConnection = null;
        Context ctx = null;
        Queue queue1 = null;
        try {

            String jndiProps =
                   
"java.naming.factory.url.pkgs=org.jboss.ejb.client.naming\n"
                    //J.G. EAP 7 test change, this works if JBoss EAP 6 jars
are included
            //+
"java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory\n"
            //Artemis change
            +
"java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory\n"
            //Below works fine in standalone java app with no Artemis but
JBoss 6 libraries
            //+ "java.naming.provider.url=remote://10.140.40.157:30202\n"
            //this may not be needed - but Artemis change
            + "java.naming.provider.url=tcp://10.140.40.157:30202\n"
//according to a post, you dont use the naming/remoting you use the
messaging port
            //Artemis change - addition
            +
"connectionFactory.jms/ConnectionFactory=tcp://10.140.40.157:30206\n"
            //Artemis change - addition
            +
"jms.NotificationQueue=java:/com/vendor/samp/imp/mycompany/ejb/NotificationQueue\n"
            + "java.naming.security.principal=samp.abcd1\n"
                    + "java.naming.security.credentials=PW_abcd1\n"
                    + "jboss.naming.client.ejb.context=true\n"
                    //Artemis change - addition
                    +
"protocolManagerFactoryStr=org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory\n"
                    +
"jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=true\n"
                    +
"jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER\n"
                    +
"jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false\n"
                    +
"jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS=true\n"
                    +
"jboss.naming.client.remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=true";

            Properties props = new Properties();
            props.load(new StringReader(jndiProps));
           
            /*
             * TODO - investigate, research or post question to jboss forums
as this throws an exception of " EJBCLIENT000405: An EJB client context is
already
             * registered for EJB client context identifier [Named EJB
client context identifier: RemoteNamingEJBClientContext"
             *
             * For now add try/catch as it doesnt seem fatal
             */
            try{
            ctx = new InitialContext(props);
            }catch(Exception e){
           
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Caught
exception: " + e.getMessage());
            e.printStackTrace();
            }
           
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Created
initial context");
           
           
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Creating
Factory");
                        if(ctx != null){
                    //Artemis change - Red Hat says you shouldnt need the below if
not using administered objects, e.g. jndi
                    //factory = (QueueConnectionFactory)
ctx.lookup("java:/System/Vendor/ApplicationType/Management/Application/6-1;2-0;ZZZ/Comp/QueueConnectionFactory");
                    factory = (QueueConnectionFactory)
ctx.lookup("jms/ConnectionFactory");
                   
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Created
Factory");
                   
                   
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->looking up
queue");
                                //Artemis change
                    //queue1 = (Queue)
ctx.lookup("java:/com/vendor/samp/imp/mycompany/ejb/NotificationQueue");
                    queue1 = (Queue) ctx.lookup("jms/NotificationQueue");
                                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->looked up
queue");
                               
                                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Creating
queue connection");
                                queueConnection = factory.createQueueConnection("samp.csra1",
"PW_csra1");
                                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Created
queue connection");
                               
                       
System.out.println("InterceptorJMSSigmaProducer:->sendJMSMessage:->Creating
queue session");
                                session = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
                                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Created
queue session");
       
                    queueConnection.start();
                               
                   
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Started the
queue connection");
       
                                sender = session.createSender(queue1);
       
                                System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Created
Sender");
                               
                                // create and send the message
                    TextMessage objectMessage = session.createTextMessage(xml);
                    sender.send(objectMessage);
                   
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Sent
Message");
            }else{
            System.out.println("Context is null");
            }
        } catch (NamingException e) {
       
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->NamingException
" + e.getMessage() + " - Could not send message");
            e.printStackTrace();
        } catch (Exception e) {
       
System.out.println("InterceptorJMSSigmaProducer:->sendJMSMessage:->Exception
caught in try: " + e.getMessage());
            e.printStackTrace();
        } finally {
        try{
        if (sender != null) { sender.close(); }
        if (session !=null) { session.close(); }
        if (queueConnection != null){ queueConnection.close(); }
        if (ctx != null) { ctx = null; }
        }catch(Exception e){
       
System.out.println("InterceptorJMSProducer:->sendJMSMessage:->Exception
caught in Finally: " + e.getMessage());
        }
        }

                return false;
        }
   
   
}

*The console output is:*
Trying to Send message
InterceptorJMSProducer:->sendJMSMessage:->For myself with:
<testXML>Hello IAT</testXML>
InterceptorJMSProducer:->sendJMSMessage:->Created initial context
InterceptorJMSProducer:->sendJMSMessage:->Creating Factory
InterceptorJMSProducer:->sendJMSMessage:->Created Factory
InterceptorJMSProducer:->sendJMSMessage:->looking up queue
InterceptorJMSProducer:->sendJMSMessage:->NamingException NotificationQueue
- Could not send message
javax.naming.NameNotFoundException: NotificationQueue
Sent message
        at
org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:241)
        at
org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:277)
        at
org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:245)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at net.myco.utility.TestSender.sendJMSMessage(TestSender.java:120)
        at net.myco.utility.TestSender.main(TestSender.java:39)


I also have -Djavax.net.debug=all on, and *nothing* is being output so I'm
pretty sure it's not even connecting to the remote server.

Of, note, my classpath includes:
<http://activemq.2283324.n4.nabble.com/file/t379195/Artemis.png>

And my apologies, the formatting (indention) got a little messed up.






--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
In reply to this post by jbertram
Done banging my head on this and trying all sorts of different things -
opening a Red Hat Support ticket ;-(  If they provide a working example I'll
post it here if I'm allowed!



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

jbertram
This slipped off my radar, but I just had a quick look at your code.  The
JNDI stuff looks like a mish-mash of Wildfly and Artemis implementation
properties.  One important thing to keep in mind here is that the JNDI
implementations between Artemis and Wildfly are completely different and
each requires their own unique property values to be configured
appropriately.  If you're connecting to Wildfly you have to use the
appropriate properties for their JNDI implementation, and if you're
connecting to Artemis you have to use the appropriate properties for our
implementation.  Another thing to keep in mind is the the Wildfly JNDI is a
client/server implementation meaning the JNDI client implementation
actually goes over the network and performs the lookup on the remote
server.  The Artemis JNDI implementation is 100% client-side meaning that
the JNDI client simply instantiates the JMS admin objects (connection
factories, destinations, etc.) without doing any kind of remote lookup.  It
is up to the user to configure the Artemis JNDI properties appropriately so
that it contains the resource JMS admin objects.

I guess my first question about your code would be - are you trying to use
Wildfly or Artemis JNDI?


Justin


On Fri, Aug 10, 2018 at 4:06 PM, JGlass <[hidden email]> wrote:

> Done banging my head on this and trying all sorts of different things -
> opening a Red Hat Support ticket ;-(  If they provide a working example
> I'll
> post it here if I'm allowed!
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
Hi Justin - no problem on the radar!

On your questions, answered inline:


> This slipped off my radar, but I just had a quick look at your code.  The
> JNDI stuff looks like a mish-mash of Wildfly and Artemis implementation
> properties.

J.G.: That would probably be because I hadn't found a working example yet of
Artemis to HornetQ so I was trying to add Artemis JNDI as I found it.  Is
there any documentation on what the HornetQ to Artemis mapping might be?


> One important thing to keep in mind here is that the JNDI
> implementations between Artemis and Wildfly are completely different and
> each requires their own unique property values to be configured
> appropriately.

 

J.G.:  Understood.  So with my current scenario, I'm trying to connect to
HornetQ (EAP 6) but my applications hosted in EAP 7 so would I be using the
Artemis or HornetQ.  The example I found and put in the JBoss forum made it
look as if I could use Artemis but I had to change two values - which I did
- but then I couldnt find a complete example thats why theres some
HornetQ/Wildfly mixed in.


> If you're connecting to Wildfly you have to use the
> appropriate properties for their JNDI implementation, and if you're
> connecting to Artemis you have to use the appropriate properties for our
> implementation.

J.G.:  That seems to have answered the bove question - so I need to use
Wildfly plain old JNDI?

If thats the case Red Hat just said to set(from
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuring_messaging/messaging_forward_and_backward_compatiblity#messaging_backward_compatiblity
<https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuring_messaging/messaging_forward_and_backward_compatiblity#messaging_backward_compatiblity>
):
java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connectionFactory.jms/ConnectionFactory=tcp://legacy server address:5445?
protocolManagerFactoryStr=org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory
queue.jms/myQueue=myQueue

They say the default port is 5445, but my vendors server is listening on
30202 for remoting and 30206 for messaging - could you possibly point me to
where the HornetQ setting might be to verify the port?

Also, they dont mention the other JNDI settings like SASL and SSL?


> Another thing to keep in mind is the the Wildfly JNDI is a
> client/server implementation meaning the JNDI client implementation
> actually goes over the network and performs the lookup on the remote
> server.  The Artemis JNDI implementation is 100% client-side meaning that
> the JNDI client simply instantiates the JMS admin objects (connection
> factories, destinations, etc.) without doing any kind of remote lookup.
> It
> is up to the user to configure the Artemis JNDI properties appropriately
> so
> that it contains the resource JMS admin objects.

J.G.:  Understood on the above.  And I belive some of that was what I was
trying to do - I just have a lot of wrong JNDI settings (and likely some
code thats not needed)


> I guess my first question about your code would be - are you trying to use
> Wildfly or Artemis JNDI?

J.G.:  I'm just trying to get an app thats being forced (in a way) because
its running in EAP 7 with Artemis libraries to be able to communicate
properly with a queue on WildFly/HornetQ EAP 6.  I'm up for suggestions on
what I should be using to properly accomplish this.  It sounds like based on
Red Hats article as well as Artemis documentation that Artemis is backwards
compatible with HornetQ so sounds like I need to use the Artemis JNDI to get
things working properly?

Thanks for your time Justin - as always I appreciate the help and patience.




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis (JBoss EAP 7) to HornetQ (EAP 6) elaboration on RedHat example

JGlass
In reply to this post by jbertram
*Update*
Red Hats having me try a resource adapter from the EAP 7 to the EAP 6 server
but it would still be nice to have a working code example just in case
anyone else runs into the same problem!  I also asked them if they could
help with providing a code example but I have a feeling they'll be bugging
someone on your team for it Justin :-)

Keep you all posted either way.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html