Discussion:
ActiveMQ spring xml configure connector publishedAddressPolicy
Laurence
2013-07-07 17:06:51 UTC
Permalink
Hi,

I'm trying to get activemq discovery via xml configuration to work by
broadcasting machine ip address instead of name (I can make this happen with
Groovy code for an embedded broker, but I want to do this for a standard
default activemq install with xml configuration).

I've read that in the past this was not possible with ActiveMQ with
configuration to configure the connector publishedAddressPolicy, but I also
did some googling which led me to think it might be possible now with
ActiveMQ.

I've tried to configure the connector publishedAddressPolicy for ActiveMQ
5.8, but have not been able to get this to work. Does anyone know if it is
really possible to configure the publishedAddressPolicy for a connector? If
so could you send me an example?

Thanks,

Laurence

p.s. The reason I want this to work is so that a default Redhat (or Redhat
clones) installation can successfully discover activemq server instances
(Mac and Win work fine, but to make Redhat work I need to discover server by
IP instead of name).



--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-spring-xml-configure-connector-publishedAddressPolicy-tp4668960.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Christian Posta
2013-07-08 01:45:50 UTC
Permalink
Post what you have... it should work..
How are you trying to discover the instances?
Post by Laurence
Hi,
I'm trying to get activemq discovery via xml configuration to work by
broadcasting machine ip address instead of name (I can make this happen with
Groovy code for an embedded broker, but I want to do this for a standard
default activemq install with xml configuration).
I've read that in the past this was not possible with ActiveMQ with
configuration to configure the connector publishedAddressPolicy, but I also
did some googling which led me to think it might be possible now with
ActiveMQ.
I've tried to configure the connector publishedAddressPolicy for ActiveMQ
5.8, but have not been able to get this to work. Does anyone know if it is
really possible to configure the publishedAddressPolicy for a connector? If
so could you send me an example?
Thanks,
Laurence
p.s. The reason I want this to work is so that a default Redhat (or Redhat
clones) installation can successfully discover activemq server instances
(Mac and Win work fine, but to make Redhat work I need to discover server by
IP instead of name).
--
http://activemq.2283324.n4.nabble.com/ActiveMQ-spring-xml-configure-connector-publishedAddressPolicy-tp4668960.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta
Laurence
2013-07-10 00:00:28 UTC
Permalink
I still have not figured out how to xml configure a transportConnector
publishedAddressPolicy and publishedHostStrategy to a value of
IPADDRESS.

I created a groovy script spring bean to assist with configuration and
it works for the uri attribute of the transportConnector, but have had
no luck setting publishedAddressPolicy ... tried all sorts of things
with and without using groovy.

One thing I learned on my Scientific Linux 6.4 machine is that I have to
set the transportConnector uri to use the actual machine IP instead of
using 0.0.0.0 and then I have to create another connector to 127.0.0.1
(that's why I created the groovy helper to guess which ip to use by
looking for a NIC that's on the same subnet as my wireless router).

Here is one of my latest failed configuration attempts:

<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->

<transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>

<transportConnector name="openwire2" uri="tcp://#{groovyConfigHelper1.guessIp}:61616?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"
discoveryUri="multicast://default">

<publishedAddressPolicy publishedHostStrategy="IPADDRESS" />


</transportConnector>

<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
</transportConnectors>

Partial Error Message:
...
Attribute 'publishedHostStrategy' is not allowed to appear in element 'publishedAddressPolicy'.
...

I checked the xsd looking for some clues ...
and it appears publishedAddressPolicy is an element and publishedHostStrategy is an attribute of type string.


<!-- element for type: org.apache.activemq.broker.PublishedAddressPolicy -->
<xs:element name='publishedAddressPolicy'>
<xs:annotation>
<xs:documentation><![CDATA[
Policy object that controls how a TransportConnector publishes the connector's
address to the outside world. By default the connector will publish itself
using the resolved host name of the bound server socket.
]]></xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name='clusterClientUriQuery' type='xs:string'>
<xs:annotation>
<xs:documentation><![CDATA[
Gets the URI query that's configured on the published URI that's sent to client's
when the cluster info is updated.
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name='publishedHostStrategy' type='xs:string'/>
<xs:attribute name='id' type='xs:ID'/>
<xs:anyAttribute namespace='##other' processContents='lax'/>
</xs:complexType>
</xs:element>

My current less than ideal workaround until I completely figure out the xml configuration is to just add a line to the default constructor in TransportConnector.java:
this.publishedAddressPolicy.setPublishedHostStrategy( PublishedAddressPolicy.PublishedHostStrategy.IPADDRESS );

and put my newly created jar file (that just contains the recompiled
TransportConnector.java) aaa_hack_DiscoverByIp_activemq-broker-5.8.0.jar
in the ActiveMQ lib folder (this works on Linux and Win - the aaa prefix
on my jar was to get this jar to appear earlier in the class path than
the other jars).
Post by Christian Posta
Post what you have... it should work..
How are you trying to discover the instances?
Post by Laurence
Hi,
I'm trying to get activemq discovery via xml configuration to work by
broadcasting machine ip address instead of name (I can make this happen with
Groovy code for an embedded broker, but I want to do this for a standard
default activemq install with xml configuration).
I've read that in the past this was not possible with ActiveMQ with
configuration to configure the connector publishedAddressPolicy, but I also
did some googling which led me to think it might be possible now with
ActiveMQ.
I've tried to configure the connector publishedAddressPolicy for ActiveMQ
5.8, but have not been able to get this to work. Does anyone know if it is
really possible to configure the publishedAddressPolicy for a connector? If
so could you send me an example?
Thanks,
Laurence
p.s. The reason I want this to work is so that a default Redhat (or Redhat
clones) installation can successfully discover activemq server instances
(Mac and Win work fine, but to make Redhat work I need to discover server by
IP instead of name).
--
http://activemq.2283324.n4.nabble.com/ActiveMQ-spring-xml-configure-connector-publishedAddressPolicy-tp4668960.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Loading...