private boolean isNotFromSelf(final RemoteApplicationEvent event) { return serviceMatcher != null && !serviceMatcher.isFromSelf(event); }
@Bean @ConditionalOnMissingBean ServiceMatcher serviceMatcher(final ApplicationContext applicationContext) { final ServiceMatcher serviceMatcher = new ServiceMatcher(); serviceMatcher.setMatcher(new AntPathMatcher(":")); serviceMatcher.setApplicationContext(applicationContext); return serviceMatcher; }
@StreamListener(SpringCloudBusClient.INPUT) public void acceptRemote(RemoteApplicationEvent event) { if (event instanceof AckRemoteApplicationEvent) { if (this.bus.getTrace().isEnabled() && !this.serviceMatcher.isFromSelf(event) && this.applicationEventPublisher != null) { this.applicationEventPublisher.publishEvent(event); if (this.serviceMatcher.isForSelf(event) && this.applicationEventPublisher != null) { if (!this.serviceMatcher.isFromSelf(event)) { this.applicationEventPublisher.publishEvent(event); this.serviceMatcher.getServiceId(), this.bus.getAck().getDestinationService(), event.getDestinationService(), event.getId(), event.getClass());
@Bean public ServiceMatcher serviceMatcher(@BusPathMatcher PathMatcher pathMatcher, BusProperties properties, Environment environment) { String[] configNames = environment.getProperty(CLOUD_CONFIG_NAME_PROPERTY, String[].class, new String[] {}); ServiceMatcher serviceMatcher = new ServiceMatcher(pathMatcher, properties.getId(), configNames); return serviceMatcher; }
public boolean isFromSelf(RemoteApplicationEvent event) { String originService = event.getOriginService(); String serviceId = getServiceId(); return this.matcher.match(originService, serviceId); }
@StreamListener(SpringCloudBusClient.INPUT) public void acceptRemote(RemoteApplicationEvent event) { if (event instanceof AckRemoteApplicationEvent) { if (this.bus.getTrace().isEnabled() && !this.serviceMatcher.isFromSelf(event) && this.applicationEventPublisher != null) { this.applicationEventPublisher.publishEvent(event); if (this.serviceMatcher.isForSelf(event) && this.applicationEventPublisher != null) { if (!this.serviceMatcher.isFromSelf(event)) { this.applicationEventPublisher.publishEvent(event); this.serviceMatcher.getServiceId(), this.bus.getAck().getDestinationService(), event.getDestinationService(), event.getId(), event.getClass());
@Bean public ServiceMatcher serviceMatcher(@BusPathMatcher PathMatcher pathMatcher, BusProperties properties, Environment environment) { String[] configNames = environment.getProperty(CLOUD_CONFIG_NAME_PROPERTY, String[].class, new String[] {}); ServiceMatcher serviceMatcher = new ServiceMatcher(pathMatcher, properties.getId(), configNames); return serviceMatcher; }
public boolean isFromSelf(RemoteApplicationEvent event) { String originService = event.getOriginService(); String serviceId = getServiceId(); return this.matcher.match(originService, serviceId); }
@EventListener(classes = RemoteApplicationEvent.class) public void acceptLocal(RemoteApplicationEvent event) { if (this.serviceMatcher.isFromSelf(event) && !(event instanceof AckRemoteApplicationEvent)) { this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build()); } }
public boolean isForSelf(RemoteApplicationEvent event) { String destinationService = event.getDestinationService(); if (destinationService == null || destinationService.trim().isEmpty() || this.matcher.match(destinationService, getServiceId())) { return true; } // Check all potential config names instead of service name for (String configName : this.configNames) { if (this.matcher.match(destinationService, configName)) { return true; } } return false; }
@EventListener(classes = RemoteApplicationEvent.class) public void acceptLocal(RemoteApplicationEvent event) { if (this.serviceMatcher.isFromSelf(event) && !(event instanceof AckRemoteApplicationEvent)) { this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build()); } }
public boolean isForSelf(RemoteApplicationEvent event) { String destinationService = event.getDestinationService(); if (destinationService == null || destinationService.trim().isEmpty() || this.matcher.match(destinationService, getServiceId())) { return true; } // Check all potential config names instead of service name for (String configName : this.configNames) { if (this.matcher.match(destinationService, configName)) { return true; } } return false; }
/** * Was overridden that not every event has to run within a own * tenantAware. */ @Override public void multicastEvent(final ApplicationEvent event, final ResolvableType eventType) { if (applicationEventFilter.filter(event)) { return; } if (serviceMatcher == null || !(event instanceof RemoteTenantAwareEvent)) { super.multicastEvent(event, eventType); return; } final RemoteTenantAwareEvent remoteEvent = (RemoteTenantAwareEvent) event; if (serviceMatcher.isFromSelf(remoteEvent)) { super.multicastEvent(event, eventType); return; } tenantAware.runAsTenant(remoteEvent.getTenant(), () -> { super.multicastEvent(event, eventType); return null; }); }
/** * Was overridden that not every event has to run within a own * tenantAware. */ @Override public void multicastEvent(final ApplicationEvent event, final ResolvableType eventType) { if (applicationEventFilter.filter(event)) { return; } if (serviceMatcher == null || !(event instanceof RemoteTenantAwareEvent)) { super.multicastEvent(event, eventType); return; } final RemoteTenantAwareEvent remoteEvent = (RemoteTenantAwareEvent) event; if (serviceMatcher.isFromSelf(remoteEvent)) { super.multicastEvent(event, eventType); return; } tenantAware.runAsTenant(remoteEvent.getTenant(), () -> { super.multicastEvent(event, eventType); return null; }); }