camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d1x <>
Subject SJMS transaction
Date Wed, 10 Feb 2016 10:18:15 GMT

is there a way how to ensure transactions between consumer-producer of two
JMS queues using SJMS component? 

What I'm testing is this simple case:
1. prepare higher amount of JMS messages in broker (e.g. 1000)
2. have Camel route from input queue to output queue
3. start context (starts consuming messages) and in any time kill java

What I would expect is that sum of messages in input queue and output queue
will be 1000. But what happens is that the sum is higher (something between
1000 and 1005 as I use 5 parallelConsumers). It is because when I kill
process in the time when JMS message was already submitted to JMS output
queue - it will remain there even if the transaction (acknowledge) of
message from input queue did not succeed (because of kill). 

I tried hard to find out how to configure Apache Camel properly. From what I
understood from documentation is that I cannot use Camel Transaction
Processor. But still there are options like acknowledgementMode (but their
options seem not documented at all, not even in source code).

So is there a way how to configure SJMS component to behave fully
transactionally between consumer-producer? Very likely they will use the
same JMS session or use other way of synchronization?

Here is the simple code I use for testing

public class SjmsTransaction {

    public static void main(String[] args) throws Exception {
        RouteBuilder rb = new RouteBuilder() {
            public void configure() throws Exception {
//                        .setExchangePattern(ExchangePattern.InOut)
                        .process(new Processor() {
                            public void process(Exchange exchange) throws
Exception {
                                System.out.println("Processed message " +

        CamelContext context = new DefaultCamelContext();

        System.out.println("=====> Starting context");
        // Now the context will run and consume messages, when I stop
application by force in any time
        // I expect this to be true: <#submittedMessages> ==
<#messagesInInput> + <#messagesInOutput>
        // What happens is that there more messages that was not
acknowledged (from input) but are already in output

    private static void addJmsComponent(CamelContext context) {
        ConnectionFactory factory = new
        ConnectionFactoryResource connResource = new
ConnectionFactoryResource(5, factory);
        SjmsComponent comp = new SjmsComponent();
        context.addComponent("sjms", comp);

Thank you very much for any answer

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message