The message broker is responsible for managing JMS clients and their messages. The message broker is also responsible for providing quality of service features, such as reliability, persistence, security, and availability.
You can deploy FUSE Message Broker as a standalone broker that hosts clients running in other processes and other locations, or as an embedded broker that can run client functions and broker functions concurrently in one process, yet still enable connections by clients running in other processes and other locations. Standalone brokers and embedded brokers can be configured to work together to provide a more resilient network, or cluster, of brokers.
To start a standalone instance of FUSE Message Broker:
In a command prompt or terminal window, change directory to the FUSE Message Broker installation directory.
Change directory to the bin
directory.
Type the following:
Windows:
activemq.bat
UNIX:
./activemq
An embedded broker executes within the same JVM process as the clients that are using its services. So rather than communicating across the network, clients can communicate with the broker more efficiently using direct method invocation.
In addition, if the network fails, clients can continue to send messages to the broker, which will hold the messages until the network is restarted.
An embedded broker executes within the same JVM process as the clients that are using its services. There are a number of ways to embed a broker. The simplest is shown in Example 2.1
Example 2.1. Starting an Embedded Broker
BrokerService broker = new BrokerService(); broker.addConnector("tcp://localhost:61616"); broker.start();
Clients running in the same VM can connect to the embedded broker using the VM transport connector. External clients connect using the TCP transport connector. If you have more than one broker running in the same VM, you need to set a broker name, as follows:
Example 2.2. Starting a Named Embedded Broker
BrokerService broker = new BrokerService(); broker.setBrokerName("broker1"); broker.addConnector("tcp://localhost:61616"); broker.start();
Clients or other brokers connecting from within the same VM can then
connect using the virtual machine protocol on the named broker
vm://broker1
.