Package net.timewalker.ffmq3.local.destination.subscription

Examples of net.timewalker.ffmq3.local.destination.subscription.LocalTopicSubscription


                break;
            Thread.sleep(100);
        }

        // When in non-transacted mode, the ack is sent _after_ message processing so we need to wait a bit
        LocalTopic localTopic = engine.getLocalTopic(params.destinationName);
        if (!params.receiverTransacted)
        {
            while (localTopic.getSize() > 0)
                Thread.sleep(10);
        }
       
        long endTime = System.currentTimeMillis();
        double rate = (double)totalExpected*1000/(endTime-startTime);
        System.out.println((endTime-startTime)+" ms ("+rateFormat.format(rate)+" msg/s)");

        int totalReceived = 0;
        for (int n = 0 ; n < receivers.length ; n++)
            totalReceived += receivers[n].getReceivedCount();

        int topicSize = localTopic.getSize();
        if (topicSize > 0)
        {
            System.out.println("Expected : "+totalExpected);
            System.out.println("Received : "+totalReceived);
            System.out.println(localTopic);
            System.out.println(localTopic.getConsumersSummary());              
            TestUtils.dumpThreads();
            TestUtils.hang();
        }

        // Close receivers
View Full Code Here


                break;
            Thread.sleep(100);
        }

        // When in non-transacted mode, the ack is sent _after_ message processing so we need to wait a bit
        LocalTopic localTopic = engine.getLocalTopic(params.destinationName);
        if (!params.receiverTransacted)
        {
          while (localTopic.getSize() > 0)
            Thread.sleep(10);
        }
       
        long endTime = System.currentTimeMillis();
        double rate = (double)totalExpected*1000/(endTime-startTime);
        System.out.println((endTime-startTime)+" ms ("+rateFormat.format(rate)+" msg/s)");

        int totalReceived = 0;
        for (int n = 0 ; n < receivers.length ; n++)
            totalReceived += receivers[n].getReceivedCount();

        int topicSize = localTopic.getSize();
        if (topicSize > 0)
        {
            System.out.println("Expected : "+totalExpected);
            System.out.println("Received : "+totalReceived);
            System.out.println(localTopic);
            System.out.println(localTopic.getConsumersSummary());              
            TestUtils.dumpThreads();
            TestUtils.hang();
        }

        // Close receivers
View Full Code Here

    public void registerConsumer(LocalMessageConsumer consumer)
    {
        super.registerConsumer(consumer);
        synchronized (subscriptionMap)
    {
          LocalTopicSubscription subscription = new LocalTopicSubscription(consumer);
          subscriptions.add(subscription);
          subscriptionMap.put(consumer.getSubscriberId(),subscription);
    }
    }
View Full Code Here

        if (!consumer.isDurable())
        {
            log.debug("Removing non-durable subscription "+consumer.getSubscriberId());
            synchronized (subscriptionMap)
        {
              LocalTopicSubscription subscription = (LocalTopicSubscription)subscriptionMap.remove(consumer.getSubscriberId());
              if (subscription != null)
                subscriptions.remove(subscription);
        }
        }
    }
View Full Code Here

     */
    public void unsubscribe( String clientID , String subscriptionName  ) throws JMSException
    {
      String subscriberID = clientID+"-"+subscriptionName;
     
      LocalTopicSubscription subscription = (LocalTopicSubscription)subscriptionMap.get(subscriberID);
      if (subscription == null)
        return;
     
      if (isConsumerRegistered(subscriberID))
        throw new FFMQException("Subscription "+subscriptionName+" is still in use","SUBSCRIPTION_STILL_IN_USE");
View Full Code Here

          subscriptionsSnapshot = subscriptions.fastCopy();
        }
       
        for (int i = 0; i < subscriptionsSnapshot.size(); i++)
    {
        LocalTopicSubscription subscription = (LocalTopicSubscription)subscriptionsSnapshot.get(i);
           
            // No-local filtering
            if (subscription.getNoLocal() && subscription.getConnectionID().equals(connectionID))
                continue;

            try
            {
                // Message selector filtering
                MessageSelector selector = subscription.getMessageSelector();
                if (selector != null)
                {
                  srcMessage.ensureDeserializationLevel(MessageSerializationLevel.ALL_HEADERS);
                  if (!selector.matches(srcMessage))
                    continue;
                }
               
              if (subscription.getLocalQueue().put(srcMessage))
              {
                // Only require a commit if the subscription is declared as durable
                if (committables != null && subscription.isDurable())
                  committables.add(subscription.getLocalQueue());
              }
             
              dispatchedFromTopicCount++;
            }
            catch (JMSException e)
View Full Code Here

      int size = 0;
      synchronized (subscriptionMap)
        {
        for (int i = 0; i < subscriptions.size(); i++)
        {
            LocalTopicSubscription subscription = (LocalTopicSubscription)subscriptions.get(i);
                size += subscription.getLocalQueue().getSize();
            }
        }
      return size;
    }
View Full Code Here

       
        synchronized (subscriptionMap)
        {
            for (int i = 0; i < subscriptions.size(); i++)
            {
                LocalTopicSubscription subscription = (LocalTopicSubscription)subscriptions.get(i);
               
                if (i>0)
                    sb.append("\n");
                sb.append(subscription);
            }
View Full Code Here

    }
   
    private CreateConsumerResponse processCreateDurableSubscriber( CreateDurableSubscriberQuery query ) throws JMSException
    {
        LocalSession session = lookupSession(query);
        LocalDurableTopicSubscriber subscriber = (LocalDurableTopicSubscriber)session.createDurableSubscriber(query.getConsumerId(),
                                                                                                          query.getTopic(),
                                                                                                              query.getName(),
                                                                                                              query.getMessageSelector(),
                                                                                                              query.isNoLocal());
       
        // Start prefetching
        subscriber.prefetchMore();
       
        CreateConsumerResponse response = new CreateConsumerResponse();
        response.setPrefetchSize(subscriber.getPrefetchSize());
       
        return response;
    }
View Full Code Here

    }
   
    private LocalMessageConsumer lookupConsumer( AbstractConsumerQuery query ) throws JMSException
    {
        LocalSession localSession = lookupSession(query);
        LocalMessageConsumer consumer = (LocalMessageConsumer)localSession.lookupRegisteredConsumer(query.getConsumerId());
        if (consumer == null)
            throw new FFMQException("Invalid consumer id : "+query.getConsumerId(),"NETWORK_ERROR");
        return consumer;
    }
View Full Code Here

TOP

Related Classes of net.timewalker.ffmq3.local.destination.subscription.LocalTopicSubscription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.