Well you kind of answered that yourself before. If the embedded is a slave then the broker startup will wait for the master to fail, which could be never. It never actually gets the lock (either in JDBC, KahaDB or others) until the master dies. TomEE is trying to control the embedded ActiveMQ through the API, so making it block is just not going to play nicely. The StartupTimeout will eventually come in to play, but there may be side effects .

I can understand what you want (I hope). If you want a local slave and remote master, or even both remote then start the AMQ servers before you start TomEE and just let TomEE be the client. Set config to nothing: BrokerXmlConfig = , and the ServerUrl URL to the failover as you do already.

Andy.

On 27/10/2014 14:09, Leonardo K. Shikida wrote:
Hi Andy, thanks for the ideas, I'll give them a try.

Just one thing. Why "The embedded ActiveMQ should not be a slave"?



[]

Leo

On Sun, Oct 26, 2014 at 7:12 AM, Andy Gumbrecht <[email protected] <mailto:[email protected]>> wrote:

    Hi Leonardo,

    I have used ActiveMQ and failover in production for years and not
    had any issues. So my gut feeling is telling me this is something
    else. Let's see if we can get this resolved without changing your
    architecture.

    The default StartupTimeout is 30 seconds. If the broker is not
    started within this period then TomEE startup will continue. I
    don't see where it would wait forever? Can you perform a thread
    dump and see where it is blocking in your startup if it takes
    longer than 30 seconds (or change the StartupTimeout)?

    <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig  =  ServerUrl =
    failover:(*nio*://s1:61616,*nio*://s2:61616)?randomize=*true*
    *StartupTimeout = 5000*
    </Resource>

    Failover is purely an ActiveMQ client option, so we need to try
    and work out where the blocking occurs. Even if both ActiveMQs are
    not running this should not halt TomEE startup indefinitely.

    The embedded ActiveMQ should not be a slave. If you want a local
    ActiveMQ as a slave and a remote as the master then use the
    activemq.xml configuration described here:
    http://tomee.apache.org/jms-resources-and-mdb-container.html

    Also, if 'randomize=false' is defined then *s1* should be the
    *master*, or try setting it to true (the default) to see if that
    improves the failover to the master. Failover defaults and details
    can be found here:
    http://activemq.apache.org/failover-transport-reference.html

    Andy.

    On 25/10/2014 15:15, Leonardo K. Shikida wrote:

        Hi Andy

        If I've understood Romain well, setting a time to wait won't
        solve the problem.

        ActiveMQ server-slave failover works like that: the first
        server becomes the master and serves, the slave server acquire
        a lock in the DB and waits for the master server to release
        the lock to take over. This may be forever if the master
        server never stops.

        The problem here is that TomEE assumes (or it seems to assume)
        that if the embedded JMS instance is not started, then it
        cannot start the container itself, and it simply hangs forever
        during the initialization. So, actually, the slave is somewhat
        started, because it's just waiting for a lock, but somehow, I
        think this is not what TomEE considers to be a "ready" state.

        I'll have to change the current architecture to start these
        master-slave JMS servers outside TomEE, although, I'd like to
        keep it simpler. :-(


        []

        Leo

        On Sat, Oct 25, 2014 at 6:45 AM, Andy Gumbrecht
        <[email protected] <mailto:[email protected]>
        <mailto:[email protected]
        <mailto:[email protected]>>> wrote:

            And I'd suggest replacing 'tcp' with 'nio' for better
        performance.

            Andy.


            On 24/10/2014 22:47, Romain Manni-Bucau wrote:

                I don't think so, we want to fail is broker doesn't
        start in
                general
                Romain Manni-Bucau
                Twitter: @rmannibucau
                Blog: http://rmannibucau.wordpress.com/
                LinkedIn: http://fr.linkedin.com/in/rmannibucau
                Github: https://github.com/rmannibucau



                2014-10-24 22:37 GMT+02:00 Leonardo K. Shikida
                <[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>>:

                    is there any property I can set to let tomee start
                    regardless its embedded
                    jms acquires the lock or not?

                    []

                    Leo

                    On Fri, Oct 24, 2014 at 6:04 PM, Romain Manni-Bucau
                    <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>
                    wrote:

                           It is not shocking if second broker is
        configured
                        as a slave.

                        Most of the time such config are done with an
        external
                        amq to keep tomee
                        stateless
                        Le 24 oct. 2014 21:37, "Leonardo K. Shikida"
                        <[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>> a écrit :

                            well, I am using
        BrokerXmlConfig=xbean:file... to
                            get the properties file

                            but then, here's the problem. While the first
                            tomee starts, the second

                        one

                            seems to wait for its embedded JMS to
        start. Since
                            it will be a slave
                            server, waiting for a lock, whole tomee
        also waits
                            for it to start...

                            so tomee does not start.

                            is that the expected behavior?



                            []

                            Leo

                            On Fri, Oct 24, 2014 at 3:39 PM, Leonardo K.
                            Shikida <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>

                            wrote:

                                Hi

                                I can run 2 tomee's using 2 external JMS
                                servers in the failover mode,
                                using a tomee.xml like this

                                      <Resource id="MyJmsResourceAdapter"

                        type="ActiveMQResourceAdapter">

                                          BrokerXmlConfig  =
                                          ServerUrl =
failover:(tcp://s1:61616,tcp://s2:61616)?randomize=false
                                      </Resource>


                                If I want to start two embedded JMS
        servers,
                                one in each tomee, in a
                                failover mode, what's the syntax? I've
        been
                                trying this

                                      <Resource id="MyJmsResourceAdapter"

                        type="ActiveMQResourceAdapter">

                                          BrokerXmlConfig =
                                broker:(tcp://s1:61616)?persistent=true
                                          ServerUrl =
failover:(tcp://s1:61616,tcp:/s2:61616)?randomize=false
                                          DataSource = MyJmsDataSource
                                      </Resource>

                                where MyJmsDataSource points to some JDBC
                                resource (must be the same

                        for

                                both). Of course, the other tomee
        declares its
                                broker in the
                                "BrokerXmlConfig"

                                But something is not right. I feel I am
                                missing something. Is this the
                                right syntax?

                                TIA

                                Leo



                --            Andy Gumbrecht
        https://twitter.com/AndyGeeDe
        http://www.tomitribe.com



-- Andy Gumbrecht
    https://twitter.com/AndyGeeDe
    http://www.tomitribe.com



--
  Andy Gumbrecht
  https://twitter.com/AndyGeeDe
  http://www.tomitribe.com

Reply via email to