You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by jxz024000 <zh...@hotmail.com> on 2019/09/26 03:59:36 UTC

Set message annotation with Qpid jms client

Hi Rob,

In our project, we use the new qpid jms client with Azure service bus. We
need to use the scheduled delivery feature in service bus. I found one
stackoverflow article with an example on how to do it with message
annotation
(https://stackoverflow.com/questions/45631740/how-to-send-scheduled-message-to-azure-service-bus-with-jms).
When I tried to use the example code, it complains the
((AmqpJmsTextMessageFacade)((JmsTextMessage)textMessage).getFacade()).getAmqpMessage()
line. Obviously getAmqpMessage() no longer exist in AmqpJmsTextMessageFacade
class. I checked the source code of AmqpJmsMessageFacade and found there is
a package private method setMessageAnnotation to set message annotations.
But since it is package private method, we can't use it. I google around
this issue about setting message annotation and found this old post and the
issue here (https://issues.apache.org/jira/browse/QPIDJMS-153,  
http://qpid.2158936.n2.nabble.com/JMS-client-set-headers-message-and-delivery-annotations-td7639762.html).
It looks the enhancement hasn't been not done yet. So is it only option for
me now is to use reflection to call setMessageAnnotation. Is there other
option here if we still want to use JMS.

Thanks,
Jay



--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Set message annotation with Qpid jms client

Posted by jxz024000 <zh...@hotmail.com>.
Thanks Rob. I upgraded qpid to 0.45.0 and the code works as expected. Here is
my code if anyone needs to use the same feature.





--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Set message annotation with Qpid jms client

Posted by Robbie Gemmell <ro...@gmail.com>.
The refective route you noted would work. There is an alternative
route that could be taken more easily without reflection since 0.45.0
(still requires casting) due to the changes made during
https://issues.apache.org/jira/browse/QPIDJMS-471. If you track the
new usage of the AmqpJmsMessageFacade messageAnnotationsMap field it
should be obvious.

If Microsoft were to implement support for
https://www.oasis-open.org/committees/document.php?document_id=65347
that would enable the mechanism used for years by the JMS client to
indicate scheduled delivery via the JMS 2.0 Delivery Delay feature
(e.g https://docs.oracle.com/javaee/7/api/javax/jms/MessageProducer.html#setDeliveryDelay-long-)

Robbie

On Thu, 26 Sep 2019 at 05:07, jxz024000 <zh...@hotmail.com> wrote:
>
> Hi Rob,
>
> In our project, we use the new qpid jms client with Azure service bus. We
> need to use the scheduled delivery feature in service bus. I found one
> stackoverflow article with an example on how to do it with message
> annotation
> (https://stackoverflow.com/questions/45631740/how-to-send-scheduled-message-to-azure-service-bus-with-jms).
> When I tried to use the example code, it complains the
> ((AmqpJmsTextMessageFacade)((JmsTextMessage)textMessage).getFacade()).getAmqpMessage()
> line. Obviously getAmqpMessage() no longer exist in AmqpJmsTextMessageFacade
> class. I checked the source code of AmqpJmsMessageFacade and found there is
> a package private method setMessageAnnotation to set message annotations.
> But since it is package private method, we can't use it. I google around
> this issue about setting message annotation and found this old post and the
> issue here (https://issues.apache.org/jira/browse/QPIDJMS-153,
> http://qpid.2158936.n2.nabble.com/JMS-client-set-headers-message-and-delivery-annotations-td7639762.html).
> It looks the enhancement hasn't been not done yet. So is it only option for
> me now is to use reflection to call setMessageAnnotation. Is there other
> option here if we still want to use JMS.
>
> Thanks,
> Jay
>
>
>
> --
> Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org