Skip to content

Commit

Permalink
Merge pull request #912 from aashikam/deprecate
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam authored Apr 3, 2024
2 parents 3a9619f + d259897 commit f2ad02f
Show file tree
Hide file tree
Showing 45 changed files with 146 additions and 157 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:AnydataMessage message) {
}
}
```
Expand All @@ -135,13 +135,13 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onRequest(rabbitmq:Message message) returns string {
remote function onRequest(rabbitmq:AnydataMessage message) returns string {
return "Hello Back!";
}
}
```

The `rabbitmq:Message` record received can be used to retrieve its contents.
The `rabbitmq:AnydataMessage` record received can be used to retrieve its contents.

### Advanced usage

Expand All @@ -161,7 +161,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message, rabbitmq:Caller caller) {
remote function onMessage(rabbitmq:AnydataMessage message, rabbitmq:Caller caller) {
rabbitmq:Error? result = caller->basicAck();
}
}
Expand All @@ -176,7 +176,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:AnydataMessage message) {
rabbitmq:Error? result = caller->basicNack(true, requeue = false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "rabbitmq"
version = "2.10.1"
version = "3.0.0"
authors = ["Ballerina"]
keywords = ["service", "client", "messaging", "network", "pubsub"]
repository = "https://github.com/ballerina-platform/module-ballerinax-rabbitmq"
Expand All @@ -18,8 +18,8 @@ path = "./lib/amqp-client-5.18.0.jar"
[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "rabbitmq-native"
version = "2.10.1"
path = "../native/build/libs/rabbitmq-native-2.10.1-SNAPSHOT.jar"
version = "3.0.0"
path = "../native/build/libs/rabbitmq-native-3.0.0-SNAPSHOT.jar"

[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "rabbitmq-compiler-plugin"
class = "io.ballerina.stdlib.rabbitmq.plugin.RabbitmqCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/rabbitmq-compiler-plugin-2.10.1-SNAPSHOT.jar"
path = "../compiler-plugin/build/libs/rabbitmq-compiler-plugin-3.0.0-SNAPSHOT.jar"
7 changes: 3 additions & 4 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "cache"
version = "3.7.1"
version = "3.7.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "constraint"},
Expand Down Expand Up @@ -71,7 +71,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.6"
version = "2.10.11"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -322,7 +322,6 @@ modules = [
org = "ballerina"
name = "time"
version = "2.4.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down Expand Up @@ -387,7 +386,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "rabbitmq"
version = "2.10.1"
version = "3.0.0"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "crypto"},
Expand Down
10 changes: 5 additions & 5 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:AnydataMessage message) {
}
}
```
Expand All @@ -128,13 +128,13 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onRequest(rabbitmq:Message message) returns string {
remote function onRequest(rabbitmq:AnydataMessage message) returns string {
return "Hello Back!";
}
}
```

The `rabbitmq:Message` record received can be used to retrieve its contents.
The `rabbitmq:AnydataMessage` record received can be used to retrieve its contents.

### Advanced usage

Expand All @@ -154,7 +154,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message, rabbitmq:Caller caller) {
remote function onMessage(rabbitmq:BytesMessage message, rabbitmq:Caller caller) {
rabbitmq:Error? result = caller->basicAck();
}
}
Expand All @@ -169,7 +169,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:BytesMessage message) {
rabbitmq:Error? result = caller->basicNack(true, requeue = false);
}
}
Expand Down
10 changes: 5 additions & 5 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:BytesMessage message) {
}
}
```
Expand All @@ -128,13 +128,13 @@ The most efficient way to receive messages is to set up a subscription using a B
queueName: "MyQueue"
}
service rabbitmq:Service on channelListener {
remote function onRequest(rabbitmq:Message message) returns string {
remote function onRequest(rabbitmq:BytesMessage message) returns string {
return "Hello Back!";
}
}
```

The `rabbitmq:Message` record received can be used to retrieve its contents.
The `rabbitmq:BytesMessage` record received can be used to retrieve its contents.

