Comments (12)
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.
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.
... 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.
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.
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.
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.
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.
so you made it work?? 😃
from rqueue.
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.
Since you didn't referenced it here, I didn't noticed it. I will test it and let you know.
from rqueue.
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.
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)
- Serialization support java time module HOT 1
- Deleted messages are kept in memory HOT 5
- Add static resource mapping handler when rqueue.web.url.prefix is set HOT 5
- Weighted priorisation with maximum concurrency HOT 2
- Question: Re-starting processing task when system restarts HOT 7
- Do you plan to use spring-cloud-sleuth to propagate the traceId? HOT 5
- Dashboard shows empty even thought Rqueue is working fine HOT 13
- Question: Integration scenario with multiple queues HOT 4
- rqueue workflow discussion HOT 4
- Support of jackson-databind 2.16.0 HOT 3
- Login/pass for queue dashboard HOT 4
- Lack of available threads HOT 2
- Service-Level Concurrency Control HOT 1
- IllegalArgumentException when accessing queue details HOT 1
- springboot 3.2 can not work HOT 5
- springboot 2.7 can not work HOT 9
- Typo in dashboard text HOT 2
- RQueue attempting to bootstrap despite being "disabled" HOT 1
- Best practice of initializing a queue (producer only) HOT 1
- RqueueListener sometimes do not consume message. (Intermittently) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rqueue.