Java Code Examples for org.springframework.messaging.simp.stomp.StompSession.Subscription#addReceiptTask()

The following examples show how to use org.springframework.messaging.simp.stomp.StompSession.Subscription#addReceiptTask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultStompSessionTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void receiptReceived() {
	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));
	subscription.addReceiptTask(() -> received.set(true));

	assertNull(received.get());

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	assertNotNull(received.get());
	assertTrue(received.get());
}
 
Example 2
Source File: DefaultStompSessionTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void receiptReceivedBeforeTaskAdded() {
	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	subscription.addReceiptTask(() -> received.set(true));

	assertNotNull(received.get());
	assertTrue(received.get());
}
 
Example 3
Source File: DefaultStompSessionTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void receiptReceived() {
	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));
	subscription.addReceiptTask(() -> received.set(true));

	assertNull(received.get());

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	assertNotNull(received.get());
	assertTrue(received.get());
}
 
Example 4
Source File: DefaultStompSessionTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void receiptReceivedBeforeTaskAdded() {
	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	subscription.addReceiptTask(() -> received.set(true));

	assertNotNull(received.get());
	assertTrue(received.get());
}
 
Example 5
Source File: DefaultStompSessionTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void receiptReceived() throws Exception {

	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));
	subscription.addReceiptTask(() -> received.set(true));

	assertNull(received.get());

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	assertNotNull(received.get());
	assertTrue(received.get());
}
 
Example 6
Source File: DefaultStompSessionTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void receiptReceivedBeforeTaskAdded() throws Exception {

	this.session.afterConnected(this.connection);
	this.session.setTaskScheduler(mock(TaskScheduler.class));

	AtomicReference<Boolean> received = new AtomicReference<>();

	StompHeaders headers = new StompHeaders();
	headers.setDestination("/topic/foo");
	headers.setReceipt("my-receipt");
	Subscription subscription = this.session.subscribe(headers, mock(StompFrameHandler.class));

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
	accessor.setReceiptId("my-receipt");
	accessor.setLeaveMutable(true);
	this.session.handleMessage(MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders()));

	subscription.addReceiptTask(() -> received.set(true));

	assertNotNull(received.get());
	assertTrue(received.get());
}