You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Vince Cole <me...@vincecole.co.uk> on 2017/03/07 14:15:54 UTC

synchronous sending - using javax.jms.MessageProducer::send

I have a requirement to for my JMS client 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 application to keep the message (so it can retry later) and
only drop it once the broker has accepted it into the specified
queue/topic.

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
* The broker is ActiveMQ 5.14.0, if that makes any difference.

Please could you advise if the Qpid Java client library supports
synchronous production
and if so what settings to use, to acheive that, 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.

Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Robbie Gemmell <ro...@gmail.com>.
On 7 March 2017 at 15:57, Vince Cole <th...@gmail.com> wrote:
> Hi Tim
>
> Thanks
>
> I now see that my client should be setting *jms.forceSyncSend=true*
> (although the ActiveMQ documentation has it as *jms.alwaysSyncSend=true*, so
> I am setting both) option in the connection URI.

Dont set config options for the ActiveMQ client if you arent using it.
Some of the options are similar between the two, as we combined some
earlier work and collaborated on the AMQP 1.0 JMS client, but they are
different clients and the options/behaviours are not exactly the same
between them.

>
> 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
>

The 'jms.' options go on the outside with the failover URI as the
documentation notes and the examples included there show:
http://qpid.apache.org/releases/qpid-jms-0.11.1/docs/index.html#failover-configuration-options

Non-persistent messages will be sent async by default. Persistent
messages will be sent synchronously by default, except within a
transaction where the transaction. The options let you change this to
suit your desired behaviour.

>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/synchronous-sending-using-javax-jms-MessageProducer-send-tp7660152p7660155.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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


Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Vince Cole <th...@gmail.com>.
Hi Tim

Thanks 

I now see that my client should be setting *jms.forceSyncSend=true*
(although the ActiveMQ documentation has it as *jms.alwaysSyncSend=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 



--
View this message in context: http://qpid.2158936.n2.nabble.com/synchronous-sending-using-javax-jms-MessageProducer-send-tp7660152p7660155.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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


Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Timothy Bish <ta...@gmail.com>.
On 03/07/2017 09:21 AM, Vince Cole wrote:
> I have a requirement to for my JMS client 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 application to keep the message (so it can retry later) and
> only drop it once the broker has accepted it into the specified
> queue/topic.
>
> I am using:
> * javax.jms : javax.jms-api : 2.0.1
> * org.apache.qpid : qpid-jms-client : 0.11.1

The client offers documentation of all the configuration options some of 
which control when messages are sent sync or async, give that a look.

http://qpid.apache.org/releases/qpid-jms-0.11.1/docs/index.html

> * org.apache.qpid : qpid-amqp-1-0-client-jms : 0.32
> * The broker is ActiveMQ 5.14.0, if that makes any difference.
>
> Please could you advise if the Qpid Java client library supports synchronous
>   production and if so what settings to use, to acheive that, 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.
>


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


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


Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Robbie Gemmell <ro...@gmail.com>.
The current AMQP 1.0 JMS client, qpid-jms-client, does use proton-j.
The older qpid-amqp-1-0-client-jms does not use proton.

If you are using maven, look at http://qpid.apache.org/maven.html for
the current dependency detail. The current release is 0.20.0, and
0.21.0 should enter the release process late this week.

Robbie

On 7 March 2017 at 15:53, Vince Cole <th...@gmail.com> wrote:
> Hi Rob
>
> I guess I'm a bit confused too.
>
> I need to use JMS and AMQP 1.0, thought I was using the correct
> dependencies, as underneath they use proton-j, but now I'm not so sure.
>
> I'll see what happens if I pull either of the client libraries out...
>
>
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/synchronous-sending-using-javax-jms-MessageProducer-send-tp7660152p7660154.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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


Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Rob Godfrey <ro...@gmail.com>.
On 7 March 2017 at 16:53, Vince Cole <th...@gmail.com> wrote:

> Hi Rob
>
> I guess I'm a bit confused too.
>
> I need to use JMS and AMQP 1.0, thought I was using the correct
> dependencies, as underneath they use proton-j, but now I'm not so sure.
>
>
qpid-amqp-1-0-client-jms is an older client that was not built upon Proton;
qpid-jms-client is the supported client library for JMS over AMQP 1.0 and
*is* built on Proton.


> I'll see what happens if I pull either of the client libraries out...
>
>
As above, presuming that you are actually using the qpid-jms-client the you
can remove any reference to qpid-amqp-1-0-* .  The two clients use
differently named connection factories, and different URL formats, so it
should be easy enough to tell which you are using.

-- Rob


>
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.
> com/synchronous-sending-using-javax-jms-MessageProducer-
> send-tp7660152p7660154.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Vince Cole <th...@gmail.com>.
Hi Rob

I guess I'm a bit confused too. 

I need to use JMS and AMQP 1.0, thought I was using the correct
dependencies, as underneath they use proton-j, but now I'm not so sure.

I'll see what happens if I pull either of the client libraries out...





--
View this message in context: http://qpid.2158936.n2.nabble.com/synchronous-sending-using-javax-jms-MessageProducer-send-tp7660152p7660154.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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


Re: synchronous sending - using javax.jms.MessageProducer::send

Posted by Rob Godfrey <ro...@gmail.com>.
Hi Vince,

On 7 March 2017 at 15:21, Vince Cole <th...@gmail.com> wrote:

>
>
> 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
>

I'm a bit confused by this: qpid-jms-client and qpid-amqp-1-0-client-jms
are two different client libraries which each attempt to implement JMS over
AMQP 1.0 - which of the two libraries are you actually using?  (Note that
we are no longer updating qpid-amqp-1-0-client-jms, and also that the
latest release of qpid-jms-client is 0.20.0).

-- Rob

synchronous sending - using javax.jms.MessageProducer::send

Posted by Vince Cole <th...@gmail.com>.
I have a requirement to for my JMS client 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 application to keep the message (so it can retry later) and
only drop it once the broker has accepted it into the specified
queue/topic.

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
* The broker is ActiveMQ 5.14.0, if that makes any difference.

Please could you advise if the Qpid Java client library supports synchronous
 production and if so what settings to use, to acheive that, 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.