You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Davide Bolognini <da...@bravofly.com> on 2013/03/12 17:05:53 UTC

Activemq KahaDB

Hi all,

I would like to create a queue with ActiveMQ and exploit the persistence. At
the same time I wouldn't use Spring and its world. So I developed an
application like this:

tomee.xml
 <Resource id="IndexerQueueJmsResourceAdapter"
type="ActiveMQResourceAdapter">
    BrokerXmlConfig         = broker:(tcp://localhost:61616)?persistent=true
    ServerUrl               = vm://localhost
    MaximumRedeliveries     = 4
    DataSource				= IndexerQueueDataSource
  </Resource>

  <Resource id="IndexerQueueDataSource" type="DataSource">
    JdbcDriver com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
    JdbcUrl jdbc:mysql://localhost:3306/activemq
    UserName x
    Password x
    JtaManaged true
    PoolPreparedStatements true
  </Resource>

[....]

The persistence was so given by MySQL. This application worked very well,
and I didn't use the file activemq.xml. 

But now I would like to move the persistence from MySql to the file system.
So I would like to use KahaDB. The first step was to remove the DataSource
in the ActiveMQResourceAdapter. The application worked good, saving the
messages in the home directory /activemq-data/etc., but the problem is that
I have an exception starting TomEE

SEVERE: Failed to start ActiveMQ
java.lang.Exception: ActiveMQFactory.createBroker.InvocationTargetException
	at
org.apache.openejb.resource.activemq.ActiveMQFactory.createBroker(ActiveMQFactory.java:127)
	at
org.apache.openejb.resource.activemq.ActiveMQResourceAdapter.start(ActiveMQResourceAdapter.java:126)
	at
org.apache.openejb.assembler.classic.Assembler.createResource(Assembler.java:1784)
	at
org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:425)
	at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:344)
	at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
	at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
	at org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:233)
	at org.apache.tomee.catalina.TomcatLoader.init(TomcatLoader.java:130)
	at
org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:121)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
	at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
	at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at
org.apache.openejb.resource.activemq.ActiveMQFactory.createBroker(ActiveMQFactory.java:121)
	... 21 more
Caused by: java.lang.IllegalArgumentException: Unknown datasource Default
Unmanaged JDBC Database
	at
org.apache.openejb.resource.activemq.ActiveMQ5Factory.createBroker(ActiveMQ5Factory.java:88)
	... 26 more

Following some form posts, I added 

DataSource =

(so without explain the source) in the ActiveMQResourceAdapter and the
exception desappears. However now the messages are not saved.

So the question is: have you any idea to configure the KahaDB persistence
without using Spring?

Thanks a lot

Davide


 



--
View this message in context: http://openejb.979440.n4.nabble.com/Activemq-KahaDB-tp4661443.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Activemq KahaDB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
with <broker /> i think:

http://activemq.apache.org/kahadb.html

so i guess sthg like

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://activemq.org/config/1.0">

  <broker brokerName="receiver" persistent="true" useJmx="false">

    <persistenceAdapter>
      <kahaDB directory="activemq-data" journalMaxFileLength="32mb"/>
    </persistenceAdapter>

  </broker>
</beans>

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/13 Davide Bolognini <da...@bravofly.com>

> Hi Romain,
> Hi all,
>
> I have already put the persistence=true in the inline config, and with a
> mysql DB it works properly. I have a problem when I remove the DataSource
> in
> order to use KahaDB: in this case the exception occours.
>
> About activemq.xml: according to my tomee.xml presented in the post, can
> someone suggests me how to configure activemq.xml JUST to have KahaDB?
>
> Thanks a lot!
>
> Davide
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Activemq-KahaDB-tp4661443p4661487.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Activemq KahaDB

Posted by Davide Bolognini <da...@bravofly.com>.
Hi Romain,
Hi all,

I have already put the persistence=true in the inline config, and with a
mysql DB it works properly. I have a problem when I remove the DataSource in
order to use KahaDB: in this case the exception occours.

About activemq.xml: according to my tomee.xml presented in the post, can
someone suggests me how to configure activemq.xml JUST to have KahaDB?

Thanks a lot!

Davide



--
View this message in context: http://openejb.979440.n4.nabble.com/Activemq-KahaDB-tp4661443p4661487.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Activemq KahaDB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
you should be able to pass config inline (persistent=true or
broker.persistent=true can't remember which one is correct)

another potential solution (i never used this one) would be to use
activemq.xml with xbean: http://activemq.apache.org/broker-xbean-uri.html

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/12 Davide Bolognini <da...@bravofly.com>

> Hi all,
>
> I would like to create a queue with ActiveMQ and exploit the persistence.
> At
> the same time I wouldn't use Spring and its world. So I developed an
> application like this:
>
> tomee.xml
>  <Resource id="IndexerQueueJmsResourceAdapter"
> type="ActiveMQResourceAdapter">
>     BrokerXmlConfig         =
> broker:(tcp://localhost:61616)?persistent=true
>     ServerUrl               = vm://localhost
>     MaximumRedeliveries     = 4
>     DataSource                          = IndexerQueueDataSource
>   </Resource>
>
>   <Resource id="IndexerQueueDataSource" type="DataSource">
>     JdbcDriver com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
>     JdbcUrl jdbc:mysql://localhost:3306/activemq
>     UserName x
>     Password x
>     JtaManaged true
>     PoolPreparedStatements true
>   </Resource>
>
> [....]
>
> The persistence was so given by MySQL. This application worked very well,
> and I didn't use the file activemq.xml.
>
> But now I would like to move the persistence from MySql to the file system.
> So I would like to use KahaDB. The first step was to remove the DataSource
> in the ActiveMQResourceAdapter. The application worked good, saving the
> messages in the home directory /activemq-data/etc., but the problem is that
> I have an exception starting TomEE
>
> SEVERE: Failed to start ActiveMQ
> java.lang.Exception: ActiveMQFactory.createBroker.InvocationTargetException
>         at
>
> org.apache.openejb.resource.activemq.ActiveMQFactory.createBroker(ActiveMQFactory.java:127)
>         at
>
> org.apache.openejb.resource.activemq.ActiveMQResourceAdapter.start(ActiveMQResourceAdapter.java:126)
>         at
>
> org.apache.openejb.assembler.classic.Assembler.createResource(Assembler.java:1784)
>         at
>
> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:425)
>         at
> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:344)
>         at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
>         at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
>         at
> org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:233)
>         at
> org.apache.tomee.catalina.TomcatLoader.init(TomcatLoader.java:130)
>         at
>
> org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:121)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
>         at
> org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
>         at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
>         at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
> Caused by: java.lang.reflect.InvocationTargetException
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at
>
> org.apache.openejb.resource.activemq.ActiveMQFactory.createBroker(ActiveMQFactory.java:121)
>         ... 21 more
> Caused by: java.lang.IllegalArgumentException: Unknown datasource Default
> Unmanaged JDBC Database
>         at
>
> org.apache.openejb.resource.activemq.ActiveMQ5Factory.createBroker(ActiveMQ5Factory.java:88)
>         ... 26 more
>
> Following some form posts, I added
>
> DataSource =
>
> (so without explain the source) in the ActiveMQResourceAdapter and the
> exception desappears. However now the messages are not saved.
>
> So the question is: have you any idea to configure the KahaDB persistence
> without using Spring?
>
> Thanks a lot
>
> Davide
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Activemq-KahaDB-tp4661443.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>