From 704c0ef890e1781ce42023d75ff78f4523ab3726 Mon Sep 17 00:00:00 2001 From: aashikam Date: Thu, 28 Mar 2024 21:05:03 +0530 Subject: [PATCH 1/7] [Automated] Update the native jar versions --- ballerina/Dependencies.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index d0a2250f..b2fb8995 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -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"}, @@ -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"}, @@ -322,7 +322,6 @@ modules = [ org = "ballerina" name = "time" version = "2.4.0" -scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] From e5cf87685889a90c52bb3a25669e610ac7ca93cb Mon Sep 17 00:00:00 2001 From: aashikam Date: Thu, 28 Mar 2024 21:24:48 +0530 Subject: [PATCH 2/7] Remove rabbitmq:Message usages --- ballerina/Module.md | 10 ++-- ballerina/Package.md | 10 ++-- ballerina/client.bal | 6 +-- ballerina/message.bal | 15 ------ ballerina/tests/consume_constraint_tests.bal | 8 ++-- .../tests/data_binding_listener_tests.bal | 4 +- .../tests/data_binding_publish_tests.bal | 22 ++++----- .../tests/rabbitmq_client_negative_tests.bal | 12 ++--- ballerina/tests/rabbitmq_client_tests.bal | 48 +++++++++---------- ballerina/tests/readonly_msg_tests.bal | 10 ++-- .../invalid_service_10/service.bal | 4 +- .../invalid_service_11/service.bal | 4 +- .../invalid_service_12/service.bal | 4 +- .../invalid_service_13/service.bal | 8 ++-- .../invalid_service_14/service.bal | 2 +- .../invalid_service_15/service.bal | 2 +- .../invalid_service_2/service.bal | 4 +- .../invalid_service_22/service.bal | 2 +- .../invalid_service_3/service.bal | 2 +- .../invalid_service_4/service.bal | 8 ++-- .../invalid_service_8/service.bal | 6 +-- .../invalid_service_9/service.bal | 4 +- .../valid_service_1/service.bal | 6 +-- .../valid_service_10/service.bal | 4 +- .../valid_service_2/service.bal | 10 ++-- .../valid_service_3/service.bal | 16 +++---- .../valid_service_4/service.bal | 2 +- .../valid_service_5/service.bal | 2 +- .../valid_service_6/service.bal | 4 +- .../valid_service_7/service.bal | 2 +- .../expected_sources/service_1/result.bal | 2 +- .../expected_sources/service_2/result.bal | 2 +- .../rabbitmq/plugin/PluginConstants.java | 4 +- .../rabbitmq/plugin/RabbitmqCodeTemplate.java | 3 +- 34 files changed, 119 insertions(+), 133 deletions(-) diff --git a/ballerina/Module.md b/ballerina/Module.md index b7bb99b0..63ce2d1d 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -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) { } } ``` @@ -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 @@ -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(); } } @@ -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); } } diff --git a/ballerina/Package.md b/ballerina/Package.md index 1f104316..429f8497 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -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) { } } ``` @@ -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 @@ -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(); } } @@ -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); } } diff --git a/ballerina/client.bal b/ballerina/client.bal index 4ee03a22..06548b3a 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -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 T = <>) returns T|Error = @@ -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; @@ -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" diff --git a/ballerina/message.bal b/ballerina/message.bal index 900cb62b..05d53ed1 100644 --- a/ballerina/message.bal +++ b/ballerina/message.bal @@ -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. # diff --git a/ballerina/tests/consume_constraint_tests.bal b/ballerina/tests/consume_constraint_tests.bal index 1103ebd0..930c3285 100644 --- a/ballerina/tests/consume_constraint_tests.bal +++ b/ballerina/tests/consume_constraint_tests.bal @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); } diff --git a/ballerina/tests/data_binding_listener_tests.bal b/ballerina/tests/data_binding_listener_tests.bal index 9496b903..6c9e5c35 100644 --- a/ballerina/tests/data_binding_listener_tests.bal +++ b/ballerina/tests/data_binding_listener_tests.bal @@ -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; } @@ -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; } diff --git a/ballerina/tests/data_binding_publish_tests.bal b/ballerina/tests/data_binding_publish_tests.bal index 4ccf9dfa..abbe2260 100644 --- a/ballerina/tests/data_binding_publish_tests.bal +++ b/ballerina/tests/data_binding_publish_tests.bal @@ -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(); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 receivedContent = check value:fromJsonStringWithType(receivedString); test:assertEquals(receivedContent, personMap); @@ -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 receivedContent = check value:fromJsonStringWithType(receivedString); test:assertEquals(receivedContent, content); @@ -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); @@ -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); @@ -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(); } diff --git a/ballerina/tests/rabbitmq_client_negative_tests.bal b/ballerina/tests/rabbitmq_client_negative_tests.bal index a6d6c1c5..ccf02e47 100644 --- a/ballerina/tests/rabbitmq_client_negative_tests.bal +++ b/ballerina/tests/rabbitmq_client_negative_tests.bal @@ -110,8 +110,8 @@ public isolated function testClientConsumeNegative() returns error? { check newClient->queueDeclare(queue); check newClient->publishMessage({ content: message.toBytes(), routingKey: queue }); check newClient->close(); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { test:assertFail("Error expected when trying to consume messages using client."); } return; @@ -127,8 +127,8 @@ public isolated function testClientBasicAckNegative() returns error? { Client newClient = check new(DEFAULT_HOST, DEFAULT_PORT); check newClient->queueDeclare(queue); check newClient->publishMessage({ content: message.toBytes(), routingKey: queue }); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); log:printInfo("The message received: " + messageContent); test:assertEquals(messageContent, message, msg = "Message received does not match."); @@ -153,8 +153,8 @@ public isolated function testClientBasicNackNegative() returns error? { Client newClient = check new(DEFAULT_HOST, DEFAULT_PORT); check newClient->queueDeclare(queue); check newClient->publishMessage({ content: message.toBytes(), routingKey: queue }); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); test:assertEquals(messageContent, message, msg = "Message received does not match."); log:printInfo("The message received: " + messageContent); diff --git a/ballerina/tests/rabbitmq_client_tests.bal b/ballerina/tests/rabbitmq_client_tests.bal index 554d2017..8207c7ab 100644 --- a/ballerina/tests/rabbitmq_client_tests.bal +++ b/ballerina/tests/rabbitmq_client_tests.bal @@ -324,8 +324,8 @@ public function testClientVhost2() returns error? { } check newClient->queueDeclare(QUEUE_NAME); check newClient->publishMessage({content: message.toBytes(), routingKey: QUEUE_NAME}); - Message|Error consumeResult = newClient->consumeMessage(QUEUE_NAME, true); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(QUEUE_NAME, true); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); log:printInfo("The message received: " + messageContent); test:assertEquals(messageContent, message, msg = "Message received does not match."); @@ -364,8 +364,8 @@ public isolated function testProducerTransactional() returns error? { test:assertFail(msg = "Commit failed for transactional producer."); } } - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); log:printInfo("The message received: " + messageContent); test:assertEquals(messageContent, message, msg = "Message received does not match."); @@ -428,8 +428,8 @@ public isolated function testProducerTransactionalRollback() returns error? { string queue = "testProducerTransactionalRollback"; Client newClient = check new (DEFAULT_HOST, DEFAULT_PORT); error? rollbackError = rabbitMQTransactionFail(queue); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { test:assertFail("Rolled back message is in queue."); } return newClient->close(); @@ -494,7 +494,7 @@ public function testSyncConsumer() returns error? { check produceMessage(message, QUEUE); Client? channelObj = rabbitmqChannel; if channelObj is Client { - Message getResult = check channelObj->consumeMessage(QUEUE); + BytesMessage getResult = check channelObj->consumeMessage(QUEUE); string messageContent = check 'string:fromBytes(getResult.content); test:assertEquals(messageContent, message, msg = "Message received does not match."); } @@ -736,8 +736,8 @@ public isolated function testClientBasicAck() returns error? { Client newClient = check new (DEFAULT_HOST, DEFAULT_PORT); check newClient->queueDeclare(queue); check newClient->publishMessage({content: message.toBytes(), routingKey: queue}); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); log:printInfo("The message received: " + messageContent); test:assertEquals(messageContent, message, msg = "Message received does not match."); @@ -784,8 +784,8 @@ public isolated function testClientBasicNack() returns error? { Client newClient = check new (DEFAULT_HOST, DEFAULT_PORT); check newClient->queueDeclare(queue); check newClient->publishMessage({content: message.toBytes(), routingKey: queue}); - Message|Error consumeResult = newClient->consumeMessage(queue, false); - if consumeResult is Message { + BytesMessage|Error consumeResult = newClient->consumeMessage(queue, false); + if consumeResult is BytesMessage { string messageContent = check 'string:fromBytes(consumeResult.content); test:assertEquals(messageContent, message, msg = "Message received does not match."); log:printInfo("The message received: " + messageContent); @@ -991,7 +991,7 @@ Service asyncTestService = queueName: QUEUE } service object { - remote function onMessage(Message message) { + remote function onMessage(BytesMessage message) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { asyncConsumerMessage = messageContent; @@ -1001,7 +1001,7 @@ service object { } } - remote function onRequest(Message message) returns string { + remote function onRequest(BytesMessage message) returns string { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { asyncConsumerMessage = messageContent; @@ -1018,7 +1018,7 @@ Service asyncTestService2 = queueName: REQ_QUEUE } service object { - remote function onRequest(Message message, Caller caller) returns string { + remote function onRequest(BytesMessage message, Caller caller) returns string { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { onRequestMessage = messageContent; @@ -1032,7 +1032,7 @@ service object { Service asyncTestService3 = service object { - remote function onMessage(Message message) { + remote function onMessage(BytesMessage message) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { asyncConsumerMessage2 = messageContent; @@ -1049,7 +1049,7 @@ Service ackTestService = autoAck: false } service object { - remote isolated function onMessage(Message message, Caller caller) { + remote isolated function onMessage(BytesMessage message, Caller caller) { checkpanic caller->basicAck(); } }; @@ -1060,7 +1060,7 @@ Service ackTestService2 = autoAck: true } service object { - remote function onMessage(Message message, Caller caller) { + remote function onMessage(BytesMessage message, Caller caller) { error? ackResult = caller->basicAck(); if ackResult is error { negativeAck = true; @@ -1074,7 +1074,7 @@ Service ackTestService3 = autoAck: false } service object { - remote function onMessage(Message message, Caller caller) { + remote function onMessage(BytesMessage message, Caller caller) { error? ackResult = caller->basicAck(); error? ackResult2 = caller->basicAck(); if ackResult2 is error { @@ -1089,7 +1089,7 @@ Service nackTestService2 = autoAck: true } service object { - remote function onMessage(Message message, Caller caller) { + remote function onMessage(BytesMessage message, Caller caller) { error? ackResult = caller->basicNack(false, false); if ackResult is error { negativeNack = true; @@ -1103,7 +1103,7 @@ Service nackTestService3 = autoAck: false } service object { - remote function onMessage(Message message, Caller caller) { + remote function onMessage(BytesMessage message, Caller caller) { error? ackResult = caller->basicNack(false, false); error? ackResult2 = caller->basicNack(false, false); if ackResult2 is error { @@ -1118,7 +1118,7 @@ Service nackTestService = autoAck: false } service object { - remote isolated function onMessage(Message message, Caller caller) { + remote isolated function onMessage(BytesMessage message, Caller caller) { checkpanic caller->basicNack(false, false); } }; @@ -1128,7 +1128,7 @@ Service mockService = queueName: MOCK_QUEUE } service object { - remote function onMessage(Message message) { + remote function onMessage(BytesMessage message) { } }; @@ -1137,7 +1137,7 @@ Service replyService = queueName: REPLYTO } service object { - remote function onMessage(Message message) { + remote function onMessage(BytesMessage message) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { replyMessage = messageContent; @@ -1153,7 +1153,7 @@ Service replyService2 = queueName: REQ_REPLYTO } service object { - remote function onMessage(Message message) { + remote function onMessage(BytesMessage message) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { reqReplyMessage = messageContent; diff --git a/ballerina/tests/readonly_msg_tests.bal b/ballerina/tests/readonly_msg_tests.bal index 7d168fae..c0634e68 100644 --- a/ballerina/tests/readonly_msg_tests.bal +++ b/ballerina/tests/readonly_msg_tests.bal @@ -29,7 +29,7 @@ string readOnlyConsumerRequestCaller = ""; groups: ["rabbitmq"] } public function testConsumerReadOnlyMessage() returns error? { - string message = "Testing Async Consumer with ReadOnly Message"; + string message = "Testing Async Consumer with ReadOnly BytesMessage"; check produceMessage(message, READONLY_MESSAGE_QUEUE); Listener? channelListener = rabbitmqListener; if channelListener is Listener { @@ -97,7 +97,7 @@ Service readOnlyMessageService = queueName: READONLY_MESSAGE_QUEUE } service object { - remote function onMessage(readonly & Message message) { + remote function onMessage(readonly & BytesMessage message) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { readOnlyConsumerMessage = messageContent; @@ -113,7 +113,7 @@ Service readOnlyMessageService2 = queueName: READONLY_MESSAGE_QUEUE_CALLER } service object { - remote function onMessage(readonly & Message message, Caller caller) { + remote function onMessage(readonly & BytesMessage message, Caller caller) { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { readOnlyConsumerMessageCaller = messageContent; @@ -129,7 +129,7 @@ Service readOnlyMessageServiceRequest = queueName: READONLY_REQUEST_QUEUE } service object { - remote function onRequest(readonly & Message message) returns string { + remote function onRequest(readonly & BytesMessage message) returns string { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { readOnlyConsumerRequest = messageContent; @@ -146,7 +146,7 @@ Service readOnlyMessageServiceRequest2 = queueName: READONLY_REQUEST_QUEUE_CALLER } service object { - remote function onRequest(readonly & Message message, Caller caller) returns string { + remote function onRequest(readonly & BytesMessage message, Caller caller) returns string { string|error messageContent = 'string:fromBytes(message.content); if messageContent is string { readOnlyConsumerRequestCaller = messageContent; diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_10/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_10/service.bal index b57c7aaa..5fd536f1 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_10/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_10/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message) returns rabbitmq:Listener|error { + remote function onRequest(rabbitmq:AnydataMessage message) returns rabbitmq:Listener|error { return channelListener; } } @@ -32,6 +32,6 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message) returns rabbitmq:Client? { + remote function onRequest(rabbitmq:AnydataMessage message) returns rabbitmq:Client? { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_11/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_11/service.bal index 09314972..16b33f7d 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_11/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_11/service.bal @@ -23,9 +23,9 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message) { + remote function onError(rabbitmq:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_12/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_12/service.bal index c5dd51ed..73bf35ce 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_12/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_12/service.bal @@ -23,9 +23,9 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Error err, string something) { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Error err, string something) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_13/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_13/service.bal index 7ff2f25b..b113421d 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_13/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_13/service.bal @@ -23,10 +23,10 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, string err) { + remote function onError(rabbitmq:AnydataMessage message, string err) { } } @@ -34,9 +34,9 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Client err) { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Client err) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_14/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_14/service.bal index 4ec7f018..c33b0f35 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_14/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_14/service.bal @@ -25,6 +25,6 @@ listener rabbitmq:Listener channelListener2 = queueName: "MyQueue" } service rabbitmq:Service on channelListener1, channelListener2 { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_15/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_15/service.bal index bb95b28b..050b7800 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_15/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_15/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } resource function get greeting() returns string { diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_2/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_2/service.bal index 357f6527..db423df4 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_2/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_2/service.bal @@ -23,9 +23,9 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onRequest(rabbitmq:Message message) { + remote function onRequest(rabbitmq:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_22/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_22/service.bal index 5556866f..16f83712 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_22/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_22/service.bal @@ -23,6 +23,6 @@ listener rabbitmq:Listener channelListener = label: "rabbitmqService" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_3/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_3/service.bal index f2fc6057..5fa85ba3 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_3/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_3/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } remote function someFunction() {} diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_4/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_4/service.bal index 66386a03..a2606f05 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_4/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_4/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - function onMessage(rabbitmq:Message message) { + function onMessage(rabbitmq:AnydataMessage message) { } } @@ -31,7 +31,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - function onRequest(rabbitmq:Message message) { + function onRequest(rabbitmq:AnydataMessage message) { } } @@ -39,8 +39,8 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - function onError(rabbitmq:Message msg, rabbitmq:Error err) {} + function onError(rabbitmq:AnydataMessage msg, rabbitmq:Error err) {} } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_8/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_8/service.bal index 1284f47f..b39fb028 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_8/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_8/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) returns string { + remote function onMessage(rabbitmq:AnydataMessage message) returns string { return "Hello"; } } @@ -32,9 +32,9 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message msg, rabbitmq:Error err) returns string? { + remote function onError(rabbitmq:AnydataMessage msg, rabbitmq:Error err) returns string? { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_9/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_9/service.bal index 93eb0039..69765dae 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_9/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_service_9/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } remote function onError(string msg, rabbitmq:Error err) { @@ -34,7 +34,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } remote function onError(rabbitmq:Caller msg, rabbitmq:Error err) { diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_1/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_1/service.bal index b6555863..9760a405 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_1/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_1/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } } @@ -31,7 +31,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns error? { } } @@ -39,6 +39,6 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) returns rabbitmq:Error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns rabbitmq:Error? { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_10/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_10/service.bal index e33cccdc..b0dd66d2 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_10/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_10/service.bal @@ -26,7 +26,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns error? { } } @@ -34,6 +34,6 @@ service rabbitmq:Service on channelListener { label: "natsService" } service "MyQueue" on channelListener { - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns error? { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_2/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_2/service.bal index 293b72bd..1de7b76a 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_2/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_2/service.bal @@ -23,7 +23,7 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message) { + remote function onRequest(rabbitmq:AnydataMessage message) { } } @@ -31,7 +31,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message) returns string? { + remote function onRequest(rabbitmq:AnydataMessage message) returns string? { } } @@ -39,7 +39,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message, rabbitmq:Caller caller) returns anydata { + remote function onRequest(rabbitmq:AnydataMessage message, rabbitmq:Caller caller) returns anydata { } } @@ -47,7 +47,7 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onRequest(rabbitmq:Message message) returns error? { + remote function onRequest(rabbitmq:AnydataMessage message) returns error? { } } @@ -55,7 +55,7 @@ service rabbitmq:Service on channelListener { 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"; } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_3/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_3/service.bal index a527e428..6893a5eb 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_3/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_3/service.bal @@ -23,10 +23,10 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Error err) { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Error err) { } } @@ -34,10 +34,10 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Error err) returns error? { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Error err) returns error? { } } @@ -45,10 +45,10 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Error err) returns rabbitmq:Error? { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Error err) returns rabbitmq:Error? { } } @@ -56,9 +56,9 @@ service rabbitmq:Service on channelListener { queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } - remote function onError(rabbitmq:Message message, rabbitmq:Error err) returns ()|rabbitmq:Error { + remote function onError(rabbitmq:AnydataMessage message, rabbitmq:Error err) returns ()|rabbitmq:Error { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_4/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_4/service.bal index 38b28bdb..13838e9a 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_4/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_4/service.bal @@ -23,6 +23,6 @@ listener foo:Listener channelListener = queueName: "MyQueue" } service foo:Service on channelListener { - remote function onMessage(foo:Message message) { + remote function onMessage(foo:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_5/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_5/service.bal index 11a813de..97302bbc 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_5/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_5/service.bal @@ -18,7 +18,7 @@ import ballerinax/rabbitmq; listener rabbitmq:Listener channelListener = new(rabbitmq:DEFAULT_HOST, rabbitmq:DEFAULT_PORT); -type Foo rabbitmq:Message; +type Foo rabbitmq:AnydataMessage; @rabbitmq:ServiceConfig { queueName: "MyQueue" diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_6/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_6/service.bal index 10fee5ef..2b0e0bad 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_6/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_6/service.bal @@ -26,7 +26,7 @@ service rabbitmq:Service on channelListener { rabbitmq:Client newClient = checkpanic new (rabbitmq:DEFAULT_HOST, rabbitmq:DEFAULT_PORT); - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:AnydataMessage message) { } } @@ -36,6 +36,6 @@ service rabbitmq:Service on channelListener { service rabbitmq:Service on channelListener { string hello = "Hello"; - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns error? { } } diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_7/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_7/service.bal index d873bd07..129b648d 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_7/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/valid_service_7/service.bal @@ -23,6 +23,6 @@ listener rabbitmq:Listener channelListener = queueName: "MyQueue" } service rabbitmq:Service on channelListener { - remote function onMessage(readonly & rabbitmq:Message message) { + remote function onMessage(readonly & rabbitmq:AnydataMessage message) { } } diff --git a/compiler-plugin-tests/src/test/resources/expected_sources/service_1/result.bal b/compiler-plugin-tests/src/test/resources/expected_sources/service_1/result.bal index 87b09124..136399fa 100644 --- a/compiler-plugin-tests/src/test/resources/expected_sources/service_1/result.bal +++ b/compiler-plugin-tests/src/test/resources/expected_sources/service_1/result.bal @@ -3,7 +3,7 @@ import ballerinax/rabbitmq; listener rabbitmq:Listener rabbitListener = new(rabbitmq:DEFAULT_HOST, rabbitmq:DEFAULT_PORT); service "demo" on rabbitListener { - remote function onMessage(rabbitmq:Message message) returns rabbitmq:Error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns rabbitmq:Error? { } } diff --git a/compiler-plugin-tests/src/test/resources/expected_sources/service_2/result.bal b/compiler-plugin-tests/src/test/resources/expected_sources/service_2/result.bal index 17acfb84..7b630ad0 100644 --- a/compiler-plugin-tests/src/test/resources/expected_sources/service_2/result.bal +++ b/compiler-plugin-tests/src/test/resources/expected_sources/service_2/result.bal @@ -5,7 +5,7 @@ listener rabbitmq:Listener rabbitListener = new(rabbitmq:DEFAULT_HOST, rabbitmq: service "demo" on rabbitListener { int x = 5; string hello = "hello"; - remote function onMessage(rabbitmq:Message message) returns rabbitmq:Error? { + remote function onMessage(rabbitmq:AnydataMessage message) returns rabbitmq:Error? { } } diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/PluginConstants.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/PluginConstants.java index 8f45f7e8..380ca20c 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/PluginConstants.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/PluginConstants.java @@ -72,7 +72,7 @@ enum CompilationErrors { INVALID_FUNCTION("Resource functions are not allowed.", "RABBITMQ_104"), FUNCTION_SHOULD_BE_REMOTE("Method must have the remote qualifier.", "RABBITMQ_105"), MUST_HAVE_MESSAGE("Must have the method parameter rabbitmq:AnydataMessage.", "RABBITMQ_106"), - MUST_HAVE_MESSAGE_AND_ERROR("Must have the method parameters rabbitmq:Message and rabbitmq:Error.", + MUST_HAVE_MESSAGE_AND_ERROR("Must have the method parameters rabbitmq:AnydataMessage and rabbitmq:Error.", "RABBITMQ_107"), INVALID_FUNCTION_PARAM_MESSAGE_OR_PAYLOAD("Invalid method parameter. Only subtypes of " + "rabbitmq:AnydataMessage or subtypes of anydata are allowed.", "RABBITMQ_108"), @@ -88,7 +88,7 @@ enum CompilationErrors { "RABBITMQ_113"), ONLY_PARAMS_ALLOWED("Invalid method parameter count. Only subtypes of rabbitmq:AnydataMessage, " + "subtypes of anydata and rabbitmq:Caller are allowed.", "RABBITMQ_114"), - ONLY_PARAMS_ALLOWED_ON_ERROR("Invalid method parameter count. Only rabbitmq:Message and " + + ONLY_PARAMS_ALLOWED_ON_ERROR("Invalid method parameter count. Only rabbitmq:AnydataMessage and " + "rabbitmq:Error are allowed.", "RABBITMQ_115"), INVALID_RETURN_TYPE_ERROR_OR_NIL("Invalid return type. Only error? or rabbitmq:Error? is allowed.", "RABBITMQ_116"), diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/RabbitmqCodeTemplate.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/RabbitmqCodeTemplate.java index 6aa08ce7..16825ad0 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/RabbitmqCodeTemplate.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/rabbitmq/plugin/RabbitmqCodeTemplate.java @@ -48,7 +48,8 @@ public class RabbitmqCodeTemplate implements CodeAction { public static final String NODE_LOCATION = "node.location"; public static final String LS = System.lineSeparator(); - public static final String REMOTE_FUNCTION_TEXT = LS + "\tremote function onMessage(rabbitmq:Message message)" + + public static final String REMOTE_FUNCTION_TEXT = LS + + "\tremote function onMessage(rabbitmq:AnydataMessage message)" + " returns rabbitmq:Error? {" + LS + LS + "\t}" + LS; @Override From d40c11cb9c27def5059796a0ec47d5d87cd070c5 Mon Sep 17 00:00:00 2001 From: aashikam Date: Thu, 28 Mar 2024 21:25:20 +0530 Subject: [PATCH 3/7] Update major version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d81cc6c4..96b0eca0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.stdlib -version=2.10.1-SNAPSHOT +version=3.0.0-SNAPSHOT ballerinaLangVersion=2201.8.0 amqpClientVersion=5.18.0 From 75b7b2f88bee31fa51231f046f60570b413d2bfa Mon Sep 17 00:00:00 2001 From: aashikam Date: Thu, 28 Mar 2024 21:29:04 +0530 Subject: [PATCH 4/7] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 91bb5a49..78ecb3c6 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -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" @@ -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" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index a9a77107..97dbe606 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -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" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index b2fb8995..76d31ee6 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -386,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"}, From f80af85c3c9a5540c2dfe16992700ef167c9b2eb Mon Sep 17 00:00:00 2001 From: aashikam Date: Thu, 28 Mar 2024 21:58:38 +0530 Subject: [PATCH 5/7] Update docs --- README.md | 10 +++++----- changelog.md | 5 +++++ docs/spec/spec.md | 2 +- .../rabbitmq-hub/A Websub Hub Based on RabbitMQ.md | 2 +- examples/rabbitmq-hub/hub/start_hub.bal | 12 ++++++------ load-tests/simple_producer_consumer/src/main.bal | 2 +- .../ballerina/stdlib/rabbitmq/RabbitMQConstants.java | 1 - 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 071c667b..09f4faca 100644 --- a/README.md +++ b/README.md @@ -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) { } } ``` @@ -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 @@ -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(); } } @@ -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); } } diff --git a/changelog.md b/changelog.md index 2eb34b7c..8d1e6fbc 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Changed +- [[#5069] Remove the definition and the usages of the deprecated rabbitmq:Message record](https://github.com/ballerina-platform/ballerina-library/issues/5069) + +## [2.10.0] - 2023-09-18 + ### Changed - [[#4734] Changed disallowing service level annotations in the compiler plugin](https://github.com/ballerina-platform/ballerina-standard-library/issues/4734) diff --git a/docs/spec/spec.md b/docs/spec/spec.md index 32a5b908..8de66d8f 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -541,7 +541,7 @@ It is also possible to retrieve individual messages on demand ("pull API" a.k.a. # + 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 T = <>) returns T|Error; diff --git a/examples/rabbitmq-hub/A Websub Hub Based on RabbitMQ.md b/examples/rabbitmq-hub/A Websub Hub Based on RabbitMQ.md index 97a8e6df..76761973 100644 --- a/examples/rabbitmq-hub/A Websub Hub Based on RabbitMQ.md +++ b/examples/rabbitmq-hub/A Websub Hub Based on RabbitMQ.md @@ -9,7 +9,7 @@ _Updated_: 2023/04/25 # Overview -The purpose of this example is to demonstrate the usage of ballerina RabbbitMQ package in a production ready application. +The purpose of this example is to demonstrate the usage of ballerina RabbitMQ package in a production ready application. This is a websub hub implementation based on message brokers. In this case hub is backed by RabbitMQ message broker. Message brokers are a natural fit for the implementation of websub hubs as they serve a similar purpose. diff --git a/examples/rabbitmq-hub/hub/start_hub.bal b/examples/rabbitmq-hub/hub/start_hub.bal index 0488feb2..bde68743 100644 --- a/examples/rabbitmq-hub/hub/start_hub.bal +++ b/examples/rabbitmq-hub/hub/start_hub.bal @@ -108,8 +108,8 @@ isolated function pollForNewUpdates(websubhub:HubClient clientEp, rabbitmq:Clien do { while true { // Set autoAck mode to false. - rabbitmq:Message|error records = consumerEp->consumeMessage(topicName, false); - if (records is rabbitmq:Message) { + rabbitmq:BytesMessage|error records = consumerEp->consumeMessage(topicName, false); + if (records is rabbitmq:BytesMessage) { if !isValidConsumer(topicName, groupName) { fail error(string `Consumer with group name ${groupName} or topic ${topicName} is invalid`); } @@ -139,7 +139,7 @@ isolated function isValidConsumer(string topicName, string groupName) returns bo return topicAvailable && subscriberAvailable; } -isolated function notifySubscribers(rabbitmq:Message records, websubhub:HubClient clientEp, rabbitmq:Client consumerEp) returns error? { +isolated function notifySubscribers(rabbitmq:BytesMessage records, websubhub:HubClient clientEp, rabbitmq:Client consumerEp) returns error? { var message = deSerializeRecord(records); if message is websubhub:ContentDistributionMessage { var response = clientEp->notifyContentDistribution(message); @@ -154,7 +154,7 @@ isolated function notifySubscribers(rabbitmq:Message records, websubhub:HubClien } } -isolated function deSerializeRecord(rabbitmq:Message records) returns websubhub:ContentDistributionMessage|error { +isolated function deSerializeRecord(rabbitmq:BytesMessage records) returns websubhub:ContentDistributionMessage|error { byte[] content = records.content; string message = check string:fromBytes(content); json payload = check value:fromJsonString(message); @@ -170,7 +170,7 @@ rabbitmq:Service topicService = queueName: config:REGISTERED_WEBSUB_TOPICS_QUEUE } service object { - remote function onMessage(rabbitmq:Message message) { + remote function onMessage(rabbitmq:BytesMessage message) { string|error messageContent = string:fromBytes(message.content); if messageContent is string { websubhub:TopicRegistration[]|error persistedTopics = deSerializeTopicsMessage(messageContent); @@ -188,7 +188,7 @@ rabbitmq:Service subscribersService = queueName: config:WEBSUB_SUBSCRIBERS_QUEUE } service object { - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:BytesMessage message) returns error? { string|error messageContent = string:fromBytes(message.content); if messageContent is string { websubhub:VerifiedSubscription[]|error persistedSubscribers = deSerializeSubscribersMessage(messageContent); diff --git a/load-tests/simple_producer_consumer/src/main.bal b/load-tests/simple_producer_consumer/src/main.bal index 00b21765..8784fac9 100644 --- a/load-tests/simple_producer_consumer/src/main.bal +++ b/load-tests/simple_producer_consumer/src/main.bal @@ -124,7 +124,7 @@ rabbitmq:Service rabbitmqService = queueName: QUEUE_NAME } service object { - remote function onMessage(rabbitmq:Message message) returns error? { + remote function onMessage(rabbitmq:BytesMessage message) returns error? { string|error messageContent = 'string:fromBytes(message.content); if messageContent is error { lock { diff --git a/native/src/main/java/io/ballerina/stdlib/rabbitmq/RabbitMQConstants.java b/native/src/main/java/io/ballerina/stdlib/rabbitmq/RabbitMQConstants.java index 64c2f539..91be9c8f 100644 --- a/native/src/main/java/io/ballerina/stdlib/rabbitmq/RabbitMQConstants.java +++ b/native/src/main/java/io/ballerina/stdlib/rabbitmq/RabbitMQConstants.java @@ -110,7 +110,6 @@ public class RabbitMQConstants { public static final String CHANNEL_NATIVE_OBJECT = "rabbitmq_channel_object"; // Message constant fields - public static final String MESSAGE_RECORD = "Message"; public static final String MESSAGE_CONTENT_FIELD = "content"; public static final String MESSAGE_ROUTINE_KEY_FIELD = "routingKey"; public static final String MESSAGE_EXCHANGE_FIELD = "exchange"; From 85f53d710bbd2359b64871121f989ee7ae6f7e78 Mon Sep 17 00:00:00 2001 From: aashikam Date: Mon, 1 Apr 2024 22:29:47 +0530 Subject: [PATCH 6/7] Add changes from code review --- ballerina/Module.md | 4 ++-- docs/proposals/data-binding.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ballerina/Module.md b/ballerina/Module.md index 63ce2d1d..554235d4 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -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:BytesMessage message) returns string { + remote function onRequest(rabbitmq:AnydataMessage message) returns string { return "Hello Back!"; } } ``` -The `rabbitmq:BytesMessage` record received can be used to retrieve its contents. +The `rabbitmq:AnydataMessage` record received can be used to retrieve its contents. ### Advanced usage diff --git a/docs/proposals/data-binding.md b/docs/proposals/data-binding.md index 5ec42684..faabb20c 100644 --- a/docs/proposals/data-binding.md +++ b/docs/proposals/data-binding.md @@ -15,7 +15,7 @@ Data binding helps to access the incoming and outgoing message data in the user' ## Motivation -As of now, the Ballerina `rabbitmq` package does not provide direct data binding for sending and receiving messages. Only `rabbitmq:Message` is the supported data type to send and receive messages which only support `byte[]` as the message content type. Therefore, users have to do data manipulations by themselves. With this new feature, the user experience can be improved by introducing data binding to reduce the burden of developers converting byte data to the desired format as discussed in the next section. +As of now, the Ballerina `rabbitmq` package does not provide direct data binding for sending and receiving messages. Only `rabbitmq:AnydataMessage` is the supported data type to send and receive messages which only support `byte[]` as the message content type. Therefore, users have to do data manipulations by themselves. With this new feature, the user experience can be improved by introducing data binding to reduce the burden of developers converting byte data to the desired format as discussed in the next section. ## Description From 52f1e157dd1b2998ad500998cec37e6b560db47e Mon Sep 17 00:00:00 2001 From: aashikam Date: Tue, 2 Apr 2024 10:27:43 +0530 Subject: [PATCH 7/7] Add changes from code review --- docs/proposals/data-binding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/proposals/data-binding.md b/docs/proposals/data-binding.md index faabb20c..5ec42684 100644 --- a/docs/proposals/data-binding.md +++ b/docs/proposals/data-binding.md @@ -15,7 +15,7 @@ Data binding helps to access the incoming and outgoing message data in the user' ## Motivation -As of now, the Ballerina `rabbitmq` package does not provide direct data binding for sending and receiving messages. Only `rabbitmq:AnydataMessage` is the supported data type to send and receive messages which only support `byte[]` as the message content type. Therefore, users have to do data manipulations by themselves. With this new feature, the user experience can be improved by introducing data binding to reduce the burden of developers converting byte data to the desired format as discussed in the next section. +As of now, the Ballerina `rabbitmq` package does not provide direct data binding for sending and receiving messages. Only `rabbitmq:Message` is the supported data type to send and receive messages which only support `byte[]` as the message content type. Therefore, users have to do data manipulations by themselves. With this new feature, the user experience can be improved by introducing data binding to reduce the burden of developers converting byte data to the desired format as discussed in the next section. ## Description