### Advanced usage

Expand All @@ -154,7 +154,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message, rabbitmq:Caller caller) {
remote function onMessage(rabbitmq:BytesMessage message, rabbitmq:Caller caller) {
rabbitmq:Error? result = caller->basicAck();
}
}
Expand All @@ -169,7 +169,7 @@ The default acknowledgement mode is auto-ack (messages are acknowledged immediat
autoAck: false
}
service rabbitmq:Service on channelListener {
remote function onMessage(rabbitmq:Message message) {
remote function onMessage(rabbitmq:BytesMessage message) {
rabbitmq:Error? result = caller->basicNack(true, requeue = false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions ballerina/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public isolated client class Client {
# + queueName - The name of the queue
# + autoAck - If false, should manually acknowledge
# + T - Optional type description of the required data type
# + return - A `rabbitmq:Message` object containing the retrieved message data or else a`rabbitmq:Error` if an
# + return - A `rabbitmq:AnydataMessage` object containing the retrieved message data or else a`rabbitmq:Error` if an
# I/O error occurred
isolated remote function consumeMessage(string queueName, boolean autoAck = true, typedesc<AnydataMessage> T = <>)
returns T|Error =
Expand Down Expand Up @@ -162,7 +162,7 @@ public isolated client class Client {
# + multiple - Set to `true` to acknowledge all messages up to and including the called on message and
# `false` to acknowledge just the called on message
# + return - A `rabbitmq:Error` if an I/O error occurred or else `()`
isolated remote function basicAck(Message|AnydataMessage message, boolean multiple = false) returns Error? =
isolated remote function basicAck(AnydataMessage message, boolean multiple = false) returns Error? =
@java:Method {
'class: "io.ballerina.stdlib.rabbitmq.util.ChannelUtils"
} external;
Expand All @@ -177,7 +177,7 @@ public isolated client class Client {
# `false` to reject just the called on message
# + requeue - `true` if the rejected message(s) should be re-queued rather than discarded/dead-lettered
# + return - A `rabbitmq:Error` if an I/O error occurred or else `()`
isolated remote function basicNack(Message|AnydataMessage message, boolean multiple = false, boolean requeue = true)
isolated remote function basicNack(AnydataMessage message, boolean multiple = false, boolean requeue = true)
returns Error? =
@java:Method {
'class: "io.ballerina.stdlib.rabbitmq.util.ChannelUtils"
Expand Down
15 changes: 0 additions & 15 deletions ballerina/message.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,6 @@
// specific language governing permissions and limitations
// under the License.

# Represents the message, which a RabbitMQ server sends to its subscribed services.
#
# + content - The content of the message
# + routingKey - The routing key to which the message is sent
# + exchange - The exchange to which the message is sent. The default exchange is a direct exchange with no name (empty string) pre-declared by the broker.
# + deliveryTag - The delivery tag of the message
# + properties - Basic properties of the message - routing headers etc.
@deprecated
public type Message record {|
byte[] content;
string routingKey;
string exchange = "";
int deliveryTag?;
BasicProperties properties?;
|};

# Represents the anydata message, which a RabbitMQ server sends to its subscribed services.
#
Expand Down
8 changes: 4 additions & 4 deletions ballerina/tests/consume_constraint_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function intMinValueConstraintListenerMessageTest() returns error? {
log:printInfo("The message received: " + message.toString());
}

remote function onError(Message msg, Error e) {
remote function onError(BytesMessage msg, Error e) {
if e is PayloadValidationError {
receivedIntMinValueConstraintError = e.message();
}
Expand Down Expand Up @@ -237,7 +237,7 @@ function intMaxValueConstraintListenerMessageTest() returns error? {
log:printInfo("The message received: " + message.toString());
}

remote function onError(Message msg, Error e) {
remote function onError(BytesMessage msg, Error e) {
if e is PayloadValidationError {
receivedIntMaxValueConstraintError = e.message();
}
Expand All @@ -264,7 +264,7 @@ function numberMaxValueConstraintListenerPayloadTest() returns error? {
log:printInfo("The message received: " + message.toString());
}

remote function onError(Message msg, Error e) {
remote function onError(BytesMessage msg, Error e) {
if e is PayloadValidationError {
receivedNumberMaxValueConstraintError = e.message();
}
Expand All @@ -291,7 +291,7 @@ function numberMinValueConstraintListenerPayloadTest() returns error? {
log:printInfo("The message received: " + message.toString());
}

remote function onError(Message msg, Error e) {
remote function onError(BytesMessage msg, Error e) {
if e is PayloadValidationError {
receivedNumberMinValueConstraintError = e.message();
}
Expand Down
4 changes: 2 additions & 2 deletions ballerina/tests/data_binding_listener_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public function testListenerDataBindingError() returns error? {
log:printInfo("The message received: " + intMessage.toString());
}

remote function onError(Message msg, Error e) returns Error? {
remote function onError(BytesMessage msg, Error e) returns Error? {
if e.message().includes("ConversionError", 0) {
receivedErrorCount += 1;
}
Expand Down Expand Up @@ -739,7 +739,7 @@ public function testListenerRequestDataBindingError() returns error? {
return "Hello Back!!";
}

remote function onError(Message msg, Error e) returns Error? {
remote function onError(BytesMessage msg, Error e) returns Error? {
if e.message().includes("ConversionError", 0) {
receivedErrorCount += 1;
}
Expand Down
22 changes: 11 additions & 11 deletions ballerina/tests/data_binding_publish_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function stringPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_STRING_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_STRING_PUBLISH_QUEUE);
string receivedContent = check string:fromBytes(receivedMessage.content);
test:assertEquals(receivedContent, content);
check 'client->close();
Expand All @@ -41,7 +41,7 @@ function intPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_INT_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_INT_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
int receivedContent = check int:fromString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -57,7 +57,7 @@ function floatPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_FLOAT_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_FLOAT_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
float receivedContent = check float:fromString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -73,7 +73,7 @@ function decimalPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_DECIMAL_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_DECIMAL_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
decimal receivedContent = check decimal:fromString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -89,7 +89,7 @@ function booleanPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_BOOLEAN_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_BOOLEAN_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
boolean receivedContent = check boolean:fromString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -104,7 +104,7 @@ function recordPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_RECORD_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_RECORD_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
Person receivedContent = check value:fromJsonStringWithType(receivedString);
test:assertEquals(receivedContent, personRecord);
Expand All @@ -119,7 +119,7 @@ function mapPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_MAP_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_MAP_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
map<Person> receivedContent = check value:fromJsonStringWithType(receivedString);
test:assertEquals(receivedContent, personMap);
Expand All @@ -137,7 +137,7 @@ function tablePublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_TABLE_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_TABLE_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
table<Person> receivedContent = check value:fromJsonStringWithType(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -153,7 +153,7 @@ function xmlPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_XML_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_XML_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
xml receivedContent = check xml:fromString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -170,7 +170,7 @@ function jsonPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_JSON_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_JSON_PUBLISH_QUEUE);
string receivedString = check string:fromBytes(receivedMessage.content);
json receivedContent = check value:fromJsonString(receivedString);
test:assertEquals(receivedContent, content);
Expand All @@ -187,7 +187,7 @@ function bytesPublishTest() returns error? {
};
Client 'client = check new (DEFAULT_HOST, DEFAULT_PORT);
check 'client->publishMessage(message);
Message receivedMessage = check 'client->consumeMessage(DATA_BINDING_BYTES_PUBLISH_QUEUE);
BytesMessage receivedMessage = check 'client->consumeMessage(DATA_BINDING_BYTES_PUBLISH_QUEUE);
test:assertEquals(receivedMessage.content, content);
check 'client->close();
}
Loading

0 comments on commit f2ad02f

Please sign in to comment.