camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject Re: Batch Transactions
Date Thu, 04 Mar 2010 14:23:28 GMT
Hi Norman,

This feature is not part of ActiveMq product but you can using java
language design something like that to process several messages in one
transaction :

public void sendTransacted() throws JMSException {
     //create a default connection - we'll assume a broker is running
    //with its default configuration
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory();
    Connection connection = cf.createConnection();
    connection.start();
    //create a transacted session
    Session session = connection.createSession(true,
Session.SESSION_TRANSACTED);
    Topic topic = session.createTopic("Test.Transactions");
    MessageProducer producer = session.createProducer(topic);
    int count =0;
    for (int i =0; i < 1000; i++) {
        Message message = session.createTextMessage("message " + i);
        producer.send(message);
        //commit every 10 messages
        if (i!=0 && i%10==0){
           session.commit();
        }
     }
 }

Thx for Rob Davies code

You can also combine activemq + camel + spring for that :
http://camel.apache.org/resequencer.html

Kind regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm



On Thu, Mar 4, 2010 at 2:45 PM, Norman Maurer <norman@apache.org> wrote:
> Hi all,
>
> is it somehow possible to batch transactions when using activemq
> component ? So for example use one transaction for 10 messages.
>
> Thx,
> Norman
>

Mime
View raw message