activemq http proxy
Asked Answered
M

2

8

I need to connect a ActiveMQ-Listener to a broker outside the firewall through an HTTP/HTTPS-Proxy. I've searched everywhere but haven't found a solution how to set the proxy settings for the AcitveMQ-Client.

ActiveMQ is using Apache HttpClient but I don't know how to manipulate the creation of this client within ActiveMQ. The use of htttps.proxyHost and https.proxyPort is not used by the HttpClient.

Is there a way to set a global http/https proxy for all instances of HttpClient ?

Marlin answered 18/1, 2013 at 9:15 Comment(0)
F
5

The ActiveMQ HttpClientTransport contains the following methods you can use to specify the proxy host and port:

public void setProxyHost(String proxyHost)
public void setProxyPort(int proxyPort)

For version 5.6+ you can also provide the proxy username and password:

public void setProxyUser(String proxyUser)
public void setProxyPassword(String proxyPassword)

To configure a JmsInvokerProxyFactoryBean:

<bean id="jmsClientFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL">
      <value>http://myendpoint.somewhere.com:5186?proxyUser=fred&amp;proxyPassword=ahoy&amp;proxyHost=myproxyhost.somewhere.com&amp;proxyPort=8081</value>
    </property>
</bean>


<bean id="remotingService"
        class="org.springframework.jms.remoting.JmsInvokerProxyFactoryBean">
      <property name="serviceInterface" value="com.foo.CheckingAccountService"/>
      <property name="connectionFactory" ref="jmsClientFactory"/>
      <property name="queue" ref="queue"/>
   </bean>
Fluctuation answered 18/1, 2013 at 17:13 Comment(7)
Thanks, but how can I get the instance of my Httpclienttransport to set the proxy. Iam using Springs JmsInvokerProxyFactoryBean and I don't know where the Httpclienttransport is created and how to access the instance within Activemq ?Marlin
Hi I am using ActiveMQConnectionFactory to create a connection using JmsTemplate. I need to connect to activeMq which is behind the proxy server. Can you please let me know how to set the proxy details to activemqConection. we are using tcp trasport connection to communicate with activemq. thanks for help in advance.Marinmarina
I don't think the TCP transport supports proxies. There is an open issue to support this: issues.apache.org/jira/plugins/servlet/mobile#issue/AMQ-2678Fluctuation
Hi is there way to use http trasport to connect via proxy. in the post you have mentioned that we can use HttpClinetTrasport. But I am not sure how to set HttpClientTrasport to ActiveMqConnection object. Please let me know how we can do that.Marinmarina
@Fluctuation Please let me know is there way to use http trasport to connect via proxy. in the post you have mentioned that we can use HttpClinetTrasport. But I am not sure how to set HttpClientTrasport to ActiveMqConnection object. Please let me know your inputs. ThanksMarinmarina
@Narendra: you should open a new question.Fluctuation
opened new question. #38270926Marinmarina
L
0

This is how you can enable http proxy in ActiveMQ if you don't use xml configuration:

  1. Add activemq-http library to the classpath (https://mvnrepository.com/artifact/org.apache.activemq/activemq-http)

  2. Add proxyHost and proxyPort as URI parameters and create connection factory with that URI:

    URI brokerUri = new URI("http://host:port");
    Map<String, String> additionalParameters = new HashMap<>();
    additionalParameters.put("proxyHost", "localhost");
    additionalParameters.put("proxyPort", "8888");
    additionalParameters.put("proxyUser", "xxxx"); // optional
    additionalParameters.put("proxyPassword", "xxxx"); // optional
    brokerUri = org.apache.activemq.util.URISupport.applyParameters(brokerUri, additionalParameters);
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri);
    Connection connection = connectionFactory.createConnection();
    
Lynxeyed answered 26/5, 2018 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.