org.springframework.messaging.simp.broker.BrokerAvailabilityEvent Java Examples

The following examples show how to use org.springframework.messaging.simp.broker.BrokerAvailabilityEvent. 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: UserRegistryMessageHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
	if (event.isBrokerAvailable()) {
		long delay = getRegistryExpirationPeriod() / 2;
		this.scheduledFuture = this.scheduler.scheduleWithFixedDelay(this.schedulerTask, delay);
	}
	else {
		ScheduledFuture<?> future = this.scheduledFuture;
		if (future != null ){
			future.cancel(true);
			this.scheduledFuture = null;
		}
	}
}
 
Example #2
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void publishEvent(Object event) {
	logger.debug("Processing ApplicationEvent " + event);
	if (event instanceof BrokerAvailabilityEvent) {
		this.eventQueue.add((BrokerAvailabilityEvent) event);
	}
}
 
Example #3
Source File: UserRegistryMessageHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Runnable getUserRegistryTask() {
	BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
	this.handler.onApplicationEvent(event);

	ArgumentCaptor<? extends Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
	verify(this.taskScheduler).scheduleWithFixedDelay(captor.capture(), eq(10000L));

	return captor.getValue();
}
 
Example #4
Source File: UserRegistryMessageHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
	if (event.isBrokerAvailable()) {
		long delay = getRegistryExpirationPeriod() / 2;
		this.scheduledFuture = this.scheduler.scheduleWithFixedDelay(this.schedulerTask, delay);
	}
	else {
		ScheduledFuture<?> future = this.scheduledFuture;
		if (future != null ){
			future.cancel(true);
			this.scheduledFuture = null;
		}
	}
}
 
Example #5
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void publishEvent(Object event) {
	logger.debug("Processing ApplicationEvent " + event);
	if (event instanceof BrokerAvailabilityEvent) {
		this.eventQueue.add((BrokerAvailabilityEvent) event);
	}
}
 
Example #6
Source File: UserRegistryMessageHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Runnable getUserRegistryTask() {
	BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
	this.handler.onApplicationEvent(event);

	ArgumentCaptor<? extends Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
	verify(this.taskScheduler).scheduleWithFixedDelay(captor.capture(), eq(10000L));

	return captor.getValue();
}
 
Example #7
Source File: UserRegistryMessageHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
	if (event.isBrokerAvailable()) {
		long delay = getRegistryExpirationPeriod() / 2;
		this.scheduledFuture = this.scheduler.scheduleWithFixedDelay(this.schedulerTask, delay);
	}
	else if (this.scheduledFuture != null ){
		this.scheduledFuture.cancel(true);
		this.scheduledFuture = null;
	}
}
 
Example #8
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void publishEvent(Object event) {
	logger.debug("Processing ApplicationEvent " + event);
	if (event instanceof BrokerAvailabilityEvent) {
		this.eventQueue.add((BrokerAvailabilityEvent) event);
	}
}
 
Example #9
Source File: UserRegistryMessageHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Runnable getUserRegistryTask() {
	BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
	this.handler.onApplicationEvent(event);

	ArgumentCaptor<? extends Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
	verify(this.taskScheduler).scheduleWithFixedDelay(captor.capture(), eq(10000L));

	return captor.getValue();
}
 
Example #10
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public void expectBrokerAvailabilityEvent(boolean isBrokerAvailable) throws InterruptedException {
	BrokerAvailabilityEvent event = this.eventQueue.poll(20000, TimeUnit.MILLISECONDS);
	assertNotNull("Times out waiting for BrokerAvailabilityEvent[" + isBrokerAvailable + "]", event);
	assertEquals(isBrokerAvailable, event.isBrokerAvailable());
}
 
Example #11
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
public void expectBrokerAvailabilityEvent(boolean isBrokerAvailable) throws InterruptedException {
	BrokerAvailabilityEvent event = this.eventQueue.poll(20000, TimeUnit.MILLISECONDS);
	assertNotNull("Times out waiting for BrokerAvailabilityEvent[" + isBrokerAvailable + "]", event);
	assertEquals(isBrokerAvailable, event.isBrokerAvailable());
}
 
Example #12
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public void expectBrokerAvailabilityEvent(boolean isBrokerAvailable) throws InterruptedException {
	BrokerAvailabilityEvent event = this.eventQueue.poll(20000, TimeUnit.MILLISECONDS);
	assertNotNull("Times out waiting for BrokerAvailabilityEvent[" + isBrokerAvailable + "]", event);
	assertEquals(isBrokerAvailable, event.isBrokerAvailable());
}
 
Example #13
Source File: QuoteServiceImpl.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
@Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
	this.brokerAvailable.set(event.isBrokerAvailable());
}
 
Example #14
Source File: QuoteService.java    From spring4ws-demos with Apache License 2.0 4 votes vote down vote up
@Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
	this.brokerAvailable.set(event.isBrokerAvailable());
}