diff --git a/ballerina/admin.bal b/ballerina/admin.bal index 5dff76e2..a5aec0ba 100644 --- a/ballerina/admin.bal +++ b/ballerina/admin.bal @@ -38,7 +38,7 @@ public isolated client class Administrator { # + return - Topic properties(Type of asb:TopicProperies) or error @display {label: "Create Topic"} isolated remote function createTopic(@display {label: "Topic"} string topicName, @display {label: "Topic Options"} *CreateTopicOptions topicOptions) returns TopicProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Get the topic with the given name. @@ -47,7 +47,7 @@ public isolated client class Administrator { # + return - Topic properties(Type of asb:TopicProperies) or error @display {label: "Get Topic"} isolated remote function getTopic(@display {label: "Topic"} string topicName) returns TopicProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Update the topic with the given options. @@ -57,7 +57,7 @@ public isolated client class Administrator { # + return - Topic properties(Type of asb:TopicProperies) or error @display {label: "Update Topics"} isolated remote function updateTopic(@display {label: "Topic"} string topicName, @display {label: "Update Topic Options"} *UpdateTopicOptions topicOptions) returns TopicProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # List the topics. @@ -65,7 +65,7 @@ public isolated client class Administrator { # + return - Topic list(Type of asb:TopicList) or error @display {label: "List Topics"} isolated remote function listTopics() returns TopicList|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Delete the topic with the given name. @@ -74,7 +74,7 @@ public isolated client class Administrator { # + return - Error or nil @display {label: "Delete Topic"} isolated remote function deleteTopic(@display {label: "Topic"} string topicName) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Create a subscription with the given name or name and options. @@ -85,7 +85,7 @@ public isolated client class Administrator { # + return - Subscription properties(Type of asb:SubscriptionProperies) or error @display {label: "Create Subscription"} isolated remote function createSubscription(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Subscription Options"} *CreateSubscriptionOptions subscriptionOptions) returns SubscriptionProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Get the subscription with the given name. @@ -95,7 +95,7 @@ public isolated client class Administrator { # + return - Subscription properties(Type of asb:SubscriptionProperies) or error @display {label: "Get Subscription"} isolated remote function getSubscription(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName) returns SubscriptionProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Update the subscription with the given options. @@ -106,7 +106,7 @@ public isolated client class Administrator { # + return - Subscription properties(Type of asb:SubscriptionProperies) or error @display {label: "Update Subscription"} isolated remote function updateSubscription(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Update Subscription Options"} *UpdateSubscriptionOptions subscriptionOptions) returns SubscriptionProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # List the subscriptions. @@ -115,7 +115,7 @@ public isolated client class Administrator { # + return - Subscription list(Type of asb:SubscriptionList) or error @display {label: "List Subscriptions"} isolated remote function listSubscriptions(@display {label: "Topic"} string topicName) returns SubscriptionList|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Delete the subscription with the given name. @@ -125,7 +125,7 @@ public isolated client class Administrator { # + return - Error or nil @display {label: "Delete Subscription"} isolated remote function deleteSubscription(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Get the status of existance of a topic with the given name. @@ -134,7 +134,7 @@ public isolated client class Administrator { # + return - Boolean or error @display {label: "is Topic Exists"} isolated remote function topicExists(@display {label: "Exists"} string topicName) returns boolean|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Get the status of existance of a subscription with the given name. @@ -144,7 +144,7 @@ public isolated client class Administrator { # + return - Boolean or error @display {label: "is Subscription Exists"} isolated remote function subscriptionExists(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName) returns boolean|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Create a rule with the given name or name and options. @@ -156,7 +156,7 @@ public isolated client class Administrator { # + return - Rule properties(Type of asb:RuleProperies) or error @display {label: "Create Rule"} isolated remote function createRule(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Rule"} string ruleName, @display {label: "Rule Options"} *CreateRuleOptions ruleOptions) returns RuleProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Delete the rule with the given name. @@ -167,7 +167,7 @@ public isolated client class Administrator { # + return - Error or nil @display {label: "Get Rule"} isolated remote function getRule(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Rule"} string ruleName) returns RuleProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Update the rule with the options. @@ -179,7 +179,7 @@ public isolated client class Administrator { # + return - Rule properties(Type of asb:RuleProperies) or error @display {label: "Update Rule"} isolated remote function updateRule(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Rule"} string ruleName, @display {label: "Update Rule Options"} *UpdateRuleOptions ruleOptions) returns RuleProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # List the rules. @@ -189,7 +189,7 @@ public isolated client class Administrator { # + return - Rule list(Type of asb:RuleList) or error @display {label: "List Rules"} isolated remote function listRules(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName) returns RuleList|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Delete the rule with the given name. @@ -200,7 +200,7 @@ public isolated client class Administrator { # + return - Error or nil @display {label: "Delete Rule"} isolated remote function deleteRule(@display {label: "Topic"} string topicName, @display {label: "Subscription"} string subscriptionName, @display {label: "Rule"} string ruleName) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Create a queue with the given name or name and options. @@ -210,7 +210,7 @@ public isolated client class Administrator { # + return - Queue properties(Type of asb:QueueProperties) or error @display {label: "Create Queue"} isolated remote function createQueue(@display {label: "Queue"} string queueName, @display {label: "Queue Options"} *CreateQueueOptions queueOptions) returns QueueProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Get the queue with the given name. @@ -219,7 +219,7 @@ public isolated client class Administrator { # + return - Queue properties(Type of asb:QueueProperties) or error @display {label: "Get Queue"} isolated remote function getQueue(@display {label: "Queue"} string queueName) returns QueueProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Update the queue with the options.Q @@ -229,14 +229,14 @@ public isolated client class Administrator { # + return - Queue properties(Type of asb:QueueProperties) or error @display {label: "Update Queue"} isolated remote function updateQueue(@display {label: "Queue"} string queueName, @display {label: "Update Queue Options"} *UpdateQueueOptions queueOptions) returns QueueProperties|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # List the queues. # # + return - Queue list(Type of asb:QueueList) or error isolated remote function listQueues() returns QueueList|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Delete the queue with the given name. @@ -245,7 +245,7 @@ public isolated client class Administrator { # + return - Error or nil @display {label: "Delete Queue"} isolated remote function deleteQueue(@display {label: "Queue"} string queueName) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; # Check whether the queue exists. @@ -254,10 +254,10 @@ public isolated client class Administrator { # + return - Boolean or error @display {label: "is Queue Exists"} isolated remote function queueExists(@display {label: "Exists"} string queueName) returns boolean|Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; } isolated function initializeAdministrator(Administrator adminClient, handle connectionString) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.admin.Administrator" + 'class: "io.ballerina.lib.asb.admin.Administrator" } external; diff --git a/ballerina/caller.bal b/ballerina/caller.bal index bdfeafb9..01edfe21 100644 --- a/ballerina/caller.bal +++ b/ballerina/caller.bal @@ -24,7 +24,7 @@ public isolated client class Caller { # # + return - An `asb:Error` if failed to complete message or else `()` isolated remote function complete() returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeCaller" + 'class: "io.ballerina.lib.asb.listener.NativeCaller" } external; # Abandon message from queue or subscription based on messageLockToken. Abandon processing of the message for @@ -34,7 +34,7 @@ public isolated client class Caller { # + propertiesToModify - Message properties to modify # + return - An `asb:Error` if failed to abandon message or else `()` isolated remote function abandon(*record {|anydata...;|} propertiesToModify) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeCaller" + 'class: "io.ballerina.lib.asb.listener.NativeCaller" } external; # Dead-Letter the message & moves the message to the Dead-Letter Queue based on messageLockToken. Transfer @@ -43,7 +43,7 @@ public isolated client class Caller { # + options - Options to specify while putting message in dead-letter queue # + return - An `asb:Error` if failed to deadletter message or else `()` isolated remote function deadLetter(*DeadLetterOptions options) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeCaller" + 'class: "io.ballerina.lib.asb.listener.NativeCaller" } external; # Defer the message in a Queue or Subscription based on messageLockToken. It prevents the message from being @@ -52,6 +52,6 @@ public isolated client class Caller { # + propertiesToModify - Message properties to modify # + return - An `asb:Error` if failed to defer message or else sequence number isolated remote function defer(*record {|anydata...;|} propertiesToModify) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeCaller" + 'class: "io.ballerina.lib.asb.listener.NativeCaller" } external; } diff --git a/ballerina/init.bal b/ballerina/init.bal index 2ac2479c..4adf5edc 100644 --- a/ballerina/init.bal +++ b/ballerina/init.bal @@ -27,5 +27,5 @@ function init() { } function setModule() returns error? = @java:Method { - 'class: "org.ballerinax.asb.util.ModuleUtils" + 'class: "io.ballerina.lib.asb.util.ModuleUtils" } external; diff --git a/ballerina/listener.bal b/ballerina/listener.bal index 18294513..9f33c467 100644 --- a/ballerina/listener.bal +++ b/ballerina/listener.bal @@ -38,7 +38,7 @@ public isolated class Listener { private isolated function externInit(ListenerConfiguration config) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; # Attaches an `asb:Service` to a listener. @@ -50,7 +50,7 @@ public isolated class Listener { # + name - Name of the service # + return - An `asb:Error` if there is an error or else `()` public isolated function attach(Service 'service, string[]|string? name = ()) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; # Detaches an `asb:Service` from the the listener. @@ -61,7 +61,7 @@ public isolated class Listener { # + 'service - The service to be detached # + return - An `asb:Error` if there is an error or else `()` public isolated function detach(Service 'service) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; # Starts the `asb:Listener`. @@ -71,7 +71,7 @@ public isolated class Listener { # # + return - An `asb:Error` if there is an error or else `()` public isolated function 'start() returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; # Stops the `asb:Listener` gracefully. @@ -81,7 +81,7 @@ public isolated class Listener { # # + return - An `asb:Error` if there is an error or else `()` public isolated function gracefulStop() returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; # Stops the `asb:Listener` immediately. @@ -91,6 +91,6 @@ public isolated class Listener { # # + return - An `asb:Error` if there is an error or else `()` public isolated function immediateStop() returns Error? = @java:Method { - 'class: "org.ballerinax.asb.listener.NativeListener" + 'class: "io.ballerina.lib.asb.listener.NativeListener" } external; } diff --git a/ballerina/receiver.bal b/ballerina/receiver.bal index ab748ac2..a04bef05 100644 --- a/ballerina/receiver.bal +++ b/ballerina/receiver.bal @@ -74,7 +74,7 @@ public isolated client class MessageReceiver { @display {label: "Expected Type"} typedesc T = <>, @display {label: "Dead-Lettered Messages"} boolean deadLettered = false) returns @display {label: "Message"} T|Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; # Receive message payload from queue or subscription. @@ -89,7 +89,7 @@ public isolated client class MessageReceiver { @display {label: "Expected Type"} typedesc T = <>, @display {label: "Dead-Lettered Messages"} boolean deadLettered = false) returns @display {label: "Message Payload"} T|Error = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; # Receive batch of messages from queue or subscription. @@ -177,7 +177,7 @@ public isolated client class MessageReceiver { isolated remote function receiveDeferred(@display {label: "Deferred Msg Seq Num"} int sequenceNumber) returns @display {label: "Deferred Message"} Message|Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; # The operation renews lock on a message in a queue or subscription based on messageLockToken. @@ -198,41 +198,41 @@ public isolated client class MessageReceiver { @display {label: "Close Receiver Connection"} isolated remote function close() returns Error? = @java:Method { name: "closeReceiver", - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; } isolated function initializeReceiver(MessageReceiver receiverClient, handle connectionString, handle queueName, handle topicName, handle subscriptionName, handle receiveMode, int maxAutoLockRenewDuration, handle isLogActive, AmqpRetryOptions retryOptions) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function receiveBatch(MessageReceiver endpointClient, int maxMessageCount, int? serverWaitTime, boolean deadLettered) returns MessageBatch|Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function complete(MessageReceiver endpointClient, Message message) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function abandon(MessageReceiver endpointClient, Message message) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function deadLetter(MessageReceiver endpointClient, Message message, string? deadLetterReason, string? deadLetterErrorDescription) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function defer(MessageReceiver endpointClient, Message message) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function receiveDeferred(MessageReceiver endpointClient, int sequenceNumber) returns Message|Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; isolated function renewLock(MessageReceiver endpointClient, Message message) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.receiver.MessageReceiver" + 'class: "io.ballerina.lib.asb.receiver.MessageReceiver" } external; diff --git a/ballerina/sender.bal b/ballerina/sender.bal index 4c97eb71..8e4fbdee 100644 --- a/ballerina/sender.bal +++ b/ballerina/sender.bal @@ -82,7 +82,7 @@ public isolated client class MessageSender { # + sequenceNumber - The sequence number of the message to cancel # + return - If the message could not be cancelled isolated remote function cancel(@display {label: "Sequence Number"} int sequenceNumber) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; # Send batch of messages to queue or topic. @@ -102,23 +102,23 @@ public isolated client class MessageSender { # + return - An `asb:Error` if failed to close connection or else `()` @display {label: "Close Sender Connection"} isolated remote function close() returns Error? = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; } isolated function initializeSender(MessageSender senderClient, handle connectionString, handle entityType, handle topicOrQueueName, handle isLogEnabled, AmqpRetryOptions retryOptions) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; isolated function send(MessageSender senderClient, Message message) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; isolated function sendBatch(MessageSender senderClient, MessageBatch messages) returns Error? = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; isolated function schedule(MessageSender senderClient, Message message, time:Civil scheduleTime) returns int|Error = @java:Method { - 'class: "org.ballerinax.asb.sender.MessageSender" + 'class: "io.ballerina.lib.asb.sender.MessageSender" } external; diff --git a/gradle.properties b/gradle.properties index 6fc7f4be..3e5492cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.caching=true -group=org.ballerinax.azure.servicebus +group=io.ballerina.lib version=3.8.1-SNAPSHOT checkstylePluginVersion=10.12.0 diff --git a/native/src/main/java/org/ballerinax/asb/admin/AdminNetworkThreadFactory.java b/native/src/main/java/io/ballerina/lib/asb/admin/AdminNetworkThreadFactory.java similarity index 96% rename from native/src/main/java/org/ballerinax/asb/admin/AdminNetworkThreadFactory.java rename to native/src/main/java/io/ballerina/lib/asb/admin/AdminNetworkThreadFactory.java index 6f8b4de9..6ca62839 100644 --- a/native/src/main/java/org/ballerinax/asb/admin/AdminNetworkThreadFactory.java +++ b/native/src/main/java/io/ballerina/lib/asb/admin/AdminNetworkThreadFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.admin; +package io.ballerina.lib.asb.admin; import java.util.concurrent.ThreadFactory; diff --git a/native/src/main/java/org/ballerinax/asb/admin/Administrator.java b/native/src/main/java/io/ballerina/lib/asb/admin/Administrator.java similarity index 99% rename from native/src/main/java/org/ballerinax/asb/admin/Administrator.java rename to native/src/main/java/io/ballerina/lib/asb/admin/Administrator.java index c1d1b5ec..5f0647ce 100644 --- a/native/src/main/java/org/ballerinax/asb/admin/Administrator.java +++ b/native/src/main/java/io/ballerina/lib/asb/admin/Administrator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.admin; +package io.ballerina.lib.asb.admin; import com.azure.core.exception.HttpResponseException; import com.azure.core.http.rest.PagedIterable; @@ -34,6 +34,10 @@ import com.azure.messaging.servicebus.administration.models.SqlRuleFilter; import com.azure.messaging.servicebus.administration.models.SubscriptionProperties; import com.azure.messaging.servicebus.administration.models.TopicProperties; +import io.ballerina.lib.asb.util.ASBConstants; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ASBUtils; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.PredefinedTypes; @@ -47,10 +51,6 @@ import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ASBConstants; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ASBUtils; -import org.ballerinax.asb.util.ModuleUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/native/src/main/java/org/ballerinax/asb/listener/EntityConfig.java b/native/src/main/java/io/ballerina/lib/asb/listener/EntityConfig.java similarity index 95% rename from native/src/main/java/org/ballerinax/asb/listener/EntityConfig.java rename to native/src/main/java/io/ballerina/lib/asb/listener/EntityConfig.java index f95f829b..8d572879 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/EntityConfig.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/EntityConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; /** * {@code EntityConfig} represents an ASB entity configurations. diff --git a/native/src/main/java/org/ballerinax/asb/listener/ErrorConsumer.java b/native/src/main/java/io/ballerina/lib/asb/listener/ErrorConsumer.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/listener/ErrorConsumer.java rename to native/src/main/java/io/ballerina/lib/asb/listener/ErrorConsumer.java index 5562515a..6bfc2a9d 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/ErrorConsumer.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/ErrorConsumer.java @@ -16,11 +16,12 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.messaging.servicebus.ServiceBusErrorContext; import com.azure.messaging.servicebus.ServiceBusException; import com.azure.messaging.servicebus.ServiceBusFailureReason; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.async.Callback; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.ValueCreator; @@ -30,7 +31,6 @@ import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ModuleUtils; import java.util.function.Consumer; diff --git a/native/src/main/java/org/ballerinax/asb/listener/ListenerConfiguration.java b/native/src/main/java/io/ballerina/lib/asb/listener/ListenerConfiguration.java similarity index 95% rename from native/src/main/java/org/ballerinax/asb/listener/ListenerConfiguration.java rename to native/src/main/java/io/ballerina/lib/asb/listener/ListenerConfiguration.java index f0d36175..b02c843e 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/ListenerConfiguration.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/ListenerConfiguration.java @@ -16,16 +16,15 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.core.amqp.AmqpRetryOptions; import com.azure.messaging.servicebus.models.ServiceBusReceiveMode; +import io.ballerina.lib.asb.util.ASBUtils; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; -import static org.ballerinax.asb.util.ASBUtils.getRetryOptions; - /** * {@code ListenerConfiguration} contains the java representation of the Ballerina ASB listener configurations. * @@ -65,7 +64,7 @@ public ListenerConfiguration(BMap configurations) { configurations.getIntValue(MAX_CONCURRENCY).intValue(), configurations.getIntValue(PREFETCH_COUNT).intValue(), configurations.getBooleanValue(AUTO_COMPLETE), - getRetryOptions((BMap) configurations.getMapValue(AMQP_RETRY_OPTIONS)) + ASBUtils.getRetryOptions((BMap) configurations.getMapValue(AMQP_RETRY_OPTIONS)) ); } diff --git a/native/src/main/java/org/ballerinax/asb/listener/MessageConsumer.java b/native/src/main/java/io/ballerina/lib/asb/listener/MessageConsumer.java similarity index 82% rename from native/src/main/java/org/ballerinax/asb/listener/MessageConsumer.java rename to native/src/main/java/io/ballerina/lib/asb/listener/MessageConsumer.java index 64b5b4fc..427e36eb 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/MessageConsumer.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/MessageConsumer.java @@ -16,20 +16,24 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.messaging.servicebus.ServiceBusReceivedMessage; import com.azure.messaging.servicebus.ServiceBusReceivedMessageContext; +import io.ballerina.lib.asb.receiver.MessageReceiver; +import io.ballerina.lib.asb.util.ASBConstants; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ASBUtils; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.async.Callback; +import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.Parameter; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ModuleUtils; import java.util.Map; import java.util.concurrent.Semaphore; @@ -37,11 +41,6 @@ import static io.ballerina.runtime.api.TypeTags.OBJECT_TYPE_TAG; import static io.ballerina.runtime.api.TypeTags.RECORD_TYPE_TAG; -import static io.ballerina.runtime.api.creators.ValueCreator.createRecordValue; -import static org.ballerinax.asb.receiver.MessageReceiver.getMessagePayload; -import static org.ballerinax.asb.receiver.MessageReceiver.populateOptionalFieldsMap; -import static org.ballerinax.asb.util.ASBConstants.BODY; -import static org.ballerinax.asb.util.ASBUtils.getValueWithIntendedType; /** * {@code MessageConsumer} provides the capability to invoke `onMessage` function of the ASB service. @@ -102,13 +101,14 @@ private Object[] getMethodParams(Parameter[] parameters, ServiceBusReceivedMessa } private BMap constructBMessage(ServiceBusReceivedMessage message) { - Map map = populateOptionalFieldsMap(message); - Object messageBody = getMessagePayload(message); + Map map = MessageReceiver.populateOptionalFieldsMap(message); + Object messageBody = MessageReceiver.getMessagePayload(message); if (messageBody instanceof byte[]) { - map.put(BODY, getValueWithIntendedType((byte[]) messageBody, PredefinedTypes.TYPE_ANYDATA)); + map.put(ASBConstants.BODY, ASBUtils.getValueWithIntendedType( + (byte[]) messageBody, PredefinedTypes.TYPE_ANYDATA)); } else { - map.put(BODY, messageBody); + map.put(ASBConstants.BODY, messageBody); } - return createRecordValue(ModuleUtils.getModule(), MESSAGE_RECORD, map); + return ValueCreator.createRecordValue(ModuleUtils.getModule(), MESSAGE_RECORD, map); } } diff --git a/native/src/main/java/org/ballerinax/asb/listener/NativeBServiceAdaptor.java b/native/src/main/java/io/ballerina/lib/asb/listener/NativeBServiceAdaptor.java similarity index 97% rename from native/src/main/java/org/ballerinax/asb/listener/NativeBServiceAdaptor.java rename to native/src/main/java/io/ballerina/lib/asb/listener/NativeBServiceAdaptor.java index af8535f4..963ead19 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/NativeBServiceAdaptor.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/NativeBServiceAdaptor.java @@ -16,8 +16,10 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.Module; import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.Runtime; @@ -30,8 +32,6 @@ import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BObject; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ModuleUtils; import java.util.Optional; import java.util.stream.Stream; diff --git a/native/src/main/java/org/ballerinax/asb/listener/NativeCaller.java b/native/src/main/java/io/ballerina/lib/asb/listener/NativeCaller.java similarity index 97% rename from native/src/main/java/org/ballerinax/asb/listener/NativeCaller.java rename to native/src/main/java/io/ballerina/lib/asb/listener/NativeCaller.java index 9eaee572..8fc7ac36 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/NativeCaller.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/NativeCaller.java @@ -16,20 +16,20 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.messaging.servicebus.ServiceBusReceivedMessageContext; import com.azure.messaging.servicebus.models.AbandonOptions; import com.azure.messaging.servicebus.models.DeadLetterOptions; import com.azure.messaging.servicebus.models.DeferOptions; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ASBUtils; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ASBUtils; -import org.ballerinax.asb.util.ModuleUtils; import java.util.Map; import java.util.Objects; diff --git a/native/src/main/java/org/ballerinax/asb/listener/NativeListener.java b/native/src/main/java/io/ballerina/lib/asb/listener/NativeListener.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/listener/NativeListener.java rename to native/src/main/java/io/ballerina/lib/asb/listener/NativeListener.java index b1875a6d..15afdb86 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/NativeListener.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/NativeListener.java @@ -16,16 +16,16 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.messaging.servicebus.ServiceBusProcessorClient; import com.azure.messaging.servicebus.models.ServiceBusReceiveMode; +import io.ballerina.lib.asb.util.ASBErrorCreator; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ASBErrorCreator; import java.time.Duration; import java.util.Objects; diff --git a/native/src/main/java/org/ballerinax/asb/listener/OnErrorCallback.java b/native/src/main/java/io/ballerina/lib/asb/listener/OnErrorCallback.java similarity index 97% rename from native/src/main/java/org/ballerinax/asb/listener/OnErrorCallback.java rename to native/src/main/java/io/ballerina/lib/asb/listener/OnErrorCallback.java index 24de711f..2648cecd 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/OnErrorCallback.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/OnErrorCallback.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import io.ballerina.runtime.api.async.Callback; import io.ballerina.runtime.api.values.BError; diff --git a/native/src/main/java/org/ballerinax/asb/listener/OnMessageAutoCompletableCallback.java b/native/src/main/java/io/ballerina/lib/asb/listener/OnMessageAutoCompletableCallback.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/listener/OnMessageAutoCompletableCallback.java rename to native/src/main/java/io/ballerina/lib/asb/listener/OnMessageAutoCompletableCallback.java index 52fea98a..c669087a 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/OnMessageAutoCompletableCallback.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/OnMessageAutoCompletableCallback.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import com.azure.messaging.servicebus.ServiceBusReceivedMessageContext; import io.ballerina.runtime.api.async.Callback; diff --git a/native/src/main/java/org/ballerinax/asb/listener/OnMessageCallback.java b/native/src/main/java/io/ballerina/lib/asb/listener/OnMessageCallback.java similarity index 97% rename from native/src/main/java/org/ballerinax/asb/listener/OnMessageCallback.java rename to native/src/main/java/io/ballerina/lib/asb/listener/OnMessageCallback.java index 350ce981..f2ca02b8 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/OnMessageCallback.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/OnMessageCallback.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; import io.ballerina.runtime.api.async.Callback; import io.ballerina.runtime.api.values.BError; diff --git a/native/src/main/java/org/ballerinax/asb/listener/QueueConfig.java b/native/src/main/java/io/ballerina/lib/asb/listener/QueueConfig.java similarity index 95% rename from native/src/main/java/org/ballerinax/asb/listener/QueueConfig.java rename to native/src/main/java/io/ballerina/lib/asb/listener/QueueConfig.java index de72a8a3..3bb3291d 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/QueueConfig.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/QueueConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; /** * {@code QueueConfig} represents an ASB queue configurations. diff --git a/native/src/main/java/org/ballerinax/asb/listener/TopicConfig.java b/native/src/main/java/io/ballerina/lib/asb/listener/TopicConfig.java similarity index 95% rename from native/src/main/java/org/ballerinax/asb/listener/TopicConfig.java rename to native/src/main/java/io/ballerina/lib/asb/listener/TopicConfig.java index 9ba62eb4..1ab0dbb6 100644 --- a/native/src/main/java/org/ballerinax/asb/listener/TopicConfig.java +++ b/native/src/main/java/io/ballerina/lib/asb/listener/TopicConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.listener; +package io.ballerina.lib.asb.listener; /** * {@code TopicConfig} represents an ASB topic configurations. diff --git a/native/src/main/java/org/ballerinax/asb/receiver/MessageReceiver.java b/native/src/main/java/io/ballerina/lib/asb/receiver/MessageReceiver.java similarity index 85% rename from native/src/main/java/org/ballerinax/asb/receiver/MessageReceiver.java rename to native/src/main/java/io/ballerina/lib/asb/receiver/MessageReceiver.java index d707fa92..a89a9438 100644 --- a/native/src/main/java/org/ballerinax/asb/receiver/MessageReceiver.java +++ b/native/src/main/java/io/ballerina/lib/asb/receiver/MessageReceiver.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.receiver; +package io.ballerina.lib.asb.receiver; import com.azure.core.amqp.AmqpRetryOptions; import com.azure.core.amqp.models.AmqpAnnotatedMessage; @@ -26,6 +26,10 @@ import com.azure.messaging.servicebus.ServiceBusReceivedMessage; import com.azure.messaging.servicebus.ServiceBusReceiverClient; import com.azure.messaging.servicebus.models.DeadLetterOptions; +import io.ballerina.lib.asb.util.ASBConstants; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ASBUtils; +import io.ballerina.lib.asb.util.ModuleUtils; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.PredefinedTypes; @@ -42,10 +46,6 @@ import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BTypedesc; -import org.ballerinax.asb.util.ASBConstants; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ASBUtils; -import org.ballerinax.asb.util.ModuleUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,36 +59,6 @@ import java.util.concurrent.Executors; import static io.ballerina.runtime.api.creators.ValueCreator.createRecordValue; -import static org.ballerinax.asb.util.ASBConstants.APPLICATION_PROPERTY_KEY; -import static org.ballerinax.asb.util.ASBConstants.BODY; -import static org.ballerinax.asb.util.ASBConstants.CONTENT_TYPE; -import static org.ballerinax.asb.util.ASBConstants.CORRELATION_ID; -import static org.ballerinax.asb.util.ASBConstants.DEAD_LETTER_ERROR_DESCRIPTION; -import static org.ballerinax.asb.util.ASBConstants.DEAD_LETTER_REASON; -import static org.ballerinax.asb.util.ASBConstants.DEAD_LETTER_SOURCE; -import static org.ballerinax.asb.util.ASBConstants.DEFAULT_MESSAGE_LOCK_TOKEN; -import static org.ballerinax.asb.util.ASBConstants.DELIVERY_COUNT; -import static org.ballerinax.asb.util.ASBConstants.ENQUEUED_SEQUENCE_NUMBER; -import static org.ballerinax.asb.util.ASBConstants.ENQUEUED_TIME; -import static org.ballerinax.asb.util.ASBConstants.LABEL; -import static org.ballerinax.asb.util.ASBConstants.LOCK_TOKEN; -import static org.ballerinax.asb.util.ASBConstants.MESSAGE_ID; -import static org.ballerinax.asb.util.ASBConstants.NATIVE_MESSAGE; -import static org.ballerinax.asb.util.ASBConstants.PARTITION_KEY; -import static org.ballerinax.asb.util.ASBConstants.RECEIVER_CLIENT; -import static org.ballerinax.asb.util.ASBConstants.REPLY_TO; -import static org.ballerinax.asb.util.ASBConstants.REPLY_TO_SESSION_ID; -import static org.ballerinax.asb.util.ASBConstants.SEQUENCE_NUMBER; -import static org.ballerinax.asb.util.ASBConstants.SESSION_ID; -import static org.ballerinax.asb.util.ASBConstants.STATE; -import static org.ballerinax.asb.util.ASBConstants.TIME_TO_LIVE; -import static org.ballerinax.asb.util.ASBConstants.TO; -import static org.ballerinax.asb.util.ASBUtils.addFieldIfPresent; -import static org.ballerinax.asb.util.ASBUtils.constructReceiverClient; -import static org.ballerinax.asb.util.ASBUtils.convertAMQPToJava; -import static org.ballerinax.asb.util.ASBUtils.convertJavaToBValue; -import static org.ballerinax.asb.util.ASBUtils.getRetryOptions; -import static org.ballerinax.asb.util.ASBUtils.getValueWithIntendedType; /** * This facilitates the client operations of MessageReceiver client in @@ -119,9 +89,10 @@ public static Object initializeReceiver(BObject receiverClient, String connectio String receiveMode, long maxAutoLockRenewDuration, String logLevel, BMap retryConfigs) { try { - AmqpRetryOptions retryOptions = getRetryOptions(retryConfigs); - ServiceBusReceiverClient nativeReceiverClient = constructReceiverClient(retryOptions, connectionString, - queueName, receiveMode, maxAutoLockRenewDuration, topicName, subscriptionName, false); + AmqpRetryOptions retryOptions = ASBUtils.getRetryOptions(retryConfigs); + ServiceBusReceiverClient nativeReceiverClient = ASBUtils.constructReceiverClient( + retryOptions, connectionString, queueName, receiveMode, maxAutoLockRenewDuration, topicName, + subscriptionName, false); setClientData(receiverClient, connectionString, queueName, topicName, subscriptionName, receiveMode, maxAutoLockRenewDuration, logLevel, retryConfigs); setClient(receiverClient, nativeReceiverClient, false); @@ -201,10 +172,11 @@ public static Object receivePayload(Environment env, BObject receiverClient, Obj Object messageBody = getMessagePayload(message); if (messageBody instanceof byte[] binaryPayload) { - Object messagePayload = getValueWithIntendedType(binaryPayload, expectedType.getDescribingType()); + Object messagePayload = ASBUtils.getValueWithIntendedType(binaryPayload, + expectedType.getDescribingType()); future.complete(messagePayload); } else { - Optional bValue = convertJavaToBValue(message.getMessageId(), messageBody); + Optional bValue = ASBUtils.convertJavaToBValue(message.getMessageId(), messageBody); String payloadBindingErr = String.format( "Failed to bind the received ASB message value to the expected Ballerina type: '%s'", expectedType.toString()); @@ -252,7 +224,7 @@ public static Object receiveBatch(Environment env, BObject receiverClient, long } List> bMessages = receivedMessageStream.stream().map(msg -> { BMap bMsg = constructExpectedMessageRecord(msg, null); - bMsg.addNativeData(NATIVE_MESSAGE, msg); + bMsg.addNativeData(ASBConstants.NATIVE_MESSAGE, msg); return bMsg; }).toList(); BMap messageRecord = ValueCreator.createRecordValue(ModuleUtils.getModule(), @@ -508,44 +480,47 @@ private static BMap constructExpectedMessageRecord(ServiceBusRe Object messageBody = getMessagePayload(message); if (messageBody instanceof byte[]) { if (expectedType != null) { - map.put(BODY, getValueWithIntendedType((byte[]) messageBody, expectedType.getFields().get(BODY) + map.put(ASBConstants.BODY, ASBUtils.getValueWithIntendedType((byte[]) messageBody, + expectedType.getFields().get(ASBConstants.BODY) .getFieldType())); } else { - map.put(BODY, getValueWithIntendedType((byte[]) messageBody, PredefinedTypes.TYPE_ANYDATA)); + map.put(ASBConstants.BODY, ASBUtils.getValueWithIntendedType((byte[]) messageBody, + PredefinedTypes.TYPE_ANYDATA)); } } else { - map.put(BODY, messageBody); + map.put(ASBConstants.BODY, messageBody); } BMap constructedMessage = createBRecordValue(map, expectedType); // Only add the native message if the message received in peek lock mode. - if (!message.getLockToken().equals(DEFAULT_MESSAGE_LOCK_TOKEN)) { - constructedMessage.addNativeData(NATIVE_MESSAGE, message); + if (!message.getLockToken().equals(ASBConstants.DEFAULT_MESSAGE_LOCK_TOKEN)) { + constructedMessage.addNativeData(ASBConstants.NATIVE_MESSAGE, message); } return constructedMessage; } public static Map populateOptionalFieldsMap(ServiceBusReceivedMessage message) { Map map = new HashMap<>(); - addFieldIfPresent(map, CONTENT_TYPE, message.getContentType()); - addFieldIfPresent(map, MESSAGE_ID, message.getMessageId()); - addFieldIfPresent(map, TO, message.getTo()); - addFieldIfPresent(map, REPLY_TO, message.getReplyTo()); - addFieldIfPresent(map, REPLY_TO_SESSION_ID, message.getReplyToSessionId()); - addFieldIfPresent(map, LABEL, message.getSubject()); - addFieldIfPresent(map, SESSION_ID, message.getSessionId()); - addFieldIfPresent(map, CORRELATION_ID, message.getCorrelationId()); - addFieldIfPresent(map, PARTITION_KEY, message.getPartitionKey()); - addFieldIfPresent(map, TIME_TO_LIVE, message.getTimeToLive().getSeconds()); - addFieldIfPresent(map, SEQUENCE_NUMBER, message.getSequenceNumber()); - addFieldIfPresent(map, LOCK_TOKEN, message.getLockToken()); - addFieldIfPresent(map, DELIVERY_COUNT, message.getDeliveryCount()); - addFieldIfPresent(map, ENQUEUED_TIME, message.getEnqueuedTime().toString()); - addFieldIfPresent(map, ENQUEUED_SEQUENCE_NUMBER, message.getEnqueuedSequenceNumber()); - addFieldIfPresent(map, DEAD_LETTER_ERROR_DESCRIPTION, message.getDeadLetterErrorDescription()); - addFieldIfPresent(map, DEAD_LETTER_REASON, message.getDeadLetterReason()); - addFieldIfPresent(map, DEAD_LETTER_SOURCE, message.getDeadLetterSource()); - addFieldIfPresent(map, STATE, message.getState().toString()); - addFieldIfPresent(map, APPLICATION_PROPERTY_KEY, getApplicationProperties(message)); + ASBUtils.addFieldIfPresent(map, ASBConstants.CONTENT_TYPE, message.getContentType()); + ASBUtils.addFieldIfPresent(map, ASBConstants.MESSAGE_ID, message.getMessageId()); + ASBUtils.addFieldIfPresent(map, ASBConstants.TO, message.getTo()); + ASBUtils.addFieldIfPresent(map, ASBConstants.REPLY_TO, message.getReplyTo()); + ASBUtils.addFieldIfPresent(map, ASBConstants.REPLY_TO_SESSION_ID, message.getReplyToSessionId()); + ASBUtils.addFieldIfPresent(map, ASBConstants.LABEL, message.getSubject()); + ASBUtils.addFieldIfPresent(map, ASBConstants.SESSION_ID, message.getSessionId()); + ASBUtils.addFieldIfPresent(map, ASBConstants.CORRELATION_ID, message.getCorrelationId()); + ASBUtils.addFieldIfPresent(map, ASBConstants.PARTITION_KEY, message.getPartitionKey()); + ASBUtils.addFieldIfPresent(map, ASBConstants.TIME_TO_LIVE, message.getTimeToLive().getSeconds()); + ASBUtils.addFieldIfPresent(map, ASBConstants.SEQUENCE_NUMBER, message.getSequenceNumber()); + ASBUtils.addFieldIfPresent(map, ASBConstants.LOCK_TOKEN, message.getLockToken()); + ASBUtils.addFieldIfPresent(map, ASBConstants.DELIVERY_COUNT, message.getDeliveryCount()); + ASBUtils.addFieldIfPresent(map, ASBConstants.ENQUEUED_TIME, message.getEnqueuedTime().toString()); + ASBUtils.addFieldIfPresent(map, ASBConstants.ENQUEUED_SEQUENCE_NUMBER, message.getEnqueuedSequenceNumber()); + ASBUtils.addFieldIfPresent(map, ASBConstants.DEAD_LETTER_ERROR_DESCRIPTION, + message.getDeadLetterErrorDescription()); + ASBUtils.addFieldIfPresent(map, ASBConstants.DEAD_LETTER_REASON, message.getDeadLetterReason()); + ASBUtils.addFieldIfPresent(map, ASBConstants.DEAD_LETTER_SOURCE, message.getDeadLetterSource()); + ASBUtils.addFieldIfPresent(map, ASBConstants.STATE, message.getState().toString()); + ASBUtils.addFieldIfPresent(map, ASBConstants.APPLICATION_PROPERTY_KEY, getApplicationProperties(message)); return map; } @@ -573,7 +548,7 @@ public static Object getMessagePayload(ServiceBusReceivedMessage receivedMessage LOGGER.debug(String.format("Received a message with messageId: %s and AMQPMessageBodyType: %s", receivedMessage.getMessageId(), bodyType)); Object amqpValue = rawAmqpMessage.getBody().getValue(); - amqpValue = convertAMQPToJava(receivedMessage.getMessageId(), amqpValue); + amqpValue = ASBUtils.convertAMQPToJava(receivedMessage.getMessageId(), amqpValue); return amqpValue; default: throw new RuntimeException("Unsupported message body type: " + receivedMessage.getMessageId()); @@ -621,7 +596,7 @@ private static ServiceBusReceiverClient getNativeReceiver(BObject bReceiver, boo if (isDeadLetter) { return (ServiceBusReceiverClient) getDeadLetterMessageReceiverFromBObject(bReceiver); } - return (ServiceBusReceiverClient) bReceiver.getNativeData(RECEIVER_CLIENT); + return (ServiceBusReceiverClient) bReceiver.getNativeData(ASBConstants.RECEIVER_CLIENT); } private static Object getDeadLetterMessageReceiverFromBObject(BObject receiverObject) { @@ -640,8 +615,8 @@ private static Object getDeadLetterMessageReceiverFromBObject(BObject receiverOb BMap retryConfigs = (BMap) receiverObject.getNativeData(ASBConstants.RECEIVER_CLIENT_RETRY_CONFIGS); try { - AmqpRetryOptions retryOptions = getRetryOptions(retryConfigs); - ServiceBusReceiverClient nativeReceiverClient = constructReceiverClient(retryOptions, + AmqpRetryOptions retryOptions = ASBUtils.getRetryOptions(retryConfigs); + ServiceBusReceiverClient nativeReceiverClient = ASBUtils.constructReceiverClient(retryOptions, connectionString, queueName, receiveMode, maxAutoLockRenewDuration, topicName, subscriptionName, true); LOGGER.debug("ServiceBusReceiverClient initialized"); @@ -681,6 +656,6 @@ private static void setClient(BObject receiverObject, ServiceBusReceiverClient c } private static ServiceBusReceivedMessage getNativeMessage(BMap message) { - return (ServiceBusReceivedMessage) message.getNativeData(NATIVE_MESSAGE); + return (ServiceBusReceivedMessage) message.getNativeData(ASBConstants.NATIVE_MESSAGE); } } diff --git a/native/src/main/java/org/ballerinax/asb/receiver/ReceiverNetworkThreadFactory.java b/native/src/main/java/io/ballerina/lib/asb/receiver/ReceiverNetworkThreadFactory.java similarity index 96% rename from native/src/main/java/org/ballerinax/asb/receiver/ReceiverNetworkThreadFactory.java rename to native/src/main/java/io/ballerina/lib/asb/receiver/ReceiverNetworkThreadFactory.java index e70e28e4..74f4f595 100644 --- a/native/src/main/java/org/ballerinax/asb/receiver/ReceiverNetworkThreadFactory.java +++ b/native/src/main/java/io/ballerina/lib/asb/receiver/ReceiverNetworkThreadFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.receiver; +package io.ballerina.lib.asb.receiver; import java.util.concurrent.ThreadFactory; diff --git a/native/src/main/java/org/ballerinax/asb/sender/MessageSender.java b/native/src/main/java/io/ballerina/lib/asb/sender/MessageSender.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/sender/MessageSender.java rename to native/src/main/java/io/ballerina/lib/asb/sender/MessageSender.java index 2dbe4163..9c9261c6 100644 --- a/native/src/main/java/org/ballerinax/asb/sender/MessageSender.java +++ b/native/src/main/java/io/ballerina/lib/asb/sender/MessageSender.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.sender; +package io.ballerina.lib.asb.sender; import com.azure.core.amqp.AmqpRetryOptions; import com.azure.messaging.servicebus.ServiceBusClientBuilder; @@ -26,6 +26,9 @@ import com.azure.messaging.servicebus.ServiceBusMessageBatch; import com.azure.messaging.servicebus.ServiceBusSenderClient; import com.azure.messaging.servicebus.models.CreateMessageBatchOptions; +import io.ballerina.lib.asb.util.ASBConstants; +import io.ballerina.lib.asb.util.ASBErrorCreator; +import io.ballerina.lib.asb.util.ASBUtils; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.TypeTags; @@ -38,9 +41,6 @@ import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; -import org.ballerinax.asb.util.ASBConstants; -import org.ballerinax.asb.util.ASBErrorCreator; -import org.ballerinax.asb.util.ASBUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +54,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.ballerinax.asb.util.ASBUtils.getRetryOptions; +import static io.ballerina.lib.asb.util.ASBUtils.getRetryOptions; /** * This facilitates the client operations of MessageSender client in Ballerina. diff --git a/native/src/main/java/org/ballerinax/asb/sender/SenderNetworkThreadFactory.java b/native/src/main/java/io/ballerina/lib/asb/sender/SenderNetworkThreadFactory.java similarity index 96% rename from native/src/main/java/org/ballerinax/asb/sender/SenderNetworkThreadFactory.java rename to native/src/main/java/io/ballerina/lib/asb/sender/SenderNetworkThreadFactory.java index 5a3a1b7f..14d2a8d1 100644 --- a/native/src/main/java/org/ballerinax/asb/sender/SenderNetworkThreadFactory.java +++ b/native/src/main/java/io/ballerina/lib/asb/sender/SenderNetworkThreadFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.sender; +package io.ballerina.lib.asb.sender; import java.util.concurrent.ThreadFactory; diff --git a/native/src/main/java/org/ballerinax/asb/util/ASBConstants.java b/native/src/main/java/io/ballerina/lib/asb/util/ASBConstants.java similarity index 99% rename from native/src/main/java/org/ballerinax/asb/util/ASBConstants.java rename to native/src/main/java/io/ballerina/lib/asb/util/ASBConstants.java index 9ee4c2f7..6afaa99e 100644 --- a/native/src/main/java/org/ballerinax/asb/util/ASBConstants.java +++ b/native/src/main/java/io/ballerina/lib/asb/util/ASBConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.util; +package io.ballerina.lib.asb.util; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BString; diff --git a/native/src/main/java/org/ballerinax/asb/util/ASBErrorCreator.java b/native/src/main/java/io/ballerina/lib/asb/util/ASBErrorCreator.java similarity index 84% rename from native/src/main/java/org/ballerinax/asb/util/ASBErrorCreator.java rename to native/src/main/java/io/ballerina/lib/asb/util/ASBErrorCreator.java index 88dcb3fd..b7788049 100644 --- a/native/src/main/java/org/ballerinax/asb/util/ASBErrorCreator.java +++ b/native/src/main/java/io/ballerina/lib/asb/util/ASBErrorCreator.java @@ -16,16 +16,14 @@ * under the License. */ -package org.ballerinax.asb.util; +package io.ballerina.lib.asb.util; + import com.azure.core.exception.HttpResponseException; import com.azure.messaging.servicebus.ServiceBusException; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BError; -import static org.ballerinax.asb.util.ASBConstants.ASB_ERROR; -import static org.ballerinax.asb.util.ModuleUtils.getModule; - /** * ASB module error related utilities. * @@ -50,7 +48,8 @@ public static BError fromBError(BError error) { return fromBError(error.getMessage(), error.getCause()); } public static BError fromBError(String message, BError cause) { - return ErrorCreator.createDistinctError(ASB_ERROR, getModule(), StringUtils.fromString(message), cause); + return ErrorCreator.createDistinctError( + ASBConstants.ASB_ERROR, ModuleUtils.getModule(), StringUtils.fromString(message), cause); } private static BError fromJavaException(String message, Throwable cause) { return fromBError(message, ErrorCreator.createError(cause)); @@ -58,12 +57,12 @@ private static BError fromJavaException(String message, Throwable cause) { public static BError createError(String message) { return ErrorCreator.createError( - ModuleUtils.getModule(), ASB_ERROR, StringUtils.fromString(message), null, null); + ModuleUtils.getModule(), ASBConstants.ASB_ERROR, StringUtils.fromString(message), null, null); } public static BError createError(String message, Throwable throwable) { BError cause = ErrorCreator.createError(throwable); return ErrorCreator.createError( - ModuleUtils.getModule(), ASB_ERROR, StringUtils.fromString(message), cause, null); + ModuleUtils.getModule(), ASBConstants.ASB_ERROR, StringUtils.fromString(message), cause, null); } } diff --git a/native/src/main/java/org/ballerinax/asb/util/ASBUtils.java b/native/src/main/java/io/ballerina/lib/asb/util/ASBUtils.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/util/ASBUtils.java rename to native/src/main/java/io/ballerina/lib/asb/util/ASBUtils.java index e7b1604d..e3f1cdb4 100644 --- a/native/src/main/java/org/ballerinax/asb/util/ASBUtils.java +++ b/native/src/main/java/io/ballerina/lib/asb/util/ASBUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.util; +package io.ballerina.lib.asb.util; import com.azure.core.amqp.AmqpRetryMode; import com.azure.core.amqp.AmqpRetryOptions; @@ -36,6 +36,7 @@ import com.azure.messaging.servicebus.administration.models.TopicProperties; import com.azure.messaging.servicebus.models.ServiceBusReceiveMode; import com.azure.messaging.servicebus.models.SubQueue; +import io.ballerina.lib.asb.receiver.MessageReceiver; import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.TypeCreator; @@ -61,7 +62,6 @@ import org.apache.qpid.proton.amqp.Binary; import org.ballerinalang.langlib.value.CloneWithType; import org.ballerinalang.langlib.value.FromJsonWithType; -import org.ballerinax.asb.receiver.MessageReceiver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,11 +85,6 @@ import static io.ballerina.runtime.api.constants.RuntimeConstants.ORG_NAME_SEPARATOR; import static io.ballerina.runtime.api.constants.RuntimeConstants.VERSION_SEPARATOR; import static io.ballerina.runtime.api.utils.TypeUtils.getReferredType; -import static org.ballerinax.asb.util.ASBConstants.DELAY; -import static org.ballerinax.asb.util.ASBConstants.MAX_DELAY; -import static org.ballerinax.asb.util.ASBConstants.MAX_RETRIES; -import static org.ballerinax.asb.util.ASBConstants.RETRY_MODE; -import static org.ballerinax.asb.util.ASBConstants.TRY_TIMEOUT; /** * Utility class for Azure Service Bus. @@ -279,11 +274,11 @@ public static Map toObjectMap(BMap map) { } public static AmqpRetryOptions getRetryOptions(BMap retryConfigs) { - Long maxRetries = retryConfigs.getIntValue(MAX_RETRIES); - BigDecimal delayConfig = ((BDecimal) retryConfigs.get(DELAY)).decimalValue(); - BigDecimal maxDelay = ((BDecimal) retryConfigs.get(MAX_DELAY)).decimalValue(); - BigDecimal tryTimeout = ((BDecimal) retryConfigs.get(TRY_TIMEOUT)).decimalValue(); - String retryMode = retryConfigs.getStringValue(RETRY_MODE).getValue(); + Long maxRetries = retryConfigs.getIntValue(ASBConstants.MAX_RETRIES); + BigDecimal delayConfig = ((BDecimal) retryConfigs.get(ASBConstants.DELAY)).decimalValue(); + BigDecimal maxDelay = ((BDecimal) retryConfigs.get(ASBConstants.MAX_DELAY)).decimalValue(); + BigDecimal tryTimeout = ((BDecimal) retryConfigs.get(ASBConstants.TRY_TIMEOUT)).decimalValue(); + String retryMode = retryConfigs.getStringValue(ASBConstants.RETRY_MODE).getValue(); return new AmqpRetryOptions() .setMaxRetries(maxRetries.intValue()) .setDelay(Duration.ofSeconds(delayConfig.intValue())) diff --git a/native/src/main/java/org/ballerinax/asb/util/ModuleUtils.java b/native/src/main/java/io/ballerina/lib/asb/util/ModuleUtils.java similarity index 98% rename from native/src/main/java/org/ballerinax/asb/util/ModuleUtils.java rename to native/src/main/java/io/ballerina/lib/asb/util/ModuleUtils.java index 6a51bca8..c98a75a8 100644 --- a/native/src/main/java/org/ballerinax/asb/util/ModuleUtils.java +++ b/native/src/main/java/io/ballerina/lib/asb/util/ModuleUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.ballerinax.asb.util; +package io.ballerina.lib.asb.util; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Module;