-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update sqs guide * disable groovy guide * remove @nonnull annotation in kotlin class * configuration note * Change LOGGER to LOG as in all other guides Change LOGGER to LOG * Remove unused imports * Add license * Whitespace whitespace * Kotlinisation * Remove SQSClient factory from guide * Add pullout keys for kotlin class --------- Co-authored-by: Tim Yates <[email protected]>
- Loading branch information
Showing
30 changed files
with
565 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
...es/micronaut-jms-aws-sqs/groovy/src/main/groovy/example/micronaut/SqsClientFactory.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...naut-jms-aws-sqs/groovy/src/test/groovy/example/micronaut/SqsClientBuilderListener.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2017-2024 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package example.micronaut | ||
|
||
import io.micronaut.context.event.BeanCreatedEvent | ||
import io.micronaut.context.event.BeanCreatedEventListener | ||
import io.micronaut.core.annotation.NonNull | ||
import jakarta.inject.Singleton | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider | ||
import software.amazon.awssdk.regions.Region | ||
import software.amazon.awssdk.services.sqs.SqsClientBuilder | ||
|
||
@Singleton // <1> | ||
class SqsClientBuilderListener implements BeanCreatedEventListener<SqsClientBuilder> { // <2> | ||
|
||
private final SqsConfig sqsConfig | ||
|
||
SqsClientBuilderListener(SqsConfig sqsConfig) { // <3> | ||
this.sqsConfig = sqsConfig | ||
} | ||
|
||
@Override | ||
SqsClientBuilder onCreated(@NonNull BeanCreatedEvent<SqsClientBuilder> event) { | ||
SqsClientBuilder builder = event.bean | ||
try { | ||
return builder | ||
.endpointOverride(new URI(sqsConfig.sqs.endpointOverride)) | ||
.credentialsProvider( | ||
StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create(sqsConfig.accessKeyId, sqsConfig.secretKey) | ||
) | ||
) | ||
.region(Region.of(sqsConfig.region)) | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...jms-aws-sqs/groovy/src/test/groovy/example/micronaut/SqsClientCreatedEventListener.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017-2024 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package example.micronaut | ||
|
||
import io.micronaut.context.event.BeanCreatedEvent | ||
import io.micronaut.context.event.BeanCreatedEventListener | ||
import jakarta.inject.Singleton | ||
import software.amazon.awssdk.services.sqs.SqsClient | ||
import software.amazon.awssdk.services.sqs.model.CreateQueueRequest | ||
|
||
@Singleton | ||
public class SqsClientCreatedEventListener implements BeanCreatedEventListener<SqsClient> { | ||
private static final String QUEUE_NAME = "demo_queue" | ||
@Override | ||
SqsClient onCreated(BeanCreatedEvent<SqsClient> event) { | ||
SqsClient client = event.getBean() | ||
if (client.listQueues().queueUrls().stream().noneMatch(it -> it.contains(QUEUE_NAME))) { | ||
client.createQueue( | ||
CreateQueueRequest.builder() | ||
.queueName(QUEUE_NAME) | ||
.build() | ||
) | ||
} | ||
client | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
guides/micronaut-jms-aws-sqs/groovy/src/test/groovy/example/micronaut/SqsConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package example.micronaut | ||
|
||
import io.micronaut.context.annotation.ConfigurationBuilder | ||
import io.micronaut.context.annotation.ConfigurationProperties | ||
|
||
@ConfigurationProperties("aws") // <1> | ||
class SqsConfig { | ||
String accessKeyId | ||
String secretKey | ||
String region | ||
|
||
@ConfigurationBuilder(configurationPrefix = "services.sqs") | ||
final Sqs sqs = new Sqs() | ||
|
||
static class Sqs { | ||
String endpointOverride | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
...icronaut-jms-aws-sqs/groovy/src/test/groovy/example/micronaut/TestSqsClientFactory.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
guides/micronaut-jms-aws-sqs/java/src/main/java/example/micronaut/SqsClientFactory.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.