Search in sources :

Example 71 with TopicImpl

use of com.swiftmq.jms.TopicImpl in project swiftmq-ce by iitsoftware.

the class TopicBroker method putMessage.

public void putMessage(Object transactionId, MessageImpl msg) throws QueueException {
    lockAndWaitAsyncFinished();
    try {
        if (subscriptions.size() == 0)
            return;
        TopicTransaction transaction = (TopicTransaction) transactionId;
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "putMessage, transaction=" + transaction + ", message=" + msg);
        // set dest queue for routing
        if (msg.getDestQueue() == null) {
            String s = getQueueName();
            msg.setDestQueue(s.substring(0, s.indexOf('@')));
        }
        String topicName = null;
        // local msgs haven't set a source router
        boolean publishedLocal = msg.getSourceRouter() == null;
        try {
            TopicImpl topic = (TopicImpl) msg.getJMSDestination();
            topicName = topic.getTopicName();
        } catch (Exception ignored) {
        }
        String[] tokenizedPubTopic = topicName.indexOf(TopicManagerImpl.TOPIC_DELIMITER_CHAR) == -1 ? rootTokenized : ctx.topicManager.tokenizeTopicName(topicName);
        List matchedNodes = null;
        if (ctx.topicManager.isDirectSubscriberSelection())
            matchedNodes = getMatchedNodes(tokenizedPubTopic);
        else
            matchedNodes = getMatchedNodes(getMatchedTopics(tokenizedPubTopic));
        if (matchedNodes != null) {
            for (int i = 0; i < matchedNodes.size(); i++) {
                PredicateNode node = (PredicateNode) matchedNodes.get(i);
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "putMessage, node: " + node + " does match");
                publishToNode(transaction, msg, node, publishedLocal);
            }
        }
    } finally {
        lock.unlock();
    }
}
Also used : EntityList(com.swiftmq.mgmt.EntityList) TopicImpl(com.swiftmq.jms.TopicImpl) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Aggregations

TopicImpl (com.swiftmq.jms.TopicImpl)71 JMSException (javax.jms.JMSException)62 InvalidSelectorException (javax.jms.InvalidSelectorException)58 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)56 Entity (com.swiftmq.mgmt.Entity)42 Property (com.swiftmq.mgmt.Property)42 MessageImpl (com.swiftmq.jms.MessageImpl)17 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)14 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)8 RingBuffer (com.swiftmq.tools.collection.RingBuffer)7 EntityList (com.swiftmq.mgmt.EntityList)6 List (java.util.List)6 QueueImpl (com.swiftmq.jms.QueueImpl)4 MessageSelector (com.swiftmq.ms.MessageSelector)4 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)4 TopicException (com.swiftmq.swiftlet.topic.TopicException)4 IOException (java.io.IOException)4 SwiftletException (com.swiftmq.swiftlet.SwiftletException)3 InvalidDestinationException (javax.jms.InvalidDestinationException)3 ActiveLogin (com.swiftmq.swiftlet.auth.ActiveLogin)2