@Override public void resetBatching(String clientId, String subscriptionName) { try { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); synchronized(indexMutex) { pageFile.tx().execute(new Transaction.Closure<IOException>(){ @Override public void execute(Transaction tx) throws IOException { StoredDestination sd = getStoredDestination(dest, tx); sd.subscriptionCursors.remove(subscriptionKey); } }); } } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public SubscriptionInfo lookupSubscription(String clientId, String subscriptionName) throws IOException { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); synchronized(indexMutex) { return pageFile.tx().execute(new Transaction.CallableClosure<SubscriptionInfo, IOException>(){ @Override public SubscriptionInfo execute(Transaction tx) throws IOException { StoredDestination sd = getStoredDestination(dest, tx); KahaSubscriptionCommand command = sd.subscriptions.get(tx, subscriptionKey); if( command ==null ) { return null; } return (SubscriptionInfo)wireFormat.unmarshal( new DataInputStream(command.getSubscriptionInfo().newInput()) ); } }); } }
@Override public void recoverSubscription(String clientId, String subscriptionName, final MessageRecoveryListener listener) throws Exception { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); synchronized(indexMutex) { pageFile.tx().execute(new Transaction.Closure<Exception>(){ @Override public void execute(Transaction tx) throws Exception { StoredDestination sd = getStoredDestination(dest, tx); Long cursorPos = sd.subscriptionAcks.get(tx, subscriptionKey); cursorPos += 1; for (Iterator<Entry<Long, MessageRecord>> iterator = sd.orderIndex.iterator(tx, cursorPos); iterator.hasNext();) { Entry<Long, MessageRecord> entry = iterator.next(); listener.recoverMessage( (Message) wireFormat.unmarshal(entry.getValue().data ) ); } } }); } }
@Override public int getMessageCount(String clientId, String subscriptionName) throws IOException { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); synchronized(indexMutex) { return pageFile.tx().execute(new Transaction.CallableClosure<Integer, IOException>(){ @Override public Integer execute(Transaction tx) throws IOException { StoredDestination sd = getStoredDestination(dest, tx); Long cursorPos = sd.subscriptionAcks.get(tx, subscriptionKey); if ( cursorPos==null ) { // The subscription might not exist. return 0; } cursorPos += 1; int counter = 0; for (Iterator<Entry<Long, MessageRecord>> iterator = sd.orderIndex.iterator(tx, cursorPos); iterator.hasNext();) { iterator.next(); counter++; } return counter; } }); } }
@Override public void recoverNextMessages(String clientId, String subscriptionName, final int maxReturned, final MessageRecoveryListener listener) throws Exception { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); synchronized(indexMutex) { pageFile.tx().execute(new Transaction.Closure<Exception>(){ @Override public void execute(Transaction tx) throws Exception { StoredDestination sd = getStoredDestination(dest, tx); Long cursorPos = sd.subscriptionCursors.get(subscriptionKey); if( cursorPos == null ) { cursorPos = sd.subscriptionAcks.get(tx, subscriptionKey); cursorPos += 1; } Entry<Long, MessageRecord> entry=null; int counter = 0; for (Iterator<Entry<Long, MessageRecord>> iterator = sd.orderIndex.iterator(tx, cursorPos); iterator.hasNext();) { entry = iterator.next(); listener.recoverMessage( (Message) wireFormat.unmarshal(entry.getValue().data ) ); counter++; if( counter >= maxReturned ) { break; } } if( entry!=null ) { sd.subscriptionCursors.put(subscriptionKey, entry.getKey() + 1); } } }); } }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toProducerKey()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toString()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toProducerKey()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toProducerKey()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toProducerKey()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }
@Override public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }
@Override public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }
public void addSubsciption(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }