You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Kevin Burton <bu...@spinn3r.com> on 2014/06/14 22:19:24 UTC

Should connection.createSession throw an exception if the connection isn't started?

So this bit me… mostly because I'm new to activemq but also because
silently failing isn't fun.

You can create a connection, create a producer, send messages on it, and
attempt to receive messages, all while the connection hasn't been started.

So my code compiled, but of course no IO was begin performed.

Which was obviously rather confusing.

It would seem that the best strategy is to throw an exception if you try to
create a session on a connection that isn't started.

Is there a reason why you would want a connection that's NOT started?

Of course… ActiveMQ is rather stable and robust… so maybe this has been
discussed before and it's some sort of anti-pattern.  Though I can't
believe I'm the only one who has been bitten by this.

Kevin


-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
Skype: *burtonator*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>
War is peace. Freedom is slavery. Ignorance is strength. Corporations are
people.

Re: Should connection.createSession throw an exception if the connection isn't started?

Posted by Matthew Pavlovich <ma...@pavlovich.com>.
I can only think of edge cases where you would want to setup everything on the client side before making the connection.start() call.  Generally, I instantiate the .start() right away.

-Matt

On Jun 14, 2014, at 3:19 PM, Kevin Burton <bu...@spinn3r.com> wrote:

> So this bit me… mostly because I'm new to activemq but also because
> silently failing isn't fun.
> 
> You can create a connection, create a producer, send messages on it, and
> attempt to receive messages, all while the connection hasn't been started.
> 
> So my code compiled, but of course no IO was begin performed.
> 
> Which was obviously rather confusing.
> 
> It would seem that the best strategy is to throw an exception if you try to
> create a session on a connection that isn't started.
> 
> Is there a reason why you would want a connection that's NOT started?
> 
> Of course… ActiveMQ is rather stable and robust… so maybe this has been
> discussed before and it's some sort of anti-pattern.  Though I can't
> believe I'm the only one who has been bitten by this.
> 
> Kevin
> 
> 
> -- 
> 
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> Skype: *burtonator*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>
> War is peace. Freedom is slavery. Ignorance is strength. Corporations are
> people.


Re: Re: Should connection.createSession throw an exception if the connection isn't started?

Posted by "yuqingshui@qq.com" <yu...@qq.com>.
I think there is a problem with cleaning up acknowledged messages from
database when they belong to a topic which consumers use selectors in
ActiveMQ. The delete statement (that can be configured) takes min value of
acked messages of all selectors in the topic, but if consumers of messages
use selectors, it can happen that messages are not being cleaned up. For
example, let's take three selectors with names A,B,C. Assume that all
messages are addressed only to A and B. The min value of last_acked message
will be 0 all the time according to the statement, so the acked messages
won't be deleted. There is a possibility to tune the delete statement, but I
think that it should be propably taken into account but default to delete
those kind of acknowledged messages.




yuqingshui@qq.com

From: John D. Ament
Date: 2014-06-15 04:42
To: users
Subject: Re: Should connection.createSession throw an exception if the connection isn't started?
This is one of the *great* features in the JMS spec.

On Sat, Jun 14, 2014 at 4:19 PM, Kevin Burton <bu...@spinn3r.com> wrote:
> So this bit me… mostly because I'm new to activemq but also because
> silently failing isn't fun.
>
> You can create a connection, create a producer, send messages on it, and
> attempt to receive messages, all while the connection hasn't been started.
>
> So my code compiled, but of course no IO was begin performed.
>
> Which was obviously rather confusing.
>
> It would seem that the best strategy is to throw an exception if you try to
> create a session on a connection that isn't started.
>
> Is there a reason why you would want a connection that's NOT started?
>
> Of course… ActiveMQ is rather stable and robust… so maybe this has been
> discussed before and it's some sort of anti-pattern.  Though I can't
> believe I'm the only one who has been bitten by this.
>
> Kevin
>
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> Skype: *burtonator*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>
> War is peace. Freedom is slavery. Ignorance is strength. Corporations are
> people.
.

Re: Should connection.createSession throw an exception if the connection isn't started?

Posted by "John D. Ament" <jo...@gmail.com>.
This is one of the *great* features in the JMS spec.

On Sat, Jun 14, 2014 at 4:19 PM, Kevin Burton <bu...@spinn3r.com> wrote:
> So this bit me… mostly because I'm new to activemq but also because
> silently failing isn't fun.
>
> You can create a connection, create a producer, send messages on it, and
> attempt to receive messages, all while the connection hasn't been started.
>
> So my code compiled, but of course no IO was begin performed.
>
> Which was obviously rather confusing.
>
> It would seem that the best strategy is to throw an exception if you try to
> create a session on a connection that isn't started.
>
> Is there a reason why you would want a connection that's NOT started?
>
> Of course… ActiveMQ is rather stable and robust… so maybe this has been
> discussed before and it's some sort of anti-pattern.  Though I can't
> believe I'm the only one who has been bitten by this.
>
> Kevin
>
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> Skype: *burtonator*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>
> War is peace. Freedom is slavery. Ignorance is strength. Corporations are
> people.

Re: Should connection.createSession throw an exception if the connection isn't started?

Posted by artnaseef <ar...@artnaseef.com>.
The JMS spec does call out the need to call start() before consuming
messages.  There is setup that can experience race conditions, or
order-of-operation problems otherwise.  For example, a connection listener
cannot be reliably added to a connection before it's needed.

It's frustrating to experience the problem of simply failing to consume,
especially since it all "just looks right" otherwise.




--
View this message in context: http://activemq.2283324.n4.nabble.com/Should-connection-createSession-throw-an-exception-if-the-connection-isn-t-started-tp4682160p4682181.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.