The producer Ant target points to the
producerTool.java class, which again uses
ActiveMQConnectionFactory to connect to the broker, as
shown in Example 4.1.
The producer uses createQueue() or
createTopic() to publish to a destination.
![]() | Note |
|---|---|
If the destination already exits, the
|
Example 4.3. Attaching to a Queue or Topic
// Create the session
Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
if (topic) {
destination = session.createTopic(subject);
} else {
destination = session.createQueue(subject);
}