我已经实现了一个微服务,该服务从AWS SQS队列读取消息并将其保存在Redis中。是否可以通过一次保存多个对象来提高对Redis的保存操作的性能?
我的配置类:
a456
还有我的听众-现在它可以一次读取并保存一条消息:
public JmsConfig(
@Value("${amazon.sqs.accessKey}") String awsAccessKey,
@Value("${amazon.sqs.secretKey}") String awsSecretKey,
@Value("${amazon.sqs.region}") String awsRegion,
@Value("${amazon.sqs.endpoint}") String awsEndpoint) {
connectionFactory = new SQSConnectionFactory(
new ProviderConfiguration(),
AmazonSQSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(awsAccessKey, awsSecretKey)))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(awsEndpoint, awsRegion))
.build());
}
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
DefaultJmsListenerContainerFactory factory =
new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(this.connectionFactory);
factory.setDestinationResolver(new DynamicDestinationResolver());
factory.setConcurrency("3-10");
factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
factory.setReceiveTimeout(2000L);
return factory;
}
(...)
是否可以一次保存许多对象?还是因为Redis速度快而不必要?你有什么意见?我每天必须阅读并保存大约8000-10000条消息。
谢谢 马修