You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Norman Maurer <no...@apache.org> on 2010/03/04 14:45:52 UTC
Batch Transactions
Hi all,
is it somehow possible to batch transactions when using activemq
component ? So for example use one transaction for 10 messages.
Thx,
Norman
Re: Batch Transactions
Posted by Charles Moulliard <cm...@gmail.com>.
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 <no...@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
>