-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15334 from riyafa/jms
Add data binding support for Artemis Connector
- Loading branch information
Showing
51 changed files
with
1,542 additions
and
200 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
examples/artemis-anycast-session-consumer/artemis_anycast_session_consumer.out
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_multicast_consumer.bal' file and issue the | ||
# Navigate to the directory that contains the 'artemis_anycast_session_consumer.bal' file and execute the | ||
# 'ballerina run' command as follows. | ||
$ ballerina run artemis_multicast_consumer.bal | ||
# The ActiveMQ Artemis consumer runs as a Ballerina service and listens to the subscribed queue. | ||
$ ballerina run artemis_anycast_session_consumer.bal | ||
[ballerina/artemis] Client Consumer created for queue queue1 | ||
|
2 changes: 1 addition & 1 deletion
2
examples/artemis-anycast-session-producer/artemis_anycast_session_producer.out
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_anycast_session_producer.bal' file and issue the | ||
# Navigate to the directory that contains the 'artemis_anycast_session_producer.bal' file and execute the | ||
# 'ballerina run' command as follows. | ||
$ ballerina run artemis_anycast_session_producer.bal |
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,37 @@ | ||
import ballerina/artemis; | ||
import ballerina/http; | ||
import ballerina/log; | ||
|
||
type Order record { | ||
string description?; | ||
int id; | ||
float cost; | ||
}; | ||
|
||
// Consumer listens to the queue (i.e., "my_queue") with the address | ||
// (i.e., "my_address"). | ||
@artemis:ServiceConfig { | ||
queueConfig: { | ||
queueName: "my_queue", | ||
addressName: "my_address" | ||
} | ||
} | ||
// Attaches the service to the listener. | ||
service artemisConsumer on new artemis:Listener( | ||
{ host: "localhost", port: 61616 }) { | ||
|
||
// This resource is triggered when a valid `Order` is received. | ||
resource function onMessage(artemis:Message message, Order orderDetails) | ||
returns error? { | ||
|
||
// Posts order details to the backend and awaits response. | ||
http:Client clientEP = new("http://www.mocky.io"); | ||
var response = clientEP->post("/v2/5cde49ef3000005e004307f0", | ||
untaint check json.convert(orderDetails)); | ||
if (response is http:Response) { | ||
log:printInfo(check response.getTextPayload()); | ||
} else { | ||
log:printError("Invalid response ", err = response); | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/artemis-data-binding/artemis_data_binding.description
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,4 @@ | ||
// Artemis data binding helps access payload through the last resource | ||
// parameter. `string`, `json`, `xml`, `byte[]`, `record`, `map<string>`, `map<int>`, | ||
// `map<float>`, `map<byte>`, `map<byte[]>` and `map<boolean>` are supported as | ||
// parameter types. |
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,6 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_data_binding.bal' file | ||
# and execute the 'ballerina run' command as follows | ||
$ ballerina run artemis_data_binding.bal | ||
[ballerina/artemis] Client Consumer created for queue my_queue |
8 changes: 4 additions & 4 deletions
8
examples/artemis-multicast-consumer/artemis_multicast_consumer.out
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_multicast_consumer.bal' file and issue the | ||
# 'ballerina run' command. | ||
$ ballerina run artemis_multicast_consumer.bal as follows. | ||
# The ActiveMQ Artemis consumer runs as a Ballerina service and listens to the subscribed queue. | ||
# Navigate to the directory that contains the 'artemis_multicast_consumer.bal' file and execute the | ||
# 'ballerina run' command as follows. | ||
$ ballerina run artemis_multicast_consumer.bal | ||
[ballerina/artemis] Client Consumer created for queue my_queue | ||
|
2 changes: 1 addition & 1 deletion
2
examples/artemis-multicast-producer/artemis_multicast_producer.out
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_multicast_producer.bal' file and issue the | ||
# Navigate to the directory that contains the 'artemis_multicast_producer.bal' file and execute the | ||
# 'ballerina run' command as follows. | ||
$ ballerina run artemis_multicast_producer.bal |
7 changes: 2 additions & 5 deletions
7
examples/artemis-simple-transaction-consumer/artemis_simple_transaction_consumer.out
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
# Make sure to have the ActiveMQ Artemis broker running. | ||
|
||
# Navigate to the directory that contains the 'artemis_simple_transaction_consumer.bal' file and issue the | ||
# Navigate to the directory that contains the 'artemis_simple_transaction_consumer.bal' file and execute the | ||
# 'ballerina run' command as follows. | ||
$ ballerina run --experimental artemis_simple_transaction_consumer.bal | ||
# The ActiveMQ Artemis consumer runs as a Ballerina service and listens to the subscribed queue. | ||
|
||
[ballerina/http] started HTTP/WS endpoint 172.17.0.1:34985 | ||
2019-04-18 15:19:32,475 INFO [ballerina/transactions] - Created transaction: 29787878-3686-41b3-9ab3-4bc60ad278f6 | ||
2019-05-17 14:11:29,258 INFO [ballerina/transactions] - Created transaction: 78aabdba-3994-47cd-b083-80744961f69b |
2 changes: 1 addition & 1 deletion
2
examples/artemis-simple-transaction-producer/artemis_simple_transaction_producer.out
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
2 changes: 1 addition & 1 deletion
2
examples/artemis-transaction-producer/artemis_transaction_producer.out
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
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
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
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
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
90 changes: 90 additions & 0 deletions
90
...-artemis/src/main/java/org/ballerinalang/messaging/artemis/ArtemisConnectorException.java
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,90 @@ | ||
/* | ||
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you 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 | ||
* | ||
* http://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 org.ballerinalang.messaging.artemis; | ||
|
||
import org.ballerinalang.bre.Context; | ||
import org.ballerinalang.util.exceptions.BallerinaException; | ||
|
||
/** | ||
* BallerinaException that could occur in Artemis connector. | ||
* | ||
* @since 0.995 | ||
*/ | ||
public class ArtemisConnectorException extends BallerinaException { | ||
private static final long serialVersionUID = 381055783364464822L; | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with the specified detail message. | ||
* | ||
* @param message Error Message | ||
*/ | ||
public ArtemisConnectorException(String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with error message and ballerina context. | ||
* | ||
* @param message Error message | ||
* @param context Ballerina context | ||
*/ | ||
public ArtemisConnectorException(String message, Context context) { | ||
super(message, context); | ||
} | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with the specified detail message and cause. | ||
* | ||
* @param message Error message | ||
* @param cause Cause | ||
*/ | ||
public ArtemisConnectorException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with the specified detail message, | ||
* cause and ballerina context. | ||
* | ||
* @param message Error message | ||
* @param cause Cause | ||
* @param context Ballerina context | ||
*/ | ||
public ArtemisConnectorException(String message, Throwable cause, Context context) { | ||
super(message, cause, context); | ||
} | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with the cause. | ||
* | ||
* @param cause Throwable to be wrap by {@link ArtemisConnectorException} | ||
*/ | ||
public ArtemisConnectorException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
/** | ||
* Constructs a new {@link ArtemisConnectorException} with ballerina context. | ||
* | ||
* @param stack Ballerina context | ||
*/ | ||
public ArtemisConnectorException(Context stack) { | ||
super(stack); | ||
} | ||
} |
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
Oops, something went wrong.