Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.awspring.cloud.core.env.ResourceIdResolver - .ClassNotFoundException #903

Closed
Ber1984 opened this issue Oct 2, 2023 · 10 comments
Closed

Comments

@Ber1984
Copy link

Ber1984 commented Oct 2, 2023

Type: Bug

Component:
Aws-cloud-aws-core-3.0.2, Spring boot 3.1.2 , spring-cloud-aws-messaging:2.4.4

Describe the bug
I had to update my current proyect to Spring boot 3.1.2 and also update Aws-cloud-aws-core spring-cloud-aws-messaging from io.springframework to io.awspring.cloud and i'm getting this exception Caused by: java.lang.ClassNotFoundException: io.awspring.cloud.core.env.ResourceIdResolver.
I noticed that my applicaction can't resolve this class import io.awspring.cloud.core.env.ResourceIdResolver;

@Bean
	public QueueMessagingTemplate queueMessagingTemplate () {
		return new QueueMessagingTemplate(amazonSQSAsync());
	}
	
	@Bean
	public AmazonSQSAsync amazonSQSAsync () {
		return AmazonSQSAsyncClientBuilder.standard()
				.withRegion(region)
				.withCredentials(new DefaultAWSCredentialsProviderChainCustom())
				.build();
	}
	
	@Bean
	public SimpleMessageListenerContainer simpleMessageListenerContainer () {
		SimpleMessageListenerContainer msgListenerContainer = simpleMessageListenerContainerFactory()
				.createSimpleMessageListenerContainer();
		msgListenerContainer.setMessageHandler(queueMessageHandler());
		return msgListenerContainer;
	}
	
	@Bean
	public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory () {
		SimpleMessageListenerContainerFactory msgListenerContainerFactory = new SimpleMessageListenerContainerFactory();
		msgListenerContainerFactory.setAmazonSqs(amazonSQSAsync());
		msgListenerContainerFactory.setMaxNumberOfMessages(MAX_NUMBER_OF_MESSAGES);
		return msgListenerContainerFactory;
	}
	
	@Bean
	public QueueMessageHandler queueMessageHandler () {
		QueueMessageHandlerFactory queueMsgHandlerFactory = new QueueMessageHandlerFactory();
		queueMsgHandlerFactory.setAmazonSqs(amazonSQSAsync());
		QueueMessageHandler queueMessageHandler = queueMsgHandlerFactory.createQueueMessageHandler();
		List<HandlerMethodArgumentResolver> list = new ArrayList<>();
		HandlerMethodArgumentResolver resolver = new PayloadArgumentResolver(new MappingJackson2MessageConverter());
		list.add(resolver);
		queueMessageHandler.setArgumentResolvers(list);
		return queueMessageHandler;
	}

image
Thanks for your help

@MatejNedic
Copy link
Member

Hey @erickjhorman ,
Spring Cloud AWS messaging is 2.x version which is compatible with Spring Boot 2.x.
Also, you are using Spring Cloud AWS Core 3.0.2 please use spring-cloud-aws-sqs 3.0.2 then with it.
Spring Cloud AWS 3.x.x is compatible with Spring Boot 3.x

@JNKessel
Copy link

JNKessel commented Oct 3, 2023

Hi @MatejNedic!
I am having the same problem as @erickjhorman here.

According to this repository it looks like the newest version of Spring Cloud AWS messaging is 2.4.4, is there a 3.x.x version compatible with Spring Boot 3.x?

Thank you!

@MatejNedic
Copy link
Member

MatejNedic commented Oct 3, 2023

Hey @JNKessel
Spring Cloud AWS messaging is only compatible with Spring Cloud AWS 2.x.x versions.
We released new version of Spring Cloud AWS 3.0.0 + which removed Spring Cloud AWS messaging.
Now you have spring-cloud-aws-sqs and spring-cloud-aws-sns. With the latest version being 3.0.2

The repository you linked is old repository, we moved github repositories. Check here

Please check the releases

Edit:
Check our samples for 3.0.2 version sqs-sample

@JNKessel
Copy link

JNKessel commented Oct 3, 2023

Thank you so much for the clarification @MatejNedic! I hope this helps erick as well.
I will take a look at spring-cloud-aws-sqs documentation to figure out how to adapt my project.

I will still read the repository, but are there equivalent classes to the old Messaging module?

For example, these are some of the main ones i remember:
io.awspring.cloud.messaging.config.QueueMessageHandlerFactory
io.awspring.cloud.messaging.core.QueueMessagingTemplate
io.awspring.cloud.messaging.listener.SimpleMessageListenerContainer

Thank you!!

@maciejwalkowiak
Copy link
Contributor

SQS architecture has changed and there are no 1 to 1 equivalent classes. Please take a look at the reference documentation and start discussion if you'll encounter any issues.

@VaibhavTheVicar
Copy link

VaibhavTheVicar commented Feb 18, 2024

@JNKessel looks like SqsMessageListenerContainer is for SimpleMessageListenerContainer and similarly the factory.

I am having problems setting a DestinationResolver, setWaitTimeOut and FailOnMissingQueue. @maciejwalkowiak any clues?

@tomazfernandes
Copy link
Contributor

tomazfernandes commented Feb 26, 2024

@VaibhavTheVicar, unfortunately we hadn't been able to create a proper migration guide from 2.x to 3.x, so you'll need to look for new features that will correspond to your application's need rather than have a 1 to 1 feature mapping.

setWaitTimeOut and FailOnMissingQueue.

You can find similar options in ContainerOptions, please refer to the documentation.

DestinationResolver

What do you use the DestinationResolver for?

@VaibhavTheVicar
Copy link

@tomazfernandes I cant share exactly what we use destination resolvers for, company code.

But a common use case could be resolving a Kubernetes client key value pair.

Currenly I have had to override the .createInstance method in the sqsListnerFactory class, and plug a lambda for our purposes of resolution there.

@VaibhavTheVicar
Copy link

@tomazfernandes but this poses problem, I had to copy and override the WHOLE builder :/

@ailsoncgt
Copy link

@erickjhorman & @VaibhavTheVicar how did you solve the compatibility problem? Can you please share your final solution/ideia ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants