Git Product home page Git Product logo

Comments (12)

sonus21 avatar sonus21 commented on July 19, 2024

No this may not work always, so what I would say, you wrap your List into some class
e.g

class MyArrayObject{
   List<MyObject> myobjects;
}

@RqueueListener(value = myQueue)
public void informNextRoll(MyArrayObject yArrayObject) {
     //TODO
}


rqueueMessageSender.enqueueIn(myQueue, myArrayObject, 1, TimeUnit.SECONDS);

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

i did used a wrapper class already :)
i asked just to clarify my thoughts. ;)
... Just a question, it's a limitation in what exactly? Spring boot or Redis? If the limitation is in objects cast mapping, have you tried using Google Gson library (it's really powerful in mapping big nested json string objects)?

Thanks mate! :)

from rqueue.

sonus21 avatar sonus21 commented on July 19, 2024

... Just a question, it's a limitation in what exactly? Spring boot or Redis? If the limitation is in objects cast mapping, have you tried using Google Gson library (it's really powerful in mapping big nested json string objects)?

It's limitation of Rqueue, as we've no idea about the target message unless we parse the actual message, due to java type erasure, List<Xyz> is equivalent to List, so that's why it worked but what happens when you tried to do some operation than casting failed.

So internally Jackson converted JSON string to List in deserialisation process and that lead to failure.

I've made a change to accommodate list in enqueue, at the same time application should not mix list and simple object to the same queue.

See 8703893

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

Did you tried parsing the objects with gson lib? It's powerful, and you could set the parameter type of list objects. I use it often instead of jakson which requires more work to do the same with less performance.

I've made a change to accommodate list in enqueue, at the same time application should not mix list and simple object to the same queue.

Thanks for accepting this.

from rqueue.

sonus21 avatar sonus21 commented on July 19, 2024

Did you tried parsing the objects with gson lib? It's powerful, and you could set the parameter type of list objects. I use it often instead of jakson which requires more work to do the same with less performance.

I didn't try but i'm not sure how gson can handle this without knowing the target class, you can add your message converter that should deserialize and serialize array objects.

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

i suggested Gson, since it really doesn't need any configs to handle the target class structure. here is how to convert a json object string to instance :

// getting a single object instance.
MyObject myObjectInstance = new Gson().fromJson(objectData, MyObject.class);

// getting a list of objects instance.
List<MyObject > myObjectsList = new Gson().fromJson(listData, TypeToken.getParameterized(List.class, MyObject.class).getType());

...i'm not sure how gson can handle this without knowing the target class

couldn't we get it from the listener method parameter? Or why not save it as object metadata. And when fetching it, we convert it just like i suggested.

You could see how it's easy to use and trusted by many projects due to its efficiency: https://www.baeldung.com/java-json

please give it a try ;)

from rqueue.

sonus21 avatar sonus21 commented on July 19, 2024

couldn't we get it from the listener method parameter? Or why not save it as object metadata. And when fetching it, we convert it just like i suggested.

We store class name as meta data but List like data structure would require two information one for the list type and 2nd one for the item class. We concatenate them to form a final class name, In jackson we do something similar to Gson like

Class<?> envelopeClass =
            Thread.currentThread().getContextClassLoader().loadClass(classNames[0]);
Class<?> elementClass =
            Thread.currentThread().getContextClassLoader().loadClass(classNames[1]);
JavaType type =
            objectMapper
                .getTypeFactory()
                .constructCollectionType((Class<? extends Collection>) envelopeClass, elementClass);

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

so you made it work?? 😃

from rqueue.

sonus21 avatar sonus21 commented on July 19, 2024

Yes,
I think you missed the point, changelist 8703893 made it possible, you can try 2.1.0.RC to see if it's working for you or not.

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

Since you didn't referenced it here, I didn't noticed it. I will test it and let you know.

from rqueue.

sonus21 avatar sonus21 commented on July 19, 2024

I've made a change to accommodate list in enqueue, at the same time application should not mix list and simple object to the same queue.

See 8703893

@chlegou

from rqueue.

chlegou avatar chlegou commented on July 19, 2024

ah i missed it! i just tested v2.1.0.RC and it seems working perfectly for lists of objects. well done! 😃

from rqueue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.