Synchronous message production

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Synchronous message production

Vince Cole
I have a requirement to for my client (a JMS producer) to block, and only return once the message has been accepted onto the specified queue or topic. If the message is not accepted, then an exception should be thrown. We don't care whether anything actually consumes the message.

However, my client can only seem to produce messages in asynchronous mode!
So if there's an exception, all we can do is log it. That's not enough, I need the client to keep the message (so it can retry later) and only drop it once the broker has accepted it into the specified queue/topic.

Please could you advise if ActiveMQ supports synchronous production via a JMS client and if so what settings to use, in the following (where relevant):
* Options in the transport URI (in activemq.xml)
* Options in the connection URI (used by the client)
* Whether messages need to be 'persistent' or not?
* Whether the producer's JMS session should be transacted or not?
* What 'acknowledge mode' to set?
* Whether having a 'ConnectionListener' set on the connection will force it to be asynchronous, regardless?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

tabish121@gmail.com
On 03/07/2017 07:46 AM, Vince Cole wrote:

> I have a requirement to for my client (a JMS producer) to block, and only
> return once the message has been accepted onto the specified queue or topic.
> If the message is not accepted, then an exception should be thrown. We don't
> care whether anything actually consumes the message.
>
> However, my client can only seem to produce messages in asynchronous mode!
> So if there's an exception, all we can do is log it. That's not enough, I
> need the client to keep the message (so it can retry later) and only drop it
> once the broker has accepted it into the specified queue/topic.
>
> Please could you advise if ActiveMQ supports synchronous production via a
> JMS client and if so what settings to use, in the following (where

Give the docs a read, namely the configuration options that mention sync
send.
http://activemq.apache.org/connection-configuration-uri.html

> relevant):
> * Options in the transport URI (in activemq.xml)
> * Options in the connection URI (used by the client)
> * Whether messages need to be 'persistent' or not?
> * Whether the producer's JMS session should be transacted or not?
> * What 'acknowledge mode' to set?
> * Whether having a 'ConnectionListener' set on the connection will force it
> to be asynchronous, regardless?
>
> Thanks in advance.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Synchronous-message-production-tp4723171.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

Vince Cole
Thanks

I now see that my client should be setting jms.alwaysSyncSend=true (although the qpid documentation has it as jms.forceSyncSend=true, so I am setting both) option in the connection URI.

However, it is still operating asynchronously.

I forgot to mention that I am using a failover URI (with just a single broker URI inside it) in order to make the client automatically retry a dropped connection.

Could failover be forcing things into asynchronous mode?
And/or should the syncSend parameters be tacked onto the outer URI vs. the inner URI ?

In other words, is it:

  failover:( broker-uri-here?broker.params )?failover.params&sync.params

OR

  failover:( broker-uri-here?broker.params&sync.params )?failover.params

Thanks again in advance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

tabish121@gmail.com
On 03/07/2017 10:38 AM, Vince Cole wrote:
> Thanks
>
> I now see that my client should be setting *jms.alwaysSyncSend=true*
> (although the qpid documentation has it as *jms.forceSyncSend=true*, so I am
> setting both) option in the connection URI.
This is the ActiveMQ mailing list so my assumption is you are using the
ActiveMQ JMS client, if not you might want to clarify what it is you are
using.

>
> However, it is still operating asynchronously.

How are you testing this?

>
> I forgot to mention that I am using a failover URI (with just a single
> broker URI inside it) in order to make the client automatically retry a
> dropped connection.
>
> Could failover be forcing things into asynchronous mode?
> And/or should the syncSend parameters be tacked onto the outer URI vs. the
> inner URI ?
>
> In other words, is it:
>
>    failover:( broker-uri-here?broker.params )?failover.params&*sync.params*
>
> OR
>
>    failover:( broker-uri-here?broker.params&*sync.params* )?failover.params
>
> Thanks again in advance
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Synchronous-message-production-tp4723171p4723207.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

Vince Cole
Hi Tim

I am using
* javax.jms : javax.jms-api : 2.0.1
* org.apache.qpid : qpid-jms-client : 0.11.1
* org.apache.qpid : qpid-amqp-1-0-client-jms : 0.32

Apologies for the cross-post, I see you are also replying to this on the qpid forum, as yet I don't know if the problem lies in my use of ActiveMQ or Qpid, or is a more fundamental failure in my understanding of JMS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

Vince Cole
In reply to this post by tabish121@gmail.com
I am testing it, by means of making my client app send messages to a non-existent queue on the broker, as a user which does NOT have admin rights.

This fails as expected because the broker detects that the user is not allowed to the create the queue. If I then manually create the queue and try again, then it succeeds as expected, as the queue now exists and the client can send to it.

The problem is that the failure (in the first case) is not caught in a synchronous manner. My client's call to javax.jms.MessageProducer::send returns immediately, as if everything was OK only for some moments later my client's ConnectionListener to report the failure (a JMS security exception) in the log.

What I want instead is for the call to javax.jms.MessageProducer::send to be synchronous, so that the exception can be caught by the caller, not the ConnectionListener.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

tabish121@gmail.com
In reply to this post by Vince Cole
On 03/07/2017 11:01 AM, Vince Cole wrote:
> Hi Tim
>
> I am using
> * javax.jms : javax.jms-api : 2.0.1
> * org.apache.qpid : qpid-jms-client : 0.11.1

Latest version of Qpid JMS is 0.20.0 which I'd recommend you use

> * org.apache.qpid : qpid-amqp-1-0-client-jms : 0.32

This client is a defunct AMQP 1.0 JMS client that is no longer
maintained, remove it from your project and try again.

>
> Apologies for the cross-post, I see you are also replying to this on the
> qpid forum, as yet I don't know if the problem lies in my use of ActiveMQ or
> Qpid, or is a more fundamental failure in my understanding of JMS
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Synchronous-message-production-tp4723171p4723212.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synchronous message production

tabish121@gmail.com
In reply to this post by Vince Cole
First thing I'd do is settle on a single client (preferably the newest
Qpid JMS release) and then test, hard to say what is going one since you
somehow seem to be trying to use more than one at the same time.

On 03/07/2017 11:09 AM, Vince Cole wrote:

> I am testing it, by means of making my client app send messages to a
> non-existent queue on the broker, as a user which does NOT have admin
> rights.
>
> This fails as expected because the broker detects that the user is not
> allowed to the create the queue. If I then manually create the queue and try
> again, then it succeeds as expected, as the queue now exists and the client
> can send to it.
>
> The problem is that the failure (in the first case) is not caught in a
> synchronous manner. My client's call to javax.jms.MessageProducer::send
> returns immediately, as if everything was OK only for some moments later my
> client's ConnectionListener to report the failure (a JMS security exception)
> in the log.
>
> What I want instead is for the call to javax.jms.MessageProducer::send to be
> synchronous, so that the exception can be caught by the caller, not the
> ConnectionListener.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Synchronous-message-production-tp4723171p4723214.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/

Loading...