Merge branch '2.2.x'

This commit is contained in:
Spencer Gibb
2020-03-10 16:20:02 -04:00
5 changed files with 50 additions and 2 deletions

View File

@@ -16,7 +16,7 @@
<properties>
<docs.main>spring-cloud-bus</docs.main>
<main.basedir>${basedir}/..</main.basedir>
<docs.whitelisted.branches>1.1.x,1.2.x,1.3.x,2.1.x</docs.whitelisted.branches>
<docs.whitelisted.branches>2.1.x,2.2.x</docs.whitelisted.branches>
<configprops.inclusionPattern>spring.cloud.bus.*</configprops.inclusionPattern>
</properties>
<build>

View File

@@ -18,6 +18,9 @@ package org.springframework.cloud.bus;
import javax.annotation.PostConstruct;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
@@ -69,6 +72,8 @@ import org.springframework.util.PathMatcher;
// so actuator endpoints have needed dependencies
public class BusAutoConfiguration implements ApplicationEventPublisherAware {
private static final Log log = LogFactory.getLog(BusAutoConfiguration.class);
/**
* Name of the Bus path matcher.
*/
@@ -140,6 +145,9 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
public void acceptLocal(RemoteApplicationEvent event) {
if (this.serviceMatcher.isFromSelf(event)
&& !(event instanceof AckRemoteApplicationEvent)) {
if (log.isDebugEnabled()) {
log.debug("Sending remote event on bus: " + event);
}
this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build());
}
}
@@ -154,6 +162,11 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
// If it's an ACK we are finished processing at this point
return;
}
if (log.isDebugEnabled()) {
log.debug("Received remote event from bus: " + event);
}
if (this.serviceMatcher.isForSelf(event)
&& this.applicationEventPublisher != null) {
if (!this.serviceMatcher.isFromSelf(event)) {

View File

@@ -18,6 +18,8 @@ package org.springframework.cloud.bus.event;
import java.util.Map;
import org.springframework.core.style.ToStringCreator;
/**
* @author Spencer Gibb
*/
@@ -73,4 +75,13 @@ public class EnvironmentChangeRemoteApplicationEvent extends RemoteApplicationEv
return true;
}
@Override
public String toString() {
return new ToStringCreator(this).append("id", getId())
.append("originService", getOriginService())
.append("destinationService", getDestinationService())
.append("values", values).toString();
}
}

View File

@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.springframework.context.ApplicationEvent;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.StringUtils;
/**
@@ -134,4 +135,12 @@ public abstract class RemoteApplicationEvent extends ApplicationEvent {
return true;
}
@Override
public String toString() {
return new ToStringCreator(this).append("id", id)
.append("originService", originService)
.append("destinationService", destinationService).toString();
}
}

View File

@@ -16,6 +16,8 @@
package org.springframework.cloud.bus.event;
import org.springframework.core.style.ToStringCreator;
/**
* @author Stefan Pfeiffer
*/
@@ -49,7 +51,20 @@ public class UnknownRemoteApplicationEvent extends RemoteApplicationEvent {
}
public String getPayloadAsString() {
return new String(this.payload);
if (this.payload != null) {
return new String(this.payload);
}
return null;
}
@Override
public String toString() {
return new ToStringCreator(this).append("id", getId())
.append("originService", getOriginService())
.append("destinationService", getDestinationService())
.append("typeInfo", typeInfo).append("payload", getPayloadAsString())
.toString();
}
}