It is relatively straightforward to try out the various OpenWire+transport combinations using the sample code provided. After configuring the broker with the requisite transport connectors, you can use the sample producer tool and the consumer tool to propagate messages through the broker using the following protocols: OpenWire over TCP or OpenWire over HTTP.
Note
The secure socket protocols—OpenWire over SSL, and OpenWire over HTTPS—are discussed in ????.
To run these examples, you require:
Apache Ant build tool, version 1.6 or later.
The OpenWire examples depend on the sample producer and consumer clients located in the following directory:
ActiveMQInstallDir/fuse-message-broker-Version/example
To try out the OpenWire protocol, perform the following steps:
Add a HTTP transport connector by editing the broker configuration file (in
InstallDir/conf/activemq.xml)
as follows:
<beans>
...
<transportConnectors>
...
<transportConnector name="openwire" uri="tcp://localhost:61616"/>
<transportConnector name="http" uri="http://localhost:61620"/>
</transportConnectors>
...
</beans>Run the default broker by entering the following at a command line:
activemq
The default broker automatically takes its configuration from the default configuration file.
Note
The activemq script automatically sets the
ACTIVEMQ_HOME and ACTIVEMQ_BASE
environment variables to
FuseInstallDir/fuse-message-broker-Version
by default. If you want the activemq script to pick up
its configuration from a non-default conf directory, you
can set ACTIVEMQ_BASE explicitly in your environment.
The configuration files will then be taken from
$ACTIVEMQ_BASE/conf.
To connect the consumer tool to the tcp://localhost:61616
endpoint (OpenWire over TCP), change directory to
ActiveMQInstallDir/example
and enter the following command:
ant consumer -Durl=tcp://localhost:61616 -Dmax=100
You should see some output like the following:
Buildfile: build.xml
init:
compile:
consumer:
[echo] Running consumer against server at $url = tcp://localhost:61616
for subject $subject = TEST.FOO
[java] Connecting to URL: tcp://localhost:61616
[java] Consuming queue: TEST.FOO
[java] Using a non-durable subscription
[java] We are about to wait until we consume: 100 message(s) then
we will shutdownTo connect the producer tool to the tcp://localhost:61616
endpoint (OpenWire over TCP), open a new command prompt, change directory to
ActiveMQInstallDir/example
and enter the following command:
ant producer -Durl=tcp://localhost:61616
In the window where the consumer tool is running, you should see some output like the following:
[java] Received: Message: 0 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 1 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 2 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 3 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 4 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 5 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 6 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 7 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 8 sent at: Wed Sep 19 14:38:06 BST
2007 ...
[java] Received: Message: 9 sent at: Wed Sep 19 14:38:06 BST
2007 ...To connect the producer tool to the http://localhost:61620
endpoint (OpenWire over HTTP), enter the following command from the
example directory:
ant producer -Durl=http://localhost:61620
This command sends ten new messages to the consumer client.
Note
The JAR files for the HTTP protocol are currently located in the
lib/optional subdirectory. If you construct the
CLASSPATH manually, you must be sure to include the JAR files from this
subdirectory.








