@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }
ReceiptHandler handler = this.receiptHandlers.get(receiptId); if (handler != null) { handler.handleReceiptReceived();
public ReceiptHandler(@Nullable String receiptId) { this.receiptId = receiptId; if (receiptId != null) { initReceiptHandling(); } }
ReceiptHandler handler = this.receiptHandlers.get(receiptId); if (handler != null) { handler.handleReceiptReceived();
ReceiptHandler handler = this.receiptHandlers.get(receiptId); if (handler != null) { handler.handleReceiptReceived();
private void addTask(Runnable task, boolean successTask) { Assert.notNull(this.receiptId, "To track receipts, set autoReceiptEnabled=true or add 'receiptId' header"); synchronized (this) { if (this.result != null && this.result == successTask) { invoke(Collections.singletonList(task)); } else { if (successTask) { this.receiptCallbacks.add(task); } else { this.receiptLostCallbacks.add(task); } } } }
private void addTask(Runnable task, boolean successTask) { Assert.notNull(this.receiptId, "To track receipts, set autoReceiptEnabled=true or add 'receiptId' header"); synchronized (this) { if (this.result != null && this.result == successTask) { invoke(Collections.singletonList(task)); } else { if (successTask) { this.receiptCallbacks.add(task); } else { this.receiptLostCallbacks.add(task); } } } }
public void handleReceiptReceived() { handleInternal(true); }
private void handleInternal(boolean result) { synchronized (this) { if (this.result != null) { return; } this.result = result; invoke(result ? this.receiptCallbacks : this.receiptLostCallbacks); DefaultStompSession.this.receiptHandlers.remove(this.receiptId); if (this.future != null) { this.future.cancel(true); } } } }
public void handleReceiptNotReceived() { handleInternal(false); }
@Override public void addReceiptTask(Runnable task) { addTask(task, true); }
public void handleReceiptReceived() { handleInternal(true); }
private void handleInternal(boolean result) { synchronized (this) { if (this.result != null) { return; } this.result = result; invoke(result ? this.receiptCallbacks : this.receiptLostCallbacks); DefaultStompSession.this.receiptHandlers.remove(this.receiptId); if (this.future != null) { this.future.cancel(true); } } } }
public void handleReceiptNotReceived() { handleInternal(false); }
@Override public void addReceiptTask(Runnable task) { addTask(task, true); }
public ReceiptHandler(@Nullable String receiptId) { this.receiptId = receiptId; if (receiptId != null) { initReceiptHandling(); } }
@Override public void addReceiptLostTask(Runnable task) { addTask(task, false); }
@Override public Receiptable acknowledge(StompHeaders headers, boolean consumed) { String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompCommand command = (consumed ? StompCommand.ACK : StompCommand.NACK); StompHeaderAccessor accessor = createHeaderAccessor(command); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, null); execute(message); return receiptable; }
@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }
@Override public void addReceiptLostTask(Runnable task) { addTask(task, false); }