Browse Source
Components that are using a StompBrokerRelayMessageHandler may want to know whether or not the broker's unavailable. If they're sending messages to the relay via an asynchronous channel there's currently no way for them to find this out. This commit enhances StompBrokerRelayMessageHandler to publish application events when the broker's availability changes: BrokerBecameAvailableEvent and BrokerBecameUnavailableEvent. Irrespective of the number of relay sessions only a single event is published for each change in the broker's availability.pull/339/head
7 changed files with 268 additions and 34 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
/* |
||||
* Copyright 2002-2013 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.messaging.simp.stomp; |
||||
|
||||
import org.springframework.context.ApplicationEvent; |
||||
|
||||
|
||||
/** |
||||
* Base class for application events relating to broker availability. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
public abstract class BrokerAvailabilityEvent extends ApplicationEvent { |
||||
|
||||
|
||||
protected BrokerAvailabilityEvent(Object source) { |
||||
super(source); |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
/* |
||||
* Copyright 2002-2013 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.messaging.simp.stomp; |
||||
|
||||
/** |
||||
* Event raised when the broker being used by a {@link |
||||
* StompBrokerRelayMessageHandler} becomes available |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
public class BrokerBecameAvailableEvent extends BrokerAvailabilityEvent { |
||||
|
||||
/** |
||||
* Creates a new BrokerBecameAvailableEvent |
||||
* |
||||
* @param source the {@code StompBrokerRelayMessageHandler} that is acting |
||||
* as a relay for the broker that has become available. Must not be {@code |
||||
* null}. |
||||
*/ |
||||
public BrokerBecameAvailableEvent(StompBrokerRelayMessageHandler source) { |
||||
super(source); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright 2002-2013 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.messaging.simp.stomp; |
||||
|
||||
|
||||
/** |
||||
* Event raised when the broker being used by a {@link |
||||
* StompBrokerRelayMessageHandler} becomes unavailable |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
public class BrokerBecameUnavailableEvent extends BrokerAvailabilityEvent { |
||||
|
||||
/** |
||||
* Creates a new BrokerBecameUnavailableEvent |
||||
* |
||||
* @param source the {@code StompBrokerRelayMessageHandler} that is acting |
||||
* as a relay for the broker that has become unavailable. Must not be {@code |
||||
* null}. |
||||
*/ |
||||
public BrokerBecameUnavailableEvent(StompBrokerRelayMessageHandler source) { |
||||
super(source); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue