@Override public ListenableFuture<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { if (isConcurrentStoreAndDispatchTopics()) { message.beforeMarshall(wireFormat); StoreTopicTask result = new StoreTopicTask(this, context, message, subscriptionCount.get()); result.aquireLocks(); addTopicTask(this, result); return result.getFuture(); } else { return super.asyncAddTopicMessage(context, message); } }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { String subscriptionKey = subscriptionKey(clientId, subscriptionName).toString(); if (isConcurrentStoreAndDispatchTopics()) { AsyncJobKey key = new AsyncJobKey(messageId, getDestination()); StoreTopicTask task = null; synchronized (asyncTaskMap) { task = (StoreTopicTask) asyncTaskMap.get(key); } if (task != null) { if (task.addSubscriptionKey(subscriptionKey)) { removeTopicTask(this, messageId); if (task.cancel()) { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } }
protected void addTopicTask(KahaDBTopicMessageStore store, StoreTopicTask task) throws IOException { synchronized (store.asyncTaskMap) { store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task); } this.topicExecutor.execute(task); }
@Override public void run() { this.store.doneTasks++; try { if (this.done.compareAndSet(false, true)) { this.topicStore.addMessage(context, message); // apply any acks we have synchronized (this.subscriptionKeys) { for (String key : this.subscriptionKeys) { this.topicStore.doAcknowledge(context, key, this.message.getMessageId(), null); } } removeTopicTask(this.topicStore, this.message.getMessageId()); this.future.complete(); } else if (cancelledTaskModMetric > 0 && this.store.canceledTasks++ % cancelledTaskModMetric == 0) { System.err.println(this.store.dest.getName() + " cancelled: " + (this.store.canceledTasks / this.store.doneTasks) * 100); this.store.canceledTasks = this.store.doneTasks = 0; } } catch (Exception e) { this.future.setException(e); } finally { releaseLocks(); } } }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { String subscriptionKey = subscriptionKey(clientId, subscriptionName).toString(); if (isConcurrentStoreAndDispatchTopics()) { AsyncJobKey key = new AsyncJobKey(messageId, getDestination()); StoreTopicTask task = null; synchronized (asyncTaskMap) { task = (StoreTopicTask) asyncTaskMap.get(key); } if (task != null) { if (task.addSubscriptionKey(subscriptionKey)) { removeTopicTask(this, messageId); if (task.cancel()) { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { String subscriptionKey = subscriptionKey(clientId, subscriptionName).toString(); if (isConcurrentStoreAndDispatchTopics()) { AsyncJobKey key = new AsyncJobKey(messageId, getDestination()); StoreTopicTask task = null; synchronized (asyncTaskMap) { task = (StoreTopicTask) asyncTaskMap.get(key); } if (task != null) { if (task.addSubscriptionKey(subscriptionKey)) { removeTopicTask(this, messageId); if (task.cancel()) { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } }
public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { String subscriptionKey = subscriptionKey(clientId, subscriptionName); if (isConcurrentStoreAndDispatchTopics()) { AsyncJobKey key = new AsyncJobKey(messageId, getDestination()); StoreTopicTask task = null; synchronized (asyncTaskMap) { task = (StoreTopicTask) asyncTaskMap.get(key); } if (task != null) { if (task.addSubscriptionKey(subscriptionKey)) { removeTopicTask(this, messageId); if (task.cancel()) { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { String subscriptionKey = subscriptionKey(clientId, subscriptionName).toString(); if (isConcurrentStoreAndDispatchTopics()) { AsyncJobKey key = new AsyncJobKey(messageId, getDestination()); StoreTopicTask task = null; synchronized (asyncTaskMap) { task = (StoreTopicTask) asyncTaskMap.get(key); } if (task != null) { if (task.addSubscriptionKey(subscriptionKey)) { removeTopicTask(this, messageId); if (task.cancel()) { synchronized (asyncTaskMap) { asyncTaskMap.remove(key); } } } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } } else { doAcknowledge(context, subscriptionKey, messageId, ack); } }
@Override public ListenableFuture<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { if (isConcurrentStoreAndDispatchTopics()) { message.beforeMarshall(wireFormat); StoreTopicTask result = new StoreTopicTask(this, context, message, subscriptionCount.get()); result.aquireLocks(); addTopicTask(this, result); return result.getFuture(); } else { return super.asyncAddTopicMessage(context, message); } }
protected void addTopicTask(KahaDBTopicMessageStore store, StoreTopicTask task) throws IOException { synchronized (store.asyncTaskMap) { store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task); } this.topicExecutor.execute(task); }
protected void addTopicTask(KahaDBTopicMessageStore store, StoreTopicTask task) throws IOException { synchronized (store.asyncTaskMap) { store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task); } this.topicExecutor.execute(task); }
@Override public Future<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { if (isConcurrentStoreAndDispatchTopics()) { StoreTopicTask result = new StoreTopicTask(this, context, message, subscriptionCount.get()); result.aquireLocks(); addTopicTask(this, result); return result.getFuture(); } else { return super.asyncAddTopicMessage(context, message); } }
protected void addTopicTask(KahaDBTopicMessageStore store, StoreTopicTask task) throws IOException { synchronized (store.asyncTaskMap) { store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task); } this.topicExecutor.execute(task); }
@Override public ListenableFuture<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { if (isConcurrentStoreAndDispatchTopics()) { message.beforeMarshall(wireFormat); StoreTopicTask result = new StoreTopicTask(this, context, message, subscriptionCount.get()); result.aquireLocks(); addTopicTask(this, result); return result.getFuture(); } else { return super.asyncAddTopicMessage(context, message); } }
protected void addTopicTask(KahaDBTopicMessageStore store, StoreTopicTask task) throws IOException { synchronized (store.asyncTaskMap) { store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task); } this.topicExecutor.execute(task); }
@Override public ListenableFuture<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { if (isConcurrentStoreAndDispatchTopics()) { message.beforeMarshall(wireFormat); StoreTopicTask result = new StoreTopicTask(this, context, message, subscriptionCount.get()); result.aquireLocks(); addTopicTask(this, result); return result.getFuture(); } else { return super.asyncAddTopicMessage(context, message); } }