String topicBase = "qmf." + _domain + ".topic";
_syncSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create a MessageProducer for the QMF topic address used to broadcast requests
Destination topicAddress = _syncSession.createQueue(topicBase);
_broadcaster = _syncSession.createProducer(topicAddress);
// If Asynchronous Behaviour is enabled we create the Queues used to receive async responses
// Data Indications, QMF Events, Heartbeats etc. from the broker (or other Agents).
if (!_disableEvents)
{
// TODO it should be possible to bind _eventConsumer and _asyncResponder to the same queue
// if I can figure out the correct AddressString to use, probably not a big deal though.
_asyncSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Set up MessageListener on the Event Address
Destination eventAddress = _asyncSession.createQueue(topicBase + "/agent.ind.#" + eventAddressOptions);
_eventConsumer = _asyncSession.createConsumer(eventAddress);
_eventConsumer.setMessageListener(this);
// Create the asynchronous JMSReplyTo _replyAddress and MessageConsumer
_asyncReplyAddress = _asyncSession.createQueue(_address + ".async" + asyncReplyAddressOptions);
_asyncResponder = _asyncSession.createConsumer(_asyncReplyAddress);
_asyncResponder.setMessageListener(this);
}
// I've extended the synchronized block to include creating the _requester and _responder. I don't believe
// that this is strictly necessary, but it stops findbugs moaning about inconsistent synchronization
// so makes sense if only to get that warm and fuzzy feeling of keeping findbugs happy :-)
synchronized(this)
{
// Create a MessageProducer for the QMF direct address, mainly used for request/response
Destination directAddress = _syncSession.createQueue("qmf." + _domain + ".direct");
_requester = _syncSession.createProducer(directAddress);
// Create the JMSReplyTo _replyAddress and MessageConsumer
_replyAddress = _syncSession.createQueue(_address + syncReplyAddressOptions);
_responder = _syncSession.createConsumer(_replyAddress);