You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by James Adams <mo...@gmail.com> on 2009/01/07 21:20:41 UTC

Embedded broker is always empty (no messages) each time it's started?

When I start an embedded ActiveMQ broker it is a fresh/clean/empty queue,
right?  My understanding was that there is no possibility of messages
building up from previous test runs or other message senders adding messages
to a queue which will be present the next time the embedded ActiveMQ broker
comes up.  The reason I ask is that I assume that the above is the case, and
my tests are expecting an empty queue each time they run, and I sometimes
see messages in the queue which shouldn't be in the queue as a result of my
test run, so I thought maybe they're leftovers from a previous test run. 
Can someone confirm that I am not mistaken about how the embedded broker
starts, so I can know that messages I read from my queue in a test are in
fact only messages which could have been sent as a result of my test (which
starts the embedded broker using Spring) and not leftovers from previous
runs.

Thanks in advance for any comments.

--James
-- 
View this message in context: http://www.nabble.com/Embedded-broker-is-always-empty-%28no-messages%29-each-time-it%27s-started--tp21339447p21339447.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Embedded broker is always empty (no messages) each time it's started?

Posted by Gary Tully <ga...@gmail.com>.
An embedded broker is no different from an non embedded broker. By
default it will use a message store for any persistent messages. If
you want a broker to always start with an empty store there is a
deleteAllMessagesOnStartup attribute on BrokerService that will clear
out the store for you.
Alternatively you could set the persistent attribute to false and a
memory store  (will will not persist any messages to disk) will be
used.
Persistent messages are the default for a standard JMS client.


2009/1/7 James Adams <mo...@gmail.com>:
>
> When I start an embedded ActiveMQ broker it is a fresh/clean/empty queue,
> right?  My understanding was that there is no possibility of messages
> building up from previous test runs or other message senders adding messages
> to a queue which will be present the next time the embedded ActiveMQ broker
> comes up.  The reason I ask is that I assume that the above is the case, and
> my tests are expecting an empty queue each time they run, and I sometimes
> see messages in the queue which shouldn't be in the queue as a result of my
> test run, so I thought maybe they're leftovers from a previous test run.
> Can someone confirm that I am not mistaken about how the embedded broker
> starts, so I can know that messages I read from my queue in a test are in
> fact only messages which could have been sent as a result of my test (which
> starts the embedded broker using Spring) and not leftovers from previous
> runs.
>
> Thanks in advance for any comments.
>
> --James
> --
> View this message in context: http://www.nabble.com/Embedded-broker-is-always-empty-%28no-messages%29-each-time-it%27s-started--tp21339447p21339447.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com

Re: Embedded broker is always empty (no messages) each time it's started?

Posted by David Jencks <da...@yahoo.com>.
On Jan 7, 2009, at 12:20 PM, James Adams wrote:

>
> When I start an embedded ActiveMQ broker it is a fresh/clean/empty  
> queue,
> right?

I haven't used the embedded broker much but I think this is wrong.   
AFAIK unless you configure a broker to use the  
MemoryPersistenceAdapter it will use some kind of file system or  
database storage for all persistent messages, so, as per spec, they  
will survive a server shutdown.

You might be able to find and remove the data files between runs....  
although with e.g. junit creating all the tests before running any of  
them this might cause problems.  You might also be able to configure  
each test to use a different directory.  Or find a way to use the  
MemoryPersistenceAdapter.  Unfortunately I don't know how to do any of  
these things.

thanks
david jencks

>  My understanding was that there is no possibility of messages
> building up from previous test runs or other message senders adding  
> messages
> to a queue which will be present the next time the embedded ActiveMQ  
> broker
> comes up.  The reason I ask is that I assume that the above is the  
> case, and
> my tests are expecting an empty queue each time they run, and I  
> sometimes
> see messages in the queue which shouldn't be in the queue as a  
> result of my
> test run, so I thought maybe they're leftovers from a previous test  
> run.
> Can someone confirm that I am not mistaken about how the embedded  
> broker
> starts, so I can know that messages I read from my queue in a test  
> are in
> fact only messages which could have been sent as a result of my test  
> (which
> starts the embedded broker using Spring) and not leftovers from  
> previous
> runs.
>
> Thanks in advance for any comments.
>
> --James
> -- 
> View this message in context: http://www.nabble.com/Embedded-broker-is-always-empty-%28no-messages%29-each-time-it%27s-started--tp21339447p21339447.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>