问题
The Apache ActiveMQ broker supports discovery with IP multicast. This feature is activated in the default 'demo' configuration (see below). I would like to implement the discovery feature in other languages (Delphi / Free Pascal). Is there some minimal code example or introduction page on the web which shows how this would be implemented in Java?
If I understand correctly, the multicast would trigger an answer of the message broker, which contains information about IP and port of the message broker. But I can not figure out which port the client needs to specify (ActiveMQ documentation).
However I can not see which port the multicast client should use.
<!-- Create a TCP transport that is advertised on via an IP multicast
group named default. -->
<transportConnector name="openwire" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
...
Update: I found http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html and try to use this example code.
回答1:
The best source of documentation is always the code itself. If you take a look at the source in SVN for ActiveMQ and browse the org.apache.activemq.transports.discovery package you should have a really good understanding of how the discovery bits works, also the default ports are all in the code.
svn co https://svn.apache.org/repos/asf/activemq/trunk activemq
来源:https://stackoverflow.com/questions/12285666/discover-a-running-activemq-message-broker-using-ip-multicast