amqphub / quarkus-qpid-jms

Quarkus extension for using the Qpid JMS AMQP 1.0 client.
Apache License 2.0
12 stars 11 forks source link

setObject on ObjectMessage hangs when running in GraalVM #10

Open chughts opened 3 years ago

chughts commented 3 years ago

I have code that creates and puts in turn TextMessage, BytesMessage, StreamMessage, ObjectMessage and MapMessage onto queues. It works when running under standard Quarkus, but when the code is compiled and run as a GraalVM executable it hangs, with no timeout on

setObject

code just enough to recreate:

import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.ObjectMessage;

@Inject
ConnectionFactory factory;

JMSContext context = factory.createContext(JMSContext.AUTO_ACKNOWLEDGE);
ObjectMessage om = context.createObjectMessage();

try {
    String d = new String("ObjectMessage");
    om.setObject(d);
} catch (JMSException e) {
        ...
}
gemmellr commented 3 years ago

I don't see it hang, but throw, coming directly from GraalVM being unable to do the needed ObjectOutputStream.writeObject() serialization operation:

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: ObjectOutputStream.writeObject()
        at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:68)
        ...
        at org.apache.qpid.jms.message.JmsObjectMessage.setObject(JmsObjectMessage.java:47)

This is confirmed by https://github.com/oracle/graal/issues/460, though that does now indicate support is coming in GraalVM 21.0.0 via https://github.com/oracle/graal/pull/2730

chughts commented 3 years ago

I am currently on LLVM (GraalVM CE Native 20.2.0) Running on a Mac (Catalina)

I am not getting the exception, only a hang.

gemmellr commented 3 years ago

I was using GraalVM CE 20.3.0 and my own reproducer. Note that it isn't an [JMS]Exception that is thrown but an Error. The above code example wont catch it.

chughts commented 3 years ago

You are right. Adding a catch(Error e), shows up the thrown error.

I was expecting anything I didn't catch to bubble up through the Quarkus code and show up in the logs.

cescoffier commented 2 years ago

Serialization has been added into GraalVM. Worth rechecking with a recent version. If you use "custom" objects, make sure they are annotated with @RegisterForReflection

chughts commented 2 years ago

I will give it a go.