/** * Remove all pending acknowledgement markers that are batched into the single * client acknowledge operation. * * @param subscription * The STOMP Subscription that has performed a client acknowledge. * @param msgIdsToRemove * List of message IDs that are bound to the subscription that has ack'd */ protected void afterClientAck(StompSubscription subscription, ArrayList<String> msgIdsToRemove) { int count = 0; for (Map.Entry<String,AckEntry> entry : this.pedingAcks.entrySet()){ AckEntry actEntry = entry.getValue(); if (msgIdsToRemove.contains(actEntry.messageId)) { this.pedingAcks.remove(entry.getKey()); count++; } } LOG.trace("Subscription:[{}] client acknowledged {} messages", subscription.getSubscriptionId(), count); } }
public MessageAck onMessageAck(TransactionId transactionId) { return subscription.onStompMessageAck(messageId, transactionId); }
StompSubscription stompSubscription = new StompSubscription(this, subscriptionId, consumerInfo, headers.get(Stomp.Headers.TRANSFORMATION)); stompSubscription.setDestination(actualDest); stompSubscription.setAckMode(StompSubscription.CLIENT_ACK); } else if (Stomp.Headers.Subscribe.AckModeValues.INDIVIDUAL.equals(ackMode)) { stompSubscription.setAckMode(StompSubscription.INDIVIDUAL_ACK); } else { stompSubscription.setAckMode(StompSubscription.AUTO_ACK);
if ((subscriptionId != null && subscriptionId.equals(sub.getSubscriptionId())) || (destination != null && destination.equals(sub.getDestination()))) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); iter.remove(); return;
StompSubscription sub = this.subscriptions.remove(subscriptionId); if (sub != null) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); return; if (destination != null && destination.equals(sub.getDestination())) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); iter.remove(); return;
if (sub != null) { String ackId = null; if (version.equals(Stomp.V1_2) && sub.getAckMode() != Stomp.Headers.Subscribe.AckModeValues.AUTO && md.getMessage() != null) { AckEntry pendingAck = new AckEntry(md.getMessage().getMessageId().toString(), sub); ackId = this.ACK_ID_GENERATOR.generateId(); sub.onMessageDispatch(md, ackId); } catch (Exception ex) { if (ackId != null) {
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }
protected void onStompCommit(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (Iterator<StompSubscription> iter = subscriptionsByConsumerId.values().iterator(); iter.hasNext();) { StompSubscription sub = iter.next(); sub.onStompCommit(activemqTx); } TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompAbort(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (Iterator<StompSubscription> iter = subscriptionsByConsumerId.values().iterator(); iter.hasNext();) { StompSubscription sub = iter.next(); try { sub.onStompAbort(activemqTx); } catch (Exception e) { throw new ProtocolException("Transaction abort failed", false, e); } } TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.ROLLBACK); sendToActiveMQ(tx, createResponseHandler(command)); }
stompSubscription = new StompSubscription(this, subscriptionId, consumerInfo, headers.get(Stomp.Headers.TRANSFORMATION)); } else { stompSubscription = new StompQueueBrowserSubscription(this, subscriptionId, consumerInfo, headers.get(Stomp.Headers.TRANSFORMATION)); stompSubscription.setDestination(actualDest); stompSubscription.setAckMode(StompSubscription.CLIENT_ACK); } else if (Stomp.Headers.Subscribe.AckModeValues.INDIVIDUAL.equals(ackMode)) { stompSubscription.setAckMode(StompSubscription.INDIVIDUAL_ACK); } else { stompSubscription.setAckMode(StompSubscription.AUTO_ACK);
StompSubscription sub = this.subscriptions.remove(subscriptionId); if (sub != null) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); return; if (destination != null && destination.equals(sub.getDestination())) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); iter.remove(); return;
if (sub != null) { String ackId = null; if (version.equals(Stomp.V1_2) && sub.getAckMode() != Stomp.Headers.Subscribe.AckModeValues.AUTO && md.getMessage() != null) { AckEntry pendingAck = new AckEntry(md.getMessage().getMessageId().toString(), sub); ackId = this.ACK_ID_GENERATOR.generateId(); sub.onMessageDispatch(md, ackId); } catch (Exception ex) { if (ackId != null) {
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }
protected void onStompCommit(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (StompSubscription sub : subscriptionsByConsumerId.values()) { sub.onStompCommit(activemqTx); } pedingAcks.clear(); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompAbort(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (stompTx == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId activemqTx = transactions.remove(stompTx); if (activemqTx == null) { throw new ProtocolException("Invalid transaction id: " + stompTx); } for (StompSubscription sub : subscriptionsByConsumerId.values()) { try { sub.onStompAbort(activemqTx); } catch (Exception e) { throw new ProtocolException("Transaction abort failed", false, e); } } pedingAcks.clear(); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.ROLLBACK); sendToActiveMQ(tx, createResponseHandler(command)); }
stompSubscription = new StompSubscription(this, subscriptionId, consumerInfo, headers.get(Stomp.Headers.TRANSFORMATION)); } else { stompSubscription = new StompQueueBrowserSubscription(this, subscriptionId, consumerInfo, headers.get(Stomp.Headers.TRANSFORMATION)); stompSubscription.setDestination(actualDest); stompSubscription.setAckMode(StompSubscription.CLIENT_ACK); } else if (Stomp.Headers.Subscribe.AckModeValues.INDIVIDUAL.equals(ackMode)) { stompSubscription.setAckMode(StompSubscription.INDIVIDUAL_ACK); } else { stompSubscription.setAckMode(StompSubscription.AUTO_ACK);
StompSubscription sub = this.subscriptions.remove(subscriptionId); if (sub != null) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); return; if (destination != null && destination.equals(sub.getDestination())) { sendToActiveMQ(sub.getConsumerInfo().createRemoveCommand(), createResponseHandler(command)); iter.remove(); return;
if (sub != null) { String ackId = null; if (version.equals(Stomp.V1_2) && sub.getAckMode() != Stomp.Headers.Subscribe.AckModeValues.AUTO && md.getMessage() != null) { AckEntry pendingAck = new AckEntry(md.getMessage().getMessageId().toString(), sub); ackId = this.ACK_ID_GENERATOR.generateId(); sub.onMessageDispatch(md, ackId); } catch (Exception ex) { if (ackId != null) {
public MessageAck onMessageAck(TransactionId transactionId) { return subscription.onStompMessageAck(messageId, transactionId); }
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }