# ModuleEventConfig.java

    package cloud.wconnect.rateshop.config;

    import cloud.wconnect.aws.sns.messaging.core.AwsSignatureVerifier;
    import cloud.wconnect.aws.sns.messaging.core.VerificationProperties;
    import cloud.wconnect.sns.http.configuration.SnsHttpProperties;
    import cloud.wconnect.sns.http.processor.Sender;
    import org.springframework.beans.factory.annotation.Qualifier;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
    import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
    import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
    import software.amazon.awssdk.regions.Region;
    import software.amazon.awssdk.services.sns.SnsClient;

    /**
     * module event sns sender
     *
     * @author yyt
     * 2023/10/27
     */
    @Configuration
    public class ModuleEventConfig {

        @Value("${w-connect.module-event.access-key}")
        private String awsAccessKey;

        @Value("${w-connect.module-event.secret-key}")
        private String awsSecretKey;

        @Value("${w-connect.module-event.region}")
        private String awsRegion;

        @Value("${w-connect.module-event.topic}")
        private String topic;

        @Value("${w-connect.module-event.category-name}")
        private String categoryName;

        @Value("${w-connect.module-event.max-life-time-of-message}")
        private long maxLifeTimeOfMessage;

        @Bean("moduleEventSnsClient")
        public SnsClient getSnsClient(){
            return SnsClient.builder()
                    .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(awsAccessKey, awsSecretKey)))
                    .region(Region.of(awsRegion))
                    .httpClient(UrlConnectionHttpClient.builder().build())
                    .build();
        }

        @Bean("moduleEventSender")
        public Sender getSender(@Qualifier("moduleEventSnsClient") SnsClient snsClient){
            SnsHttpProperties properties = new SnsHttpProperties();
            properties.setAccessKey(awsAccessKey);
            properties.setSecretKey(awsSecretKey);
            properties.setTopic(topic);
            properties.setCategoryName(categoryName);
            return new Sender(properties, snsClient);
        }

        @Bean("moduleAwsSignatureVerifier")
        public AwsSignatureVerifier getAwsSignatureVerifier() {
            VerificationProperties config = new VerificationProperties();
            config.setMaxLifeTimeOfMessage(maxLifeTimeOfMessage);
            return new AwsSignatureVerifier(config);
        }

    }