How to use ActiveMQ Artemis through HTTP tunnel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use ActiveMQ Artemis through HTTP tunnel

Simon Martinelli, 72 Services LLC
Hi,



I configured a Netty http acceptor in my ActiveMQ Artemis Broker.



According to the Artemis examples I must add ?httpEnabled=true to enable HTTP.

I'm using Spring Boot and create a ActiveMQComponent like this:



@Bean

public ActiveMQComponent  activemqAmazon() {

        ActiveMQComponent activeMQComponent = new ActiveMQComponent();

        activeMQComponent.setBrokerURL("tcp://amazonaws.com:8080?httpEnabled=true");

        return activeMQComponent;

}



But then I get:

javax.jms.JMSException: Could not create Transport. Reason: java.lang.IllegalArgumentException: Invalid connect parameters: {httpEnabled=true}



Any help is appreciated.



Thanks, Simon
Reply | Threaded
Open this post in threaded view
|

Re: How to use ActiveMQ Artemis through HTTP tunnel

Quinn Stevenson
Just a guess - but I don’t think httpEnabled is a valid option for an ActiveMQ openwire connection - at least I don’t see it here http://activemq.apache.org/connection-configuration-uri.html <http://activemq.apache.org/connection-configuration-uri.html>

> On Aug 9, 2018, at 3:05 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>
> Hi,
>
>
>
> I configured a Netty http acceptor in my ActiveMQ Artemis Broker.
>
>
>
> According to the Artemis examples I must add ?httpEnabled=true to enable HTTP.
>
> I'm using Spring Boot and create a ActiveMQComponent like this:
>
>
>
> @Bean
>
> public ActiveMQComponent  activemqAmazon() {
>
>        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
>
>        activeMQComponent.setBrokerURL("tcp://amazonaws.com:8080?httpEnabled=true");
>
>        return activeMQComponent;
>
> }
>
>
>
> But then I get:
>
> javax.jms.JMSException: Could not create Transport. Reason: java.lang.IllegalArgumentException: Invalid connect parameters: {httpEnabled=true}
>
>
>
> Any help is appreciated.
>
>
>
> Thanks, Simon

Reply | Threaded
Open this post in threaded view
|

RE: How to use ActiveMQ Artemis through HTTP tunnel

Simon Martinelli, 72 Services LLC
Hi Quinn,

It's an option of Artemis https://activemq.apache.org/artemis/ to connect to Netty using a HTTP tunnel.

Thanks, Simon

-----Original Message-----
From: Quinn Stevenson <[hidden email]>
Sent: Freitag, 10. August 2018 16:08
To: [hidden email]
Subject: Re: How to use ActiveMQ Artemis through HTTP tunnel

Just a guess - but I don’t think httpEnabled is a valid option for an ActiveMQ openwire connection - at least I don’t see it here http://activemq.apache.org/connection-configuration-uri.html <http://activemq.apache.org/connection-configuration-uri.html>

> On Aug 9, 2018, at 3:05 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>
> Hi,
>
>
>
> I configured a Netty http acceptor in my ActiveMQ Artemis Broker.
>
>
>
> According to the Artemis examples I must add ?httpEnabled=true to enable HTTP.
>
> I'm using Spring Boot and create a ActiveMQComponent like this:
>
>
>
> @Bean
>
> public ActiveMQComponent  activemqAmazon() {
>
>        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
>
>        activeMQComponent.setBrokerURL("tcp://amazonaws.com:8080?httpEnabled=true");
>
>        return activeMQComponent;
>
> }
>
>
>
> But then I get:
>
> javax.jms.JMSException: Could not create Transport. Reason: java.lang.IllegalArgumentException: Invalid connect parameters: {httpEnabled=true}
>
>
>
> Any help is appreciated.
>
>
>
> Thanks, Simon

Reply | Threaded
Open this post in threaded view
|

Re: How to use ActiveMQ Artemis through HTTP tunnel

Quinn Stevenson
If I’m understanding you correctly, you’re trying to create a Camel ActiveMQCompoent - which is a specialized implementation of the Camel JMS component for ActiveMQ 5.x.  So I don’t think you have access to the Netty HTTP transport for Artemis using this component - maybe try Camel JMS?


> On Aug 10, 2018, at 8:21 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>
> Hi Quinn,
>
> It's an option of Artemis https://activemq.apache.org/artemis/ to connect to Netty using a HTTP tunnel.
>
> Thanks, Simon
>
> -----Original Message-----
> From: Quinn Stevenson <[hidden email]>
> Sent: Freitag, 10. August 2018 16:08
> To: [hidden email]
> Subject: Re: How to use ActiveMQ Artemis through HTTP tunnel
>
> Just a guess - but I don’t think httpEnabled is a valid option for an ActiveMQ openwire connection - at least I don’t see it here http://activemq.apache.org/connection-configuration-uri.html <http://activemq.apache.org/connection-configuration-uri.html>
>
>> On Aug 9, 2018, at 3:05 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>>
>> Hi,
>>
>>
>>
>> I configured a Netty http acceptor in my ActiveMQ Artemis Broker.
>>
>>
>>
>> According to the Artemis examples I must add ?httpEnabled=true to enable HTTP.
>>
>> I'm using Spring Boot and create a ActiveMQComponent like this:
>>
>>
>>
>> @Bean
>>
>> public ActiveMQComponent  activemqAmazon() {
>>
>>       ActiveMQComponent activeMQComponent = new ActiveMQComponent();
>>
>>       activeMQComponent.setBrokerURL("tcp://amazonaws.com:8080?httpEnabled=true");
>>
>>       return activeMQComponent;
>>
>> }
>>
>>
>>
>> But then I get:
>>
>> javax.jms.JMSException: Could not create Transport. Reason: java.lang.IllegalArgumentException: Invalid connect parameters: {httpEnabled=true}
>>
>>
>>
>> Any help is appreciated.
>>
>>
>>
>> Thanks, Simon
>

Reply | Threaded
Open this post in threaded view
|

RE: How to use ActiveMQ Artemis through HTTP tunnel

Simon Martinelli, 72 Services LLC
So how do I have to configure the JmsComponent for Artemis?

I didn't find any examples.

Thanks, Simon

Reply | Threaded
Open this post in threaded view
|

Re: How to use ActiveMQ Artemis through HTTP tunnel

Quinn Stevenson
There are quite a few examples of configuring camel-jms in the tests - here’s one that may be close (https://github.com/apache/camel/blob/master/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringJMSTemplate.xml <https://github.com/apache/camel/blob/master/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringJMSTemplate.xml>).

You’ll need to use the Artemis ConnectionFactory (https://activemq.apache.org/artemis/docs/javadocs/javadoc-1.1.0/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.html <https://activemq.apache.org/artemis/docs/javadocs/javadoc-1.1.0/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.html>) rather than the ActiveMQ 5.x connection factory in order to set the httpEnabled property.

HTH

> On Aug 13, 2018, at 9:03 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>
> So how do I have to configure the JmsComponent for Artemis?
>
> I didn't find any examples.
>
> Thanks, Simon
>

Reply | Threaded
Open this post in threaded view
|

RE: How to use ActiveMQ Artemis through HTTP tunnel

Simon Martinelli, 72 Services LLC
Thanks Quinn.

Sending now works with this configuration:

    @Bean
    public ActiveMQComponent activemqAmazon() {
        if (System.getProperty("http.proxyUser") != null) {
            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(System.getProperty("http.proxyUser"), System.getProperty("http.proxyPassword").toCharArray());
                }
            });
        }

        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
        activeMQComponent.setJmsOperations(camelJmsTemplate());
        return activeMQComponent;
    }

    @Bean
    public JmsConfiguration.CamelJmsTemplate camelJmsTemplate() {
        JmsConfiguration jmsConfiguration = new JmsConfiguration();
        JmsConfiguration.CamelJmsTemplate camelJmsTemplate = new JmsConfiguration.CamelJmsTemplate(jmsConfiguration, activeMQConnectionFactory());
        return camelJmsTemplate;
    }

    @Bean
    public ActiveMQConnectionFactory activeMQConnectionFactory() {
        ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://x.eu-central-1.compute.amazonaws.com:8080?httpEnabled=true");
        return activeMQConnectionFactory;
    }

But if I create a route that should consume messages it doesn't

from("activemqAmazon:UnitTopic")
                    .id(UnitTopicRemoteToUnitMasterTopicRoute.class.getSimpleName())
                    .log("Processing: ${body}")
                    .to("activemqLocal:topic:UnitMasterTopic");

I even don't see any connections the management console.

How do I have to configure my endpoint to consume from this topic over http?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How to use ActiveMQ Artemis through HTTP tunnel

Quinn Stevenson
I haven’t ever tried this, so I’m guessing.  But have you tried using the JmsComponent instead of the ActiveMQComponent?


> On Aug 13, 2018, at 10:58 AM, Simon Martinelli, 72 Services LLC <[hidden email]> wrote:
>
> activemqAmazon

Reply | Threaded
Open this post in threaded view
|

RE: How to use ActiveMQ Artemis through HTTP tunnel

Simon Martinelli, 72 Services LLC
Oh you are right! With JmsComponent it works.
Thank you very much for your help.

My config looks like:

   @Bean
    public JmsComponent activemqAmazon() {
        JmsComponent jmsComponent = new JmsComponent();
        jmsComponent.setConnectionFactory(activeMQConnectionFactory());
        return jmsComponent;
    }

    @Bean
    public ActiveMQConnectionFactory activeMQConnectionFactory() {
        ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://x.eu-central-1.compute.amazonaws.com:8080?httpEnabled=true");
        return activeMQConnectionFactory;
    }

And because of the HTTP tunnel I see:

2018-08-13 19:12:17.058  WARN 8924 --- [umer[UnitTopic]] c.c.j.DefaultJmsMessageListenerContainer : Setup of JMS message listener invoker failed for destination 'UnitTopic' - trying to recover. Cause: Session is closed
2018-08-13 19:12:17.153  INFO 8924 --- [umer[UnitTopic]] c.c.j.DefaultJmsMessageListenerContainer : Successfully refreshed JMS Connection

But I assume that this WARN is ok because of the HTTP tunnel.