Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.36k stars 2k forks source link

[BUG] Azure Communication Service Job Router Java SDK having Deserialize Issue for RouterValue class #40803

Open TongJun86 opened 5 months ago

TongJun86 commented 5 months ago

Describe the bug Hi, I am using Azure Communicaton Service Job Router Java SDK, when I tried to create the router queue, store the queue id inside db and get the router queue via the queue id stored inside db, it hits deserialize issue for JobValue. I expect to be able to get the queue and proceed with the job assignment. This issue seems occurred for RouterWorker, RouterJob and other classes which used RouterValue. May I know is this an issue for job router java sdk or I do any mistake?

Exception or Stack Trace java.io.UncheckedIOException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of com.azure.communication.jobrouter.models.RouterValue (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('Queue240624081839523') at [Source: (byte[])"{"id":"Queue240624081839523","distributionPolicyId":"Policy240624081839523","labels":{"Id":"Queue240624081839523"},"etag":"\"0200df90-0000-1100-0000-6678bb620000\""}"; line: 1, column: 92] (through reference chain: com.azure.communication.jobrouter.models.RouterQueue["labels"]->java.util.LinkedHashMap["Id"]) at com.azure.core.implementation.serializer.DefaultJsonSerializer.deserializeFromBytes(DefaultJsonSerializer.java:34) ~[azure-core-1.49.0.jar:1.49.0] at com.azure.core.implementation.util.FluxByteBufferContent.toObject(FluxByteBufferContent.java:99) ~[azure-core-1.49.0.jar:1.49.0] at com.azure.core.util.BinaryData.toObject(BinaryData.java:1116) ~[azure-core-1.49.0.jar:1.49.0] at com.azure.core.util.BinaryData.toObject(BinaryData.java:927) ~[azure-core-1.49.0.jar:1.49.0] at com.azure.communication.jobrouter.JobRouterAdministrationClient.getQueue(JobRouterAdministrationClient.java:1790) ~[azure-communication-jobrouter-1.1.4.jar:1.1.4] at com.communication.service.jobrouter.JobRouterSettingServiceImpl.getRouterQueue(JobRouterSettingServiceImpl.java:90) ~[communication-service.jar:na] at com.communication.service.jobrouter.JobRouterSettingServiceImpl.createNewRouterWorker(JobRouterSettingServiceImpl.java:217) ~[communication-service.jar:na] at com.communication.service.jobrouter.JobRouterSettingServiceImpl.findRouterWorker(JobRouterSettingServiceImpl.java:206) ~[communication-service.jar:na] at com.communication.service.jobrouter.JobRouterSettingServiceImpl.deregisterWorker(JobRouterSettingServiceImpl.java:165) ~[communication-service.jar:na] at com.communication.service.jobrouter.JobRouterSettingServiceImpl.updateWorkerAvailability(JobRouterSettingServiceImpl.java:76) ~[communication-service.jar:na] at com.communication.service.profile.ProfileNameServiceImpl.updateProfileOnlineStatus(ProfileNameServiceImpl.java:115) ~[communication-service.jar:na]

To Reproduce Steps to reproduce the behavior:

  1. Import Job Router java sdk dependency
  2. Create a new router queue
  3. Get router queue via the queue id

Code Snippet Create router queue:

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyMMddHHmmssSSS"); String routerQueueId = "Queue".concat(simpleDateFormat.format(new Date())); String distributionPolicyId = "Policy".concat(simpleDateFormat.format(new Date())); DistributionPolicy distributionPolicy = createDistributionPolicy(distributionPolicyId); CreateQueueOptions createQueueOptions = new CreateQueueOptions(routerQueueId, distributionPolicyId); jobRouterAdministrationClient.createQueue(createQueueOptions);

Get router queue:

if (!StringUtils.isEmpty(routerQueueId)) { routerQueue = jobRouterAdministrationClient.getQueue(routerQueueId); }

Expected behavior The queue seems to be created successfully, but when I try to get via the queue id, it hits deserialize issue. I expect to be able to get the queue and proceed with the job assignment.

Screenshots

Screenshot 2024-06-24 at 8 19 53 AM Screenshot 2024-06-24 at 8 22 28 AM Screenshot 2024-06-24 at 8 22 33 AM

Setup (please complete the following information):

Additional context If this is an issue, what will be the expected date to solve? Is there any temporary solution for this?

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

TongJun86 commented 5 months ago

Do this latest commit for azure job router java SDK related to this issue?

https://github.com/Azure/azure-sdk-for-java/commit/0a1712a2801bdfbc58b9b03d219104e429122346#diff-fec1f4971405d5fc5cc800e9ffb3c9256d32708158965fab322f6728be5a4652

alzimmermsft commented 5 months ago

Thanks for filing this issue @TongJun86, I believe you are correct that the commit you shared should fix this issue as it removed the usage of Jackson from Azure Communication Job Router, which removed the expectation that RouterValue had those JSON property names for string, int, double, and boolean values when it really doesn't.

@williamzhao87 can you track this issue and update it when the new version of Azure Communication Job Router is released.

TongJun86 commented 4 months ago

Hi @alzimmermsft @williamzhao87 , thank you for the response.

May I know is there any alternative suggested for now? And may I also know around when will be the target date for new version release of Azure Communication Job Router?

Thanks!

williamzhao87 commented 4 months ago

Hi @TongJun86, please use a 2.0.0 alpha version, similar to the ones in this QuickStart for now:

https://github.com/Azure-Samples/communication-services-java-quickstarts/blob/a18003fb5575bb29780151c73bd67bd3702ebd10/jobrouter-quickstart-java/pom.xml#L30

We should have a new version released soon.