[英]Spring cloud function Cosuming rabbitmq queue - Dispatcher has no subscribers for channel
Given:鉴于:
cloud:
stream:
rabbit:
bindings:
inboundApolloLookupVehicleChannel:
destination: fed.apollo-vehicle-lookup-test
group: apollo-mngt-group
consumer:
missingQueuesFatal: true
prefetch: 25
autoBindDlq: true
maxAttempts: 1
republishToDlq: true
requeueRejected: false
durableSubscription: true
maxConcurrency: 6
function:
definition: consume
and:和:
@SpringBootApplication
@EnableEurekaClient
@EnableBinding(LookupMessageChannel.class)
public class ApolloLookupServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApolloLookupServiceApplication.class, args);
}
}
public interface LookupMessageChannel {
String INBOUND_LOOKUP_VEHICLE_CHANNEL = "inboundApolloLookupVehicleChannel";
@Input(INBOUND_LOOKUP_VEHICLE_CHANNEL)
SubscribableChannel inboundApolloLookupVehicleChannel();
}
@Service
@MessageEndpoint
@RequiredArgsConstructor
public class ApolloVehicleLookupService {
private final ApolloVehicleLookUpRepository apolloVehicleLookUpRepository;
private static final Logger LOGGER = LoggerFactory.getLogger(ApolloVehicleLookupService.class);
@Bean
public Consumer<Flux<ApolloVehicleLookUp>> consume() {
return stream -> stream
.flatMap(this.apolloVehicleLookUpRepository::save)
.subscribe(value -> {
LOGGER.info("stored value: " + value.toString());
});
}
}
POM:聚甲醛:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>14</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
<spotify-docker-maven.version>1.2.0</spotify-docker-maven.version>
<os.detected.classifier>linux-x86_64</os.detected.classifier>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-rsocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
Why am I getting the following exception?为什么我会收到以下异常?
[payload=org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'apollo-lookup-service-1.inboundApolloLookupVehicleChannel'. [payload=org.springframework.messaging.MessageDeliveryException: Dispatcher 没有频道“apollo-lookup-service-1.inboundApolloLookupVehicleChannel”的订阅者。 ;
; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=byte[439]
嵌套异常是 org.springframework.integration.MessageDispatchingException: Dispatcher 没有订阅者,failedMessage=GenericMessage [payload=byte[439]
I've just wanted to consume messages from that queue.我只是想使用该队列中的消息。
Any help would be appreciated, thanks.任何帮助将不胜感激,谢谢。
The exception simple means that your channel defined in LookupMessageChannel
has no subscribers and why should it since, you have not defined any.异常简单意味着您在
LookupMessageChannel
中定义的频道没有订阅者,为什么要这样做,因为您没有定义任何订阅者。 It also appears to me that you are attempting to use functional approach while the rest of your stream app uses legacy configurations that is all but deprecated.在我看来,您正在尝试使用功能方法,而 stream 应用程序的 rest 使用几乎已弃用的旧配置。
Don't get me wrong but there are few things that are wrong with your app at the moment so it's hard to determine what exactly you are looking for to do, so.不要误会我的意思,但目前您的应用程序很少有问题,因此很难确定您到底想要做什么,所以。 .
. .
.
Please consider following this quick start (5 min top) to get you into proper functional approach and then feel free to follow up with additional questions.请考虑遵循此快速入门(顶部 5 分钟)以使您进入正确的功能方法,然后随时跟进其他问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.