You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Maciej Andreas Bednarz <be...@web.de> on 2006/04/22 11:45:55 UTC
ActiveMQ 4: EmbeddedBroker & Postgres persistence only
Hi there,
I am evaluating ActiveMQ and try to embed it into my application. So far
everything goes well. But when I try to change the persistence from derby to
postgres this seems to have no effect. After startup postgres tables are
created, but when I send some durable messages they are persisted in derby
only. Could you please review my code?
-- main method to start the broker --
BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:61616");
broker.setDeleteAllMessagesOnStartup(false);
broker.setPersistent(true);
broker.setPersistenceAdapter(createPersistenceAdapter());
broker.start();
-- persistence adapter creator --
static PersistenceAdapter createPersistenceAdapter() throws Exception {
PGPoolingDataSource pgsDs = new PGPoolingDataSource();
pgsDs.setServerName("localhost");
pgsDs.setDatabaseName("activemq");
pgsDs.setPortNumber(0);
pgsDs.setUser("activemq");
pgsDs.setPassword("activemq");
pgsDs.setDataSourceName("postgres");
pgsDs.setInitialConnections(1);
pgsDs.setMaxConnections(10);
JDBCPersistenceAdapter psa = new JDBCPersistenceAdapter(pgsDs, new
DefaultWireFormat());
ActiveMQQueue queue = new ActiveMQQueue();
queue.createDestination("TOOL.DEFAULT");
psa.createQueueMessageStore(queue);
psa.start();
return psa;
}
-- Info output after starting my broker --
INFO - ActiveMQ 4.0-RC2 JMS Message Broker (localhost) is starting
INFO - For help or more information please see:
http://incubator.apache.org/activemq/
INFO - Database driver recognized: [apache_derby_embedded_jdbc_driver]
INFO - Journal Recovery Started from: Active Journal: using 2 x 20.0 Megs
at: ...
INFO - Journal Recovered: 1 message(s) in transactions recovered.
INFO - Database driver recognized: [postgresql_native_driver]
INFO - Listening for connections at: tcp://msgn2539i:61616
INFO - Connector tcp://msgn2539i:61616 Started
INFO - ActiveMQ JMS Message Broker (localhost) started
INFO - JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
As you can see [apache_derby_embedded_jdbc_driver] is still loaded and if I
send some durable messages, they are persisted in derby ond not in postgres.
Can someone give my an example of a working configuration for postgres as
only data store for persistent messages?
Thanks,
Maciej A. Bednarz
--
View this message in context: http://www.nabble.com/ActiveMQ-4%3A-EmbeddedBroker-Postgres-persistence-only-t1490715.html#a4039343
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4: EmbeddedBroker & Postgres persistence only
Posted by Maciej Andreas Bednarz <be...@web.de>.
Hi Hiram,
this was what I`ve been looking for. I noticed that the derby message
appeared after adding the connector but did not found an join within
sourcecode. So I have changed my code the proposed way and everything works
fine.
My best,
Maciej Andreas Bednarz
--
View this message in context: http://www.nabble.com/ActiveMQ-4%3A-EmbeddedBroker-Postgres-persistence-only-t1490715.html#a4068559
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4: EmbeddedBroker & Postgres persistence only
Posted by Hiram Chirino <hi...@hiramchirino.com>.
Try adding the connector after you configure the persistence.
On 4/22/06, Maciej Andreas Bednarz <be...@web.de> wrote:
>
> Hi there,
>
> I am evaluating ActiveMQ and try to embed it into my application. So far
> everything goes well. But when I try to change the persistence from derby to
> postgres this seems to have no effect. After startup postgres tables are
> created, but when I send some durable messages they are persisted in derby
> only. Could you please review my code?
>
> -- main method to start the broker --
>
> BrokerService broker = new BrokerService();
> broker.addConnector("tcp://localhost:61616");
> broker.setDeleteAllMessagesOnStartup(false);
> broker.setPersistent(true);
> broker.setPersistenceAdapter(createPersistenceAdapter());
> broker.start();
>
> -- persistence adapter creator --
>
> static PersistenceAdapter createPersistenceAdapter() throws Exception {
>
> PGPoolingDataSource pgsDs = new PGPoolingDataSource();
>
> pgsDs.setServerName("localhost");
> pgsDs.setDatabaseName("activemq");
> pgsDs.setPortNumber(0);
> pgsDs.setUser("activemq");
> pgsDs.setPassword("activemq");
> pgsDs.setDataSourceName("postgres");
> pgsDs.setInitialConnections(1);
> pgsDs.setMaxConnections(10);
>
> JDBCPersistenceAdapter psa = new JDBCPersistenceAdapter(pgsDs, new
> DefaultWireFormat());
>
> ActiveMQQueue queue = new ActiveMQQueue();
> queue.createDestination("TOOL.DEFAULT");
> psa.createQueueMessageStore(queue);
> psa.start();
>
> return psa;
> }
>
> -- Info output after starting my broker --
>
> INFO - ActiveMQ 4.0-RC2 JMS Message Broker (localhost) is starting
> INFO - For help or more information please see:
> http://incubator.apache.org/activemq/
> INFO - Database driver recognized: [apache_derby_embedded_jdbc_driver]
> INFO - Journal Recovery Started from: Active Journal: using 2 x 20.0 Megs
> at: ...
> INFO - Journal Recovered: 1 message(s) in transactions recovered.
> INFO - Database driver recognized: [postgresql_native_driver]
>
> INFO - Listening for connections at: tcp://msgn2539i:61616
> INFO - Connector tcp://msgn2539i:61616 Started
> INFO - ActiveMQ JMS Message Broker (localhost) started
> INFO - JMX consoles can connect to
> service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
>
> As you can see [apache_derby_embedded_jdbc_driver] is still loaded and if I
> send some durable messages, they are persisted in derby ond not in postgres.
>
> Can someone give my an example of a working configuration for postgres as
> only data store for persistent messages?
>
>
> Thanks,
>
> Maciej A. Bednarz
>
> --
> View this message in context: http://www.nabble.com/ActiveMQ-4%3A-EmbeddedBroker-Postgres-persistence-only-t1490715.html#a4039343
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
Regards,
Hiram