Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

amqp - How to set ContentType in qpid JMS

Hello this question is related to this and I'd like to know if there is any way to set ContentType header in qpid in JMS context. We are using JmsConnectionFactory and spring's JMS library.

I was trying to find some way using extension but can't find the way or if that's even possible.

    final org.apache.qpid.jms.JmsConnectionFactory jmsConnectionFactory = new org.apache.qpid.jms.JmsConnectionFactory();
    jmsConnectionFactory.setExtension("headers", (connection, uri) -> {
      if (connection instanceof JmsConnection) {

      }
    });
question from:https://stackoverflow.com/questions/65941899/how-to-set-contenttype-in-qpid-jms

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is no exposed means of setting the content-type on the messages sent from the Qpid JMS client. The client itself uses this field as part of the JMS mapping to AMQP to distinguish certain message types that it sends and to determine at receive time what certain messages should be presented as.

It is technically possible to use reflection to reach in and so the value but the APIs you have to use from the JmsMessageFacade class are not public and could change with any release so choosing to do so comes with significant risk.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...