-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ConsumeEvent does not work in native when returning a Uni<Set<String>> #36172
Comments
/cc @cescoffier (redis), @gsmet (redis), @machi1990 (redis) |
So, you say that the commands are correctly executed by Redis? |
Here is the redis monitor output (smembers is for the mutiny map and scan for the orElseGet) for the native app:
and the caught exception at event bus producer side (not sure it will help):
The Redis monitor output is the same as above for JVM mode but as said, the code works fine, I mean it serves the expected HTTP response which it is not the case with the native app. |
So just to be 100% clear, everything works properly in JVM mode? |
Yes everything works properly in JVM mode. |
I would need a reproducer as a simple test (added to our ITs) works. Also, the code can be simplified:
|
Here is the reproducer project https://github.com/tnmtechnologies/quarkusRedisReactiveKeyScanCursorReproducer . Thanks for the KEYS command. I agree it simplifies but there is a warning in the documentation: |
Thanks, I will check the reproducer. Yes, the key command and the key scan command should be used with caution. |
In your reproducer you do not mention the redis version and how many key do you have. |
I have updated the README file. |
The issue seems to be in the event bus, not in Redis. The redis code produces the expected output, but it looks like the event is lost on the event bus. |
The issue is the usage of Set as reply. The local codec does not seem to work in this case in native. We need to have a look (probably with the help of @mkouba ). If you use something like: public static class MySet extends HashSet<String> {
public MySet() {
super();
}
public MySet(Set<String> s) {
super(s);
}
}
/**
*
*/
@ConsumeEvent("getIds")
public Uni<MySet> getIds(final JsonObject message) {
Log.infov("getIds(message={0})", message);
final Long limit = Optional.ofNullable(message.getLong("limit")).orElse(Long.MAX_VALUE);
final String type = message.getString("type");
return Optional.ofNullable(type)
.map(t -> {
final ReactiveSetCommands<String,String> setCommands = rds.set(String.class);
return setCommands.smembers(TYPE_NAMESPACE + t);
}).orElseGet(() -> {
final ReactiveKeyCommands<String> keyCommands = rds.key(String.class);
final ReactiveKeyScanCursor<String> scanCursor = keyCommands.scan(new KeyScanArgs().match(ID_NAMESPACE + '*').count(Long.MAX_VALUE));
final boolean hasNext = scanCursor.hasNext();
System.out.println("Has next...");
return hasNext ? scanCursor.next() : Uni.createFrom().item(() -> Collections.emptySet());
}).onItem().transformToMulti(s -> Multi.createFrom().items(s::stream))
.select().first(limit)
.onItem().transform(s -> type != null ? s : s.substring(ID_NAMESPACE.length()))
.collect().asSet()
.map(s -> new MySet(s))
.log("user code")
;
} It works |
Thanks a lot @cescoffier, the work around works. |
It seems that we only register the @tnmtechnologies In theory, you don't need to create the @cescoffier I'm not quite sure if we could do something to improve the UX in similar cases... |
@mkouba thanks for the analysis. In terms of UX, should we detect when a @ConsumeEvent method return an interface and log a warning in this case (if no codec for that type is found) ? |
Hm, we could log a warning when a consumer method returns an interface or |
@mkouba Thank you, It works. |
@mkouba ah yes.... So what about just documenting it as a limitation for now? |
Yes, we should extend the Use codecs section and explain how the default codec is registered for a return type. And make it clear that registering a default codec for an interface is of no use. And maybe add how to register a default codec for a type + register for reflection for native image. I will send a PR tomorrow. |
Hm, I think that we could actually improve the UX a little bit and register a default codec selector with |
Ah yes! Good idea! I forgot about the selector. |
Describe the bug
Quarkus 3.4.1
Redis 7.2.1
I use event bus consumer to run the redis client logic.
In JVM mode, the following piece of code works fine but with native executable, it fails with a timeout (30s default value I guess) at event bus sender side.
Thanks to the redis MONITOR command, I can see the command processed by redis.
I did some tests with Quarkus 3.2.6.Final. I have the same behavior.
Expected behavior
The code should work in native executable as for JVM mode.
Actual behavior
The code works in JVM mode but fails with native executable.
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.4.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Additional information
No response
The text was updated successfully, but these errors were encountered: