You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Marc Boorshtein <mb...@gmail.com> on 2013/10/04 11:09:23 UTC

Confirm usage of embedded ActiveMQ?

All,

I'm looking to embed ActiveMQ 5.8 in my Java based server and I wanted to
confirm my thinking to make sure I was taking the right approach.

My desire is to have a VM accessible queue (not accessible via a network)
that is using a relational database (SQL Server 2012 in this instance).
 The server can have multiple instances, all pointed to the same DB for
persistence.  Each server will host a broker and will have a message
listener, all sharing the same queue.  When I push a message into the queue
on one server, I want it accessible by either server (whichever picks it up
first).

My plan is to initialize the broker in each server with a
JDBCPersistanceAdapter using the following code:

org.apache.commons.dbcp.BasicDataSource ds = new
org.apache.commons.dbcp.BasicDataSource();
ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
ds.setUrl("jdbc:sqlserver://dbhost:1433;databaseName=activemq");
ds.setUsername("user");
ds.setPassword("password");
ds.setMaxActive(10);
JDBCPersistenceAdapter jdbcpa = new JDBCPersistenceAdapter();
jdbcpa.setDirectory(new File("activemq"));
jdbcpa.setDataSource(ds);
 final BrokerService broker = new BrokerService();
broker.setBrokerName("testing");
broker.setPersistenceAdapter(jdbcpa);
new Thread() {
  @Override
  public void run() {
  try {
  broker.start();
  } catch (Exception e) {
      // TODO Auto-generated catch block
  e.printStackTrace();
  }
   }
}.start();

So I would have multiple embedded servers connecting to the same db and the
same queue.

Am I on the right track or totally off?

Thanks
Marc

Re: Confirm usage of embedded ActiveMQ?

Posted by Gary Tully <ga...@gmail.com>.
each broker requires exclusive access to the DB. So the broker is the
shared entry point.

In each of your servers have just client side jms, producers and
consumers and have a single or replicated broker topology that is
shared by all servers.

If you want some level of isolation for your servers (the ability to
produce messages for example when the shared broker is offline) then
use a local broker with local file storage
and have it networked to the shared broker.

On 4 October 2013 10:09, Marc Boorshtein <mb...@gmail.com> wrote:
> All,
>
> I'm looking to embed ActiveMQ 5.8 in my Java based server and I wanted to
> confirm my thinking to make sure I was taking the right approach.
>
> My desire is to have a VM accessible queue (not accessible via a network)
> that is using a relational database (SQL Server 2012 in this instance).
>  The server can have multiple instances, all pointed to the same DB for
> persistence.  Each server will host a broker and will have a message
> listener, all sharing the same queue.  When I push a message into the queue
> on one server, I want it accessible by either server (whichever picks it up
> first).
>
> My plan is to initialize the broker in each server with a
> JDBCPersistanceAdapter using the following code:
>
> org.apache.commons.dbcp.BasicDataSource ds = new
> org.apache.commons.dbcp.BasicDataSource();
> ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> ds.setUrl("jdbc:sqlserver://dbhost:1433;databaseName=activemq");
> ds.setUsername("user");
> ds.setPassword("password");
> ds.setMaxActive(10);
> JDBCPersistenceAdapter jdbcpa = new JDBCPersistenceAdapter();
> jdbcpa.setDirectory(new File("activemq"));
> jdbcpa.setDataSource(ds);
>  final BrokerService broker = new BrokerService();
> broker.setBrokerName("testing");
> broker.setPersistenceAdapter(jdbcpa);
> new Thread() {
>   @Override
>   public void run() {
>   try {
>   broker.start();
>   } catch (Exception e) {
>       // TODO Auto-generated catch block
>   e.printStackTrace();
>   }
>    }
> }.start();
>
> So I would have multiple embedded servers connecting to the same db and the
> same queue.
>
> Am I on the right track or totally off?
>
> Thanks
> Marc



-- 
http://redhat.com
http://blog.garytully.com