Examples of StoredSubscription


Examples of com.google.api.client.googleapis.subscriptions.StoredSubscription

  public StoredSubscription getSubscription(String subscriptionId) throws IOException {
    if (memCache.contains(subscriptionId)) {
      return (StoredSubscription) memCache.get(subscriptionId);
    }

    StoredSubscription subscription = super.getSubscription(subscriptionId);
    memCache.put(subscriptionId, subscription, Expiration.byDeltaSeconds(EXPIRATION_TIME));
    return subscription;
  }
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId) throws IOException {
        EntityManager manager = adapter.beginEntityManager(context);
        try {
            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
            ss.setLastAckedId(messageId.getBrokerSequenceId());
        } catch (Throwable e) {
            adapter.rollbackEntityManager(context, manager);
            throw IOExceptionSupport.create(e);
        }
        adapter.commitEntityManager(context, manager);
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void addSubsciption(SubscriptionInfo info, boolean retroactive) throws IOException {
        EntityManager manager = adapter.beginEntityManager(null);
        try {
            StoredSubscription ss = new StoredSubscription();
            ss.setClientId(info.getClientId());
            ss.setSubscriptionName(info.getSubscriptionName());
            ss.setDestination(destinationName);
            ss.setSelector(info.getSelector());
            ss.setSubscribedDestination(info.getSubscribedDestination().getQualifiedName());
            ss.setLastAckedId(-1);

            if (!retroactive) {
                Query query = manager.createQuery("select max(m.id) from StoredMessage m");
                Long rc = (Long)query.getSingleResult();
                if (rc != null) {
                    ss.setLastAckedId(rc);
                }
            }

            manager.persist(ss);
        } catch (Throwable e) {
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void deleteSubscription(String clientId, String subscriptionName) throws IOException {
        EntityManager manager = adapter.beginEntityManager(null);
        try {
            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
            manager.remove(ss);
        } catch (Throwable e) {
            adapter.rollbackEntityManager(null, manager);
            throw IOExceptionSupport.create(e);
        }
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    public SubscriptionInfo lookupSubscription(String clientId, String subscriptionName) throws IOException {
        SubscriptionInfo rc = null;
        EntityManager manager = adapter.beginEntityManager(null);
        try {
            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
            if (ss != null) {
                rc = new SubscriptionInfo();
                rc.setClientId(ss.getClientId());
                rc.setDestination(destination);
                rc.setSelector(ss.getSelector());
                rc.setSubscriptionName(ss.getSubscriptionName());
                rc.setSubscribedDestination(toSubscribedDestination(ss));
            }
        } catch (Throwable e) {
            adapter.rollbackEntityManager(null, manager);
            throw IOExceptionSupport.create(e);
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

            id.setSubscriptionName(subscriptionName);
            id.setDestination(destinationName);

            AtomicLong last = subscriberLastMessageMap.get(id);
            if (last == null) {
                StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
                last = new AtomicLong(ss.getLastAckedId());
                subscriberLastMessageMap.put(id, last);
            }
            final AtomicLong lastMessageId = last;

            Query query = manager.createQuery("select m from StoredMessage m where m.destination=?1 and m.id>?2 order by m.id asc");
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    public void recoverSubscription(String clientId, String subscriptionName, MessageRecoveryListener listener) throws Exception {
        EntityManager manager = adapter.beginEntityManager(null);
        try {

            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);

            Query query = manager.createQuery("select m from StoredMessage m where m.destination=?1 and m.id>?2 order by m.id asc");
            query.setParameter(1, destinationName);
            query.setParameter(2, ss.getLastAckedId());
            for (StoredMessage m : (List<StoredMessage>)query.getResultList()) {
                Message message = (Message)wireFormat.unmarshal(new ByteSequence(m.getData()));
                listener.recoverMessage(message);
            }
        } catch (Throwable e) {
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId) throws IOException {
        EntityManager manager = adapter.beginEntityManager(context);
        try {
            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
            ss.setLastAckedId(messageId.getBrokerSequenceId());
        } catch (Throwable e) {
            adapter.rollbackEntityManager(context, manager);
            throw IOExceptionSupport.create(e);
        }
        adapter.commitEntityManager(context, manager);
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void addSubsciption(SubscriptionInfo info, boolean retroactive) throws IOException {
        EntityManager manager = adapter.beginEntityManager(null);
        try {
            StoredSubscription ss = new StoredSubscription();
            ss.setClientId(info.getClientId());
            ss.setSubscriptionName(info.getSubcriptionName());
            ss.setDestination(destinationName);
            ss.setSelector(info.getSelector());
            ss.setSubscribedDestination(info.getSubscribedDestination().getQualifiedName());
            ss.setLastAckedId(-1);

            if (!retroactive) {
                Query query = manager.createQuery("select max(m.id) from StoredMessageReference m");
                Long rc = (Long)query.getSingleResult();
                if (rc != null) {
                    ss.setLastAckedId(rc);
                }
            }

            manager.persist(ss);
        } catch (Throwable e) {
View Full Code Here

Examples of org.apache.activemq.store.jpa.model.StoredSubscription

    }

    public void deleteSubscription(String clientId, String subscriptionName) throws IOException {
        EntityManager manager = adapter.beginEntityManager(null);
        try {
            StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
            manager.remove(ss);
        } catch (Throwable e) {
            adapter.rollbackEntityManager(null, manager);
            throw IOExceptionSupport.create(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.