您好,我试图在java应用程序中使用队列中的消息,但过了一段时间,我的消费者停止轮询队列。在我的应用程序中,我有两个侦听器,消耗最多的队列通常停止被消耗。这是我的aws配置:
@Configuration
public class AWSConfiguration {
private final String region;
private final String accessKey;
private final String secretKey;
public AWSConfiguration(
@Value("${cloud.aws.region.static}") final String region,
@Value("${cloud.aws.credentials.accessKey}") final String accessKey,
@Value("${cloud.aws.credentials.secretKey}") final String secretKey) {
this.region = region;
this.accessKey = accessKey;
this.secretKey = secretKey;
}
private AWSCredentialsProvider getAwsCredentials(final String accessKey, final String secretKey) {
final BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
return new AWSStaticCredentialsProvider(basicAWSCredentials);
}
@Bean
@Primary
public AmazonSQSAsync amazonSQSAsync(){
return AmazonSQSAsyncClientBuilder
.standard()
.withCredentials(getAwsCredentials(accessKey, secretKey))
.withRegion(region)
.build();
}
}
以下是我的SQS管理员:
@SqsListener(value = "${cloud.aws.sqs.name.image-mosaic-demand-receive-mosaics}", deletionPolicy = ON_SUCCESS)
public void onReceiveMosaics(@Payload String message) {
LOGGER.trace("m=receiveMosaics(message={})", message);
GlebeDTO glebeDTO = receiveMosaicsMessageHandler.parseReceiveMessage(message);
LOGGER.info("Mosaicos do talhão {} recebidos", glebeDTO.getExternalId());
if(glebeDTO.getMosaics().size() >= 1){
processMosaicReceivedUseCase.processWithMosaics(buildCriteria(glebeDTO));
}else{
processMosaicReceivedUseCase.processWithoutMosaics(buildCriteria(glebeDTO));
}
}
@SqsListener(value = "${cloud.aws.sqs.name.image-mosaic-demand-order-request}", deletionPolicy = ON_SUCCESS)
public void receiveOrder(@Payload String message) {
LOGGER.trace("m=receiveOrder(message={})", message);
OrderRequestDTO orderRequestDTO = this.requestOrderMessageHandler.parseReceiveMessage(message);
LOGGER.info("{} - Recebida solicitação de mosaicos", orderRequestDTO.getOrderId());
validator.validate(orderRequestDTO);
Demand demand = orderRequestDTOToDemandConverter.convert(orderRequestDTO);
receiveRequestUseCase.onReceiveRequest(demand);
}
是否缺少任何配置?
暂无答案!
目前还没有任何答案,快来回答吧!