new DrainSubscriptionMessagesProcessor()); messagesCache.invokeAll(messageKeys, new AcknowledgeMessageProcessor(subscriptionIdentifier));
/** * Create either a {@link Topic} or {@link Queue} using an existing {@link Destination}. * * @param destinationIdentifier destination identifier * @param destination destination * @return destination identifier */ private Identifier createDestination(Identifier destinationIdentifier, Destination destination) { NamedCache destinationsCache = CacheFactory.getCache(Destination.CACHENAME); destinationsCache.invoke(destinationIdentifier, new CreateDestinationProcessor(destination)); return destinationIdentifier; }
/** * {@inheritDoc} */ public void onLeaseSuspended(Object leaseOwner, Lease lease) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "The lease for {0} has been suspended. Rolling back delivered messages\n", this); } CacheFactory.getCache(Subscription.CACHENAME).invoke(getIdentifier(), new SubscriptionRollbackProcessor()); }
/** * {@inheritDoc} */ @Override protected void acknowledgeDistributedEvents(List<Event> events, MessageTracker messageTracker) { // create the set of keys for messages to acknowledge ArrayList<MessageKey> messageKeys = new ArrayList<MessageKey>(events.size()); Iterator<MessageIdentifier> messageIds = messageTracker.iterator(); while (messageIds.hasNext()) { MessageIdentifier messageId = messageIds.next(); messageKeys.add(Message.getKey(subscriptionIdentifier.getDestinationIdentifier(), messageId)); } // remove this subscriber from each of the messages in this batch // (to help clean up the messages when they are completely consumed) NamedCache messagesCache = CacheFactory.getCache(Message.CACHENAME); messagesCache.invokeAll(messageKeys, new AcknowledgeMessageProcessor(subscriptionIdentifier)); // remove the range we've just distributed from the subscriber NamedCache subscriptions = CacheFactory.getCache(Subscription.CACHENAME); subscriptions.invoke(subscriptionIdentifier, new AcknowledgeSubscriptionMessagesProcessor(messageTracker)); } }
new RequestMessageFromQueueProcessor(getSubscriptionIdentifier())); (Message) CacheFactory.getCache(Message.CACHENAME) .invoke(Message.getKey(getDestinationIdentifier(), partitionId, messageSequenceNumber), new AcknowledgeMessageProcessor(getSubscriptionIdentifier())); new AcknowledgeSubscriptionMessagesProcessor(messageTracker)); (Message) CacheFactory.getCache(Message.CACHENAME) .invoke(Message.getKey(getDestinationIdentifier(), partitionId, messageSequenceNumber), new RequestMessageProcessor(getSubscriptionIdentifier()));
(Message) CacheFactory.getCache(Message.CACHENAME) .invoke(Message.getKey(getDestinationIdentifier(), messageIdentifier), new AcknowledgeMessageProcessor(getSubscriptionIdentifier())); new AcknowledgeSubscriptionMessagesProcessor(messageTracker)); (Message) CacheFactory.getCache(Message.CACHENAME) .invoke(Message.getKey(getDestinationIdentifier(), messageIdentifier), new RequestMessageProcessor(getSubscriptionIdentifier()));
new QueueSubscribeProcessor<SubscriptionConfiguration>(subscriptionIdentifier, (SubscriptionConfiguration) subscriptionConfiguration, null); new TopicSubscribeProcessor<SubscriptionConfiguration>(subscriptionIdentifier, (SubscriptionConfiguration) subscriptionConfiguration, subscription);
/** * {@inheritDoc} */ public void unsubscribe(SubscriptionIdentifier subscriptionIdentifier, MessageTracker messageTracker) { ArrayList<MessageKey> messageKeys = messageTracker.getMessageKeys(getIdentifier()); CacheFactory.getCache(Message.CACHENAME).invokeAll(messageKeys, new AcknowledgeMessageProcessor(subscriptionIdentifier)); super.unsubscribe(subscriptionIdentifier, messageTracker); }
/** * {@inheritDoc} */ public void rollback() { ensureActive(); resetMessageSequenceVerification(); if (!isAutoCommitting()) { // ensure that we have a subscription from which we can retrieve // messages ensureSubscription(); // determine the range of messages that are visible // (these are the ones we must rollback) MessageTracker messageTracker = (MessageTracker) CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new ExtractorProcessor("getVisibleMessageTracker")); NamedCache destinationCache = CacheFactory.getCache(Destination.CACHENAME); destinationCache.invoke(getDestinationIdentifier(), new RollbackMessageProcessor(getSubscriptionIdentifier(), messageTracker)); // clear the delivered list for the subscription CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new SubscriptionRollbackProcessor()); } }
new TopicSubscribeProcessor<SubscriptionConfiguration>(subscription.getIdentifier(), new DefaultSubscriptionConfiguration(), subscription));
/** * Unsubscribe from the destination. */ private void unsubscribe() { SubscriptionIdentifier subscriptionId = getIdentifier(); NamedCache destinationCache = CacheFactory.getCache(Destination.CACHENAME); destinationCache.invoke(subscriptionId.getDestinationIdentifier(), new UnsubscribeProcessor(subscriptionId)); }
/** * Expose the message batch to a queue or topic. * * @param destinationIdentifier destination identifier * @param tracker messages to expose */ private void exposeQueueMessageBatch(Identifier destinationIdentifier, MessageTracker tracker) { NamedCache destinations = CacheFactory.getCache(Destination.CACHENAME); destinations.invoke(destinationIdentifier, new ExposeMessageToQueueProcessor(tracker)); ArrayList<MessageKey> messageKeys = tracker.getMessageKeys(destinationIdentifier); CacheFactory.getCache(Message.CACHENAME).invokeAll(messageKeys, new UpdaterProcessor("setVisible", Boolean.TRUE)); }
new CreateSubscriptionProcessor(subscription));
PublishRequestIdentifier requestId = new PublishRequestIdentifier(this.publisherId, this.requestNumber++); messageCache.invoke(this.publisherId, new PublishMessageProcessor(destinationIdentifier, requestId, payload));
/** * {@inheritDoc} */ public void commit() { ensureActive(); if (!isAutoCommitting()) { // ensure that we have a subscription from which we can retrieve // messages ensureSubscription(); // determine the range of messages that are visible // (these are the ones we must acknowledge) MessageTracker messageTracker = (MessageTracker) CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new ExtractorProcessor("getVisibleMessageTracker")); // send the AcknowledgeMessageProcessor to all of the visible // messages ArrayList<MessageKey> messageKeys = messageTracker.getMessageKeys(getDestinationIdentifier()); CacheFactory.getCache(Message.CACHENAME).invokeAll(messageKeys, new AcknowledgeMessageProcessor(getSubscriptionIdentifier())); // let the subscriber know that we've acknowledged all messages CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new AcknowledgeSubscriptionMessagesProcessor(messageTracker)); } }
messagesCache.invokeAll(messageKeys, new AcknowledgeMessageProcessor(subscriptionIdentifier));
/** * {@inheritDoc} */ public void onLeaseExpiry(Object leaseOwner, Lease lease) { if (isDurable()) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "The lease for durable {0} has expired. Rolling back delivered messages\n", this); } CacheFactory.getCache(Subscription.CACHENAME).invoke(getIdentifier(), new SubscriptionRollbackProcessor()); } else { super.onLeaseExpiry(leaseOwner, lease); } }
/** * {@inheritDoc} */ public void unsubscribe() { if (isActive()) { // shutdown local resources for the subscription shutdown(State.Shutdown); // Unsubscribe from the destination. Wait until the subscription is deleted to avoid the bug in INC-795 CacheFactory.getCache(Destination.CACHENAME).invoke(getDestinationIdentifier(), new UnsubscribeProcessor(getSubscriptionIdentifier())); } }
/** * {@inheritDoc} */ public void commit() { ensureActive(); if (!isAutoCommitting()) { // ensure that we have a subscription from which we can retrieve // messages ensureSubscription(); // determine the range of messages that have been delivered // (these are the ones we must acknowledge) MessageTracker messageTracker = (MessageTracker) CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new ExtractorProcessor("getDeliveredMessageTracker")); if (!messageTracker.isEmpty()) { // Tell Message that is has been acked ArrayList<MessageKey> messageKeys = messageTracker.getMessageKeys(getDestinationIdentifier()); CacheFactory.getCache(Message.CACHENAME).invokeAll(messageKeys, new AcknowledgeMessageProcessor(getSubscriptionIdentifier())); // Tell subscription that msg has been acked. CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new AcknowledgeSubscriptionMessagesProcessor(messageTracker)); } } }
/** * {@inheritDoc} */ public void rollback() { ensureActive(); resetMessageSequenceVerification(); if (!isAutoCommitting()) { // ensure that we have a subscription from which we can retrieve // messages ensureSubscription(); // clear the delivered list for the subscription CacheFactory.getCache(Subscription.CACHENAME).invoke(getSubscriptionIdentifier(), new SubscriptionRollbackProcessor()); } }