Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/com.microsoft.azure-azure…
Browse files Browse the repository at this point in the history
…-servicebus-3.6.7
  • Loading branch information
jGauravGupta authored Jan 12, 2024
2 parents 84ae96b + 0e84685 commit f339cc6
Show file tree
Hide file tree
Showing 76 changed files with 681 additions and 527 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
java: [8, 11, 17]
java: [11, 17]
fail-fast: false
max-parallel: 2
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
Expand Down
49 changes: 44 additions & 5 deletions AmazonSQS/AmazonSQSExample/pom.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) [2022] Payara Foundation and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://github.com/payara/Payara/blob/master/LICENSE.txt
See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/legal/LICENSE.txt.
GPL Classpath Exception:
The Payara Foundation designates this particular file as subject to the "Classpath"
exception as provided by the Payara Foundation in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fish.payara.cloud.connectors</groupId>
<artifactId>cloud-connectors</artifactId>
<version>0.8.0</version>
<version>1.0.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>fish.payara.cloud.connectors.amazonsqs</groupId>
<artifactId>amazon-sqs-example</artifactId>
<version>0.8.0</version>
<version>2.0.0</version>
<packaging>ejb</packaging>

<name>Amazon SQS Example</name>
Expand All @@ -24,9 +63,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>1.12.286</version>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
<version>2.20.69</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2017-2022 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -40,37 +40,41 @@
* holder.
*/


import com.amazonaws.services.sqs.model.SendMessageRequest;
import fish.payara.cloud.connectors.amazonsqs.api.AmazonSQSConnection;
import fish.payara.cloud.connectors.amazonsqs.api.AmazonSQSConnectionFactory;
import javax.annotation.Resource;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.resource.ConnectionFactoryDefinition;
import javax.resource.spi.TransactionSupport.TransactionSupportLevel;

import jakarta.annotation.Resource;
import jakarta.ejb.Schedule;
import jakarta.ejb.Stateless;
import jakarta.resource.ConnectionFactoryDefinition;
import jakarta.resource.spi.TransactionSupport.TransactionSupportLevel;
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;
/**
*
* @author Steve Millidge (Payara Foundation)
*/
@ConnectionFactoryDefinition(name = "java:comp/env/SQSConnectionFactory",
description = "SQS Conn Factory",
interfaceName = "fish.payara.cloud.connectors.amazonsqs.api.AmazonSQSConnectionFactory",
resourceAdapter = "amazon-sqs-rar-0.8.0",
minPoolSize = 2, maxPoolSize = 2,
transactionSupport = TransactionSupportLevel.NoTransaction,
properties = {"region=${ENV=region}"})
@ConnectionFactoryDefinition(name = "java:comp/env/SQSConnectionFactory",
description = "SQS Conn Factory",
interfaceName = "fish.payara.cloud.connectors.amazonsqs.api.AmazonSQSConnectionFactory",
resourceAdapter = "amazon-sqs-rar-2.0.0",
minPoolSize = 2, maxPoolSize = 2,
transactionSupport = TransactionSupportLevel.NoTransaction,
properties = {"region=${ENV=region}"})
@Stateless
public class NewTimerSessionBean {

@Resource(lookup="java:comp/env/SQSConnectionFactory")
@Resource(lookup = "java:comp/env/SQSConnectionFactory")
AmazonSQSConnectionFactory factory;
@Schedule(second = "*/1", hour="*", minute="*")

@Schedule(second = "*/1", hour = "*", minute = "*")
public void myTimer() {
try (AmazonSQSConnection connection = factory.getConnection()) {
connection.sendMessage(new SendMessageRequest(System.getenv("queueURL"), "Hello World"));
} catch (Exception e) {}
SendMessageRequest sendMsgRequest = SendMessageRequest.builder()
.queueUrl(System.getenv("queueURL"))
.messageBody("Hello World")
.build();
connection.sendMessage(sendMsgRequest);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2017-2022 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -40,33 +40,32 @@
package fish.payara.cloud.connectors.amazonsqs.example;

import fish.payara.cloud.connectors.amazonsqs.api.AmazonSQSListener;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import com.amazonaws.services.sqs.model.Message;
import com.amazonaws.services.sqs.model.MessageAttributeValue;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import fish.payara.cloud.connectors.amazonsqs.api.OnSQSMessage;
import software.amazon.awssdk.services.sqs.model.Message;
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
import java.util.Map;

/**
*
* @author Steve Millidge (Payara Foundation)
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "queueURL", propertyValue = "${ENV=queueURL}"),
@ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "1000"),
@ActivationConfigProperty(propertyName = "region", propertyValue = "${ENV=region}")
@ActivationConfigProperty(propertyName = "queueURL", propertyValue = "${ENV=queueURL}"),
@ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "1000"),
@ActivationConfigProperty(propertyName = "region", propertyValue = "${ENV=region}")
})
public class ReceiveSQSMessage implements AmazonSQSListener {

@OnSQSMessage
public void receiveMessage(Message message) {
System.out.println("Got message " + message.getBody());
Map<String,MessageAttributeValue> mattrs = message.getMessageAttributes();
System.out.println("Got message " + message.body());
Map<String, MessageAttributeValue> mattrs = message.messageAttributes();
for (String key : mattrs.keySet()) {
System.out.println("Got Message attribute " + key + "," + mattrs.get(key).getStringValue());
System.out.println("Got Message attribute " + key + "," + mattrs.get(key).stringValue());
}
Map<String,String> attrs = message.getAttributes();

Map<String, String> attrs = message.attributesAsStrings();
for (String key : attrs.keySet()) {
System.out.println("Got attribute " + key + "," + attrs.get(key));
}
Expand Down
67 changes: 57 additions & 10 deletions AmazonSQS/AmazonSQSJCAAPI/pom.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) [2022] Payara Foundation and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://github.com/payara/Payara/blob/master/LICENSE.txt
See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/legal/LICENSE.txt.
GPL Classpath Exception:
The Payara Foundation designates this particular file as subject to the "Classpath"
exception as provided by the Payara Foundation in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fish.payara.cloud.connectors</groupId>
<artifactId>cloud-connectors</artifactId>
<version>0.8.0</version>
<version>1.0.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>fish.payara.cloud.connectors.amazonsqs</groupId>
<artifactId>amazon-sqs-jca-api</artifactId>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>Amazon SQS JCA Adapter API</name>
<description>API classes for the Amazon SQS JCA Adapter</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.20.17</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.12.286</version>
<type>pom</type>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>1.12.286</version>
<type>jar</type>
<scope>provided</scope>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2017-2022 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -39,22 +39,24 @@
*/
package fish.payara.cloud.connectors.amazonsqs.api;

import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry;
import com.amazonaws.services.sqs.model.SendMessageBatchResult;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.amazonaws.services.sqs.model.SendMessageResult;
import java.util.List;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchResponse;
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;
import software.amazon.awssdk.services.sqs.model.SendMessageResponse;


/**
*
* @author Steve Millidge (Payara Foundation)
*/
public interface AmazonSQSConnection extends AutoCloseable {

public SendMessageResult sendMessage(SendMessageRequest request);
public SendMessageResult sendMessage(String queueURL, String messageBody);
public SendMessageBatchResult sendMessageBatch(String queueURL, List<SendMessageBatchRequestEntry> entries);
public SendMessageBatchResult sendMessageBatch(SendMessageBatchRequest batch);
public SendMessageResponse sendMessage(SendMessageRequest request);
public SendMessageResponse sendMessage(String queueURL, String messageBody);
public SendMessageBatchResponse sendMessageBatch(SendMessageBatchRequest batch);
public SendMessageBatchResponse sendMessageBatch(String queueURL, List<SendMessageBatchRequestEntry> entries);


}
Loading

0 comments on commit f339cc6

Please sign in to comment.