push messages to active mq via proxy using http transport

China☆狼群 提交于 2019-12-12 02:36:16

问题


Hi I am trying to push messages to active mq via http transport. The active mq is behind the proxy server which need authentication before pushing the message to external active mq. is there a way I can set the proxy details to active mq connection.

I read some article where mentioned we can use HttpClientTrasport. But i am not sure how to set the HttpClientTrasport to ActiveMQConnection object. Thanks in advance.


回答1:


if i understand you want to set the proxy config for org.apache.activemq.ActiveMQConnection ? this can be set on org.apache.activemq.ActiveMQConnectionFactory.ActiveMQConnectionFactory(String brokerURL) level by passing the url with proxy config like this : brokerURL = "http://localhost:8080?proxyHost=proxy&proxyPort=8080&proxyUser=user&proxyPassword=pwd"

if you have specials characters on user or pwd you need to change like this : brokerURL = "http://localhost:8080?"+ URLEncoder.encode("proxyHost=proxy&proxyPort=8080&proxyUser=user&proxyPassword=pwd", "UTF-8");

hope this help




回答2:


  1. add transportConnection configuration in activemq;

nano ~/apache-activemq-5.11.1/conf/activemq.xml

<transportConnector name="http" uri="http://0.0.0.0:8888?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
  1. use broker_url
private static final String DEFAULT_BROKER_URL = "http://localhost:8888"; 
  1. add dependency in project
<dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-http</artifactId><version>5.11.1</version></dependency>


来源:https://stackoverflow.com/questions/38270426/push-messages-to-active-mq-via-proxy-using-http-transport

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!