The demonstration code required to run these examples is available only from the standalone Apache ActiveMQ package, which you must download and install in addition to Fuse ESB.
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 Fuse Message Broker Security Guide. |
To run these examples, you require:
Apache Ant build tool, version 1.6 or later.
Standalone Fuse Message Broker package, available from fusesource.com. It is assumed that you install this package to the directory,
ActiveMQInstallDir
.
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:
For full details of how to deploy a broker in the OSGi
container, please read Deploying a JMS Broker in Deploying into the OSGi Container. If you have not already deployed a broker, you
can create and deploy a new broker, broker1
, by entering the
following console command:
karaf@root> activemq:create-broker --name broker1
Add a HTTP transport connector by editing the broker configuration file (in
)
as follows:InstallDir
/deploy/broker1-broker.xml
<beans> ... <transportConnectors> ... <transportConnector name="openwire" uri="tcp://localhost:61616"/> <transportConnector name="http" uri="http://localhost:61620"/> </transportConnectors> ... </beans>
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 shutdown
To 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
|