Re: Splitter and combining messages / exchanges

2012-11-30 Thread Jason Chaffee
What about using the stream component instead of a splitter?  You could
then route to a bean and keep the first line in ThreadLocal or something
like that, and do the aggregation in the bean.  You could not doing any
asynchronous processing in this case do to using the ThreadLocal.

This might not be the optimal solution.  Claus might have some other
solutions using the EIPs, but I think this would work nonetheless.

Jason



On 11/30/12 3:13 PM, "Oliver Geisser"  wrote:

>Hi Jason,
>
>that was my first idea, too. But this does not work.
>Because I need the streaming mode (big file) I need to "release"
>every line from from the Aggregator immediately, e.g. the "completion
>predicate" will be true for all lines but the first.
>
>And when an aggregated Exchange is "completed" it is "gone"
>and with it I will also loose the header.
>
>Do you have another idea?
>
>Greetings
>Oliver
>
>
>
>2012/11/30 Jason Chaffee 
>
>> I believe could write a custom aggregator.  On the first call, you put
>>the
>> "Hello" into a header on the Exchange and return that Exchange.  On the
>> rest of the calls, you can read the header and aggregate it with the
>> current body.
>>
>>
>> On 11/30/12 2:33 PM, "Oliver Geisser"  wrote:
>>
>> >Hi Claus,
>> >
>> >thanks for your help. I've checked the Composed Message Processor EIP.
>> >
>> >Maybe I'm missing something but as far as I can see the EIP will not
>>work
>> >for my use case.
>> >
>> >Let's recap my problem with the input file
>> >
>> >Hello
>> >A
>> >B
>> >C
>> >...
>> >
>> >Because it's a very large file it will be splitted in streaming mode.
>> >Therfor
>> >every line becomes a separate Message.
>> >
>> >Using the Aggregator the "Hello" Message will be stored in the
>> >AggregationRepository.
>> >The the second message ("A") will be aggregated with "Hello" to "Hello
>>A".
>> >And now the important point: the "completion predicate" is now true and
>> >the
>> >meesage is released from the Aggregator, e.g.
>> >AggregateProcessor.onCompletion will
>> >be called and the "Hello" Exchange is removed from the
>> >AggregationRepository.
>> >
>> >The Exchange needs to be released (completed) at this point because it
>>is
>> >a
>> >big file and
>> >we need to operate in streaming mode.
>> >
>> >Now the third message ("B") comes in. Because the "Hello" Exchange was
>> >removed
>> >we can not aggregate the Exchanges to "Hello B" anymore.
>> >
>> >So the question remains: what is the best way to solve the given
>>problem
>> >(see below) with Camel?
>> >
>> >One idea I had was to mimic the Aggregate Repository but without
>>removing
>> >the "Hello" Exchange
>> >after combining it with the "A", "B", "C", etc. messages.
>> >
>> >But is this really the best solution for my problem?
>> >
>> >What I need is access to a storage location which is scoped to the
>> >"Splitter input Exchange"
>> >during processing the "splitted" Exchanges. For example: if it would be
>> >possible to access
>> >the "input" Exchange during processing the "splitted" Exchanges I would
>> >set
>> >a property
>> >on the "input" Exchange during processing the first line and reading it
>> >afterwards during
>> >processing the remaining lines.
>> >
>> >Is there any other storage location besides an Exchange property which
>>is
>> >scoped to the
>> >Exchange and is accessible from the "splitted" Exchanges?
>> >
>> >Greetings
>> >Oliver
>> >
>> >
>> >
>> >2012/11/30 Claus Ibsen 
>> >
>> >> Hi
>> >>
>> >> See this EIP
>> >> http://camel.apache.org/composed-message-processor.html
>> >>
>> >> On Thu, Nov 29, 2012 at 11:27 PM, Oliver Geisser
>> >>  wrote:
>> >> > Hello,
>> >> >
>> >> > I am using a splitter to handle a big txt file (streaming mode). I
>> >>need
>> >> to
>> >> > combine the first line
>> >> > with all the other lines and store each result into a database.
>> >> >
>> >> > What is a good Camel solution for this?
>> >> >
>> >> > Example input file:
>> >> >
>> >> > Hello
>> >> > A
>> >> > B
>> >> > C
>> >> > ...
>> >> >
>> >> >
>> >> > This needs to be combined into:
>> >> >
>> >> > Hello A
>> >> > Hello B
>> >> > Hello C
>> >> > ...
>> >> >
>> >> > Every result is stored into a database.
>> >> > It's important to use streaming because of the size of the input
>>file.
>> >> >
>> >> >
>> >> > My first idea was to use a Splitter and then store the first line
>> >>into an
>> >> > Exchange property.
>> >> > But this does not work because the Splitter creates new Exchanges
>>for
>> >> every
>> >> > line.
>> >> >
>> >> > So how do I combine the first line with all the other lines?
>> >> >
>> >> > Thanks
>> >> > Oliver
>> >> >
>> >> > --
>> >> > og
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -
>> >> Red Hat, Inc.
>> >> FuseSource is now part of Red Hat
>> >> Email: cib...@redhat.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus
>> >> Blog: http://davsclaus.com
>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>
>> >
>> >
>> >
>> >--
>> >og
>>
>>
>
>
>-- 
>og



Re: Splitter and combining messages / exchanges

2012-11-30 Thread Oliver Geisser
Hi Jason,

that was my first idea, too. But this does not work.
Because I need the streaming mode (big file) I need to "release"
every line from from the Aggregator immediately, e.g. the "completion
predicate" will be true for all lines but the first.

And when an aggregated Exchange is "completed" it is "gone"
and with it I will also loose the header.

Do you have another idea?

Greetings
Oliver



2012/11/30 Jason Chaffee 

> I believe could write a custom aggregator.  On the first call, you put the
> "Hello" into a header on the Exchange and return that Exchange.  On the
> rest of the calls, you can read the header and aggregate it with the
> current body.
>
>
> On 11/30/12 2:33 PM, "Oliver Geisser"  wrote:
>
> >Hi Claus,
> >
> >thanks for your help. I've checked the Composed Message Processor EIP.
> >
> >Maybe I'm missing something but as far as I can see the EIP will not work
> >for my use case.
> >
> >Let's recap my problem with the input file
> >
> >Hello
> >A
> >B
> >C
> >...
> >
> >Because it's a very large file it will be splitted in streaming mode.
> >Therfor
> >every line becomes a separate Message.
> >
> >Using the Aggregator the "Hello" Message will be stored in the
> >AggregationRepository.
> >The the second message ("A") will be aggregated with "Hello" to "Hello A".
> >And now the important point: the "completion predicate" is now true and
> >the
> >meesage is released from the Aggregator, e.g.
> >AggregateProcessor.onCompletion will
> >be called and the "Hello" Exchange is removed from the
> >AggregationRepository.
> >
> >The Exchange needs to be released (completed) at this point because it is
> >a
> >big file and
> >we need to operate in streaming mode.
> >
> >Now the third message ("B") comes in. Because the "Hello" Exchange was
> >removed
> >we can not aggregate the Exchanges to "Hello B" anymore.
> >
> >So the question remains: what is the best way to solve the given problem
> >(see below) with Camel?
> >
> >One idea I had was to mimic the Aggregate Repository but without removing
> >the "Hello" Exchange
> >after combining it with the "A", "B", "C", etc. messages.
> >
> >But is this really the best solution for my problem?
> >
> >What I need is access to a storage location which is scoped to the
> >"Splitter input Exchange"
> >during processing the "splitted" Exchanges. For example: if it would be
> >possible to access
> >the "input" Exchange during processing the "splitted" Exchanges I would
> >set
> >a property
> >on the "input" Exchange during processing the first line and reading it
> >afterwards during
> >processing the remaining lines.
> >
> >Is there any other storage location besides an Exchange property which is
> >scoped to the
> >Exchange and is accessible from the "splitted" Exchanges?
> >
> >Greetings
> >Oliver
> >
> >
> >
> >2012/11/30 Claus Ibsen 
> >
> >> Hi
> >>
> >> See this EIP
> >> http://camel.apache.org/composed-message-processor.html
> >>
> >> On Thu, Nov 29, 2012 at 11:27 PM, Oliver Geisser
> >>  wrote:
> >> > Hello,
> >> >
> >> > I am using a splitter to handle a big txt file (streaming mode). I
> >>need
> >> to
> >> > combine the first line
> >> > with all the other lines and store each result into a database.
> >> >
> >> > What is a good Camel solution for this?
> >> >
> >> > Example input file:
> >> >
> >> > Hello
> >> > A
> >> > B
> >> > C
> >> > ...
> >> >
> >> >
> >> > This needs to be combined into:
> >> >
> >> > Hello A
> >> > Hello B
> >> > Hello C
> >> > ...
> >> >
> >> > Every result is stored into a database.
> >> > It's important to use streaming because of the size of the input file.
> >> >
> >> >
> >> > My first idea was to use a Splitter and then store the first line
> >>into an
> >> > Exchange property.
> >> > But this does not work because the Splitter creates new Exchanges for
> >> every
> >> > line.
> >> >
> >> > So how do I combine the first line with all the other lines?
> >> >
> >> > Thanks
> >> > Oliver
> >> >
> >> > --
> >> > og
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -
> >> Red Hat, Inc.
> >> FuseSource is now part of Red Hat
> >> Email: cib...@redhat.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>
> >
> >
> >
> >--
> >og
>
>


-- 
og


Re: Splitter and combining messages / exchanges

2012-11-30 Thread Jason Chaffee
I believe could write a custom aggregator.  On the first call, you put the
"Hello" into a header on the Exchange and return that Exchange.  On the
rest of the calls, you can read the header and aggregate it with the
current body.


On 11/30/12 2:33 PM, "Oliver Geisser"  wrote:

>Hi Claus,
>
>thanks for your help. I've checked the Composed Message Processor EIP.
>
>Maybe I'm missing something but as far as I can see the EIP will not work
>for my use case.
>
>Let's recap my problem with the input file
>
>Hello
>A
>B
>C
>...
>
>Because it's a very large file it will be splitted in streaming mode.
>Therfor
>every line becomes a separate Message.
>
>Using the Aggregator the "Hello" Message will be stored in the
>AggregationRepository.
>The the second message ("A") will be aggregated with "Hello" to "Hello A".
>And now the important point: the "completion predicate" is now true and
>the
>meesage is released from the Aggregator, e.g.
>AggregateProcessor.onCompletion will
>be called and the "Hello" Exchange is removed from the
>AggregationRepository.
>
>The Exchange needs to be released (completed) at this point because it is
>a
>big file and
>we need to operate in streaming mode.
>
>Now the third message ("B") comes in. Because the "Hello" Exchange was
>removed
>we can not aggregate the Exchanges to "Hello B" anymore.
>
>So the question remains: what is the best way to solve the given problem
>(see below) with Camel?
>
>One idea I had was to mimic the Aggregate Repository but without removing
>the "Hello" Exchange
>after combining it with the "A", "B", "C", etc. messages.
>
>But is this really the best solution for my problem?
>
>What I need is access to a storage location which is scoped to the
>"Splitter input Exchange"
>during processing the "splitted" Exchanges. For example: if it would be
>possible to access
>the "input" Exchange during processing the "splitted" Exchanges I would
>set
>a property
>on the "input" Exchange during processing the first line and reading it
>afterwards during
>processing the remaining lines.
>
>Is there any other storage location besides an Exchange property which is
>scoped to the
>Exchange and is accessible from the "splitted" Exchanges?
>
>Greetings
>Oliver
>
>
>
>2012/11/30 Claus Ibsen 
>
>> Hi
>>
>> See this EIP
>> http://camel.apache.org/composed-message-processor.html
>>
>> On Thu, Nov 29, 2012 at 11:27 PM, Oliver Geisser
>>  wrote:
>> > Hello,
>> >
>> > I am using a splitter to handle a big txt file (streaming mode). I
>>need
>> to
>> > combine the first line
>> > with all the other lines and store each result into a database.
>> >
>> > What is a good Camel solution for this?
>> >
>> > Example input file:
>> >
>> > Hello
>> > A
>> > B
>> > C
>> > ...
>> >
>> >
>> > This needs to be combined into:
>> >
>> > Hello A
>> > Hello B
>> > Hello C
>> > ...
>> >
>> > Every result is stored into a database.
>> > It's important to use streaming because of the size of the input file.
>> >
>> >
>> > My first idea was to use a Splitter and then store the first line
>>into an
>> > Exchange property.
>> > But this does not work because the Splitter creates new Exchanges for
>> every
>> > line.
>> >
>> > So how do I combine the first line with all the other lines?
>> >
>> > Thanks
>> > Oliver
>> >
>> > --
>> > og
>>
>>
>>
>> --
>> Claus Ibsen
>> -
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>> Email: cib...@redhat.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>
>
>-- 
>og



Re: Splitter and combining messages / exchanges

2012-11-30 Thread Oliver Geisser
Hi Claus,

thanks for your help. I've checked the Composed Message Processor EIP.

Maybe I'm missing something but as far as I can see the EIP will not work
for my use case.

Let's recap my problem with the input file

Hello
A
B
C
...

Because it's a very large file it will be splitted in streaming mode.
Therfor
every line becomes a separate Message.

Using the Aggregator the "Hello" Message will be stored in the
AggregationRepository.
The the second message ("A") will be aggregated with "Hello" to "Hello A".
And now the important point: the "completion predicate" is now true and the
meesage is released from the Aggregator, e.g.
AggregateProcessor.onCompletion will
be called and the "Hello" Exchange is removed from the
AggregationRepository.

The Exchange needs to be released (completed) at this point because it is a
big file and
we need to operate in streaming mode.

Now the third message ("B") comes in. Because the "Hello" Exchange was
removed
we can not aggregate the Exchanges to "Hello B" anymore.

So the question remains: what is the best way to solve the given problem
(see below) with Camel?

One idea I had was to mimic the Aggregate Repository but without removing
the "Hello" Exchange
after combining it with the "A", "B", "C", etc. messages.

But is this really the best solution for my problem?

What I need is access to a storage location which is scoped to the
"Splitter input Exchange"
during processing the "splitted" Exchanges. For example: if it would be
possible to access
the "input" Exchange during processing the "splitted" Exchanges I would set
a property
on the "input" Exchange during processing the first line and reading it
afterwards during
processing the remaining lines.

Is there any other storage location besides an Exchange property which is
scoped to the
Exchange and is accessible from the "splitted" Exchanges?

Greetings
Oliver



2012/11/30 Claus Ibsen 

> Hi
>
> See this EIP
> http://camel.apache.org/composed-message-processor.html
>
> On Thu, Nov 29, 2012 at 11:27 PM, Oliver Geisser
>  wrote:
> > Hello,
> >
> > I am using a splitter to handle a big txt file (streaming mode). I need
> to
> > combine the first line
> > with all the other lines and store each result into a database.
> >
> > What is a good Camel solution for this?
> >
> > Example input file:
> >
> > Hello
> > A
> > B
> > C
> > ...
> >
> >
> > This needs to be combined into:
> >
> > Hello A
> > Hello B
> > Hello C
> > ...
> >
> > Every result is stored into a database.
> > It's important to use streaming because of the size of the input file.
> >
> >
> > My first idea was to use a Splitter and then store the first line into an
> > Exchange property.
> > But this does not work because the Splitter creates new Exchanges for
> every
> > line.
> >
> > So how do I combine the first line with all the other lines?
> >
> > Thanks
> > Oliver
> >
> > --
> > og
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cib...@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
og


Test Intercept with adviceWith and http

2012-11-30 Thread lleclerc
Hi,

This time I tried using http instead of http4.
No exception, but the intercept is not working, even with isUseAdviceWith()
to return true.

What is going on ?

using camel 2.10.2, and http 4.2.2.

Thank you in advance,

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.AdviceWithRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

/**
 * Created with IntelliJ IDEA.
 * User: lleclerc
 * Date: 12-11-28
 * Time: 16:34
 * To change this template use File | Settings | File Templates.
 */
public class IsUseAdviceWithJUnit4Test extends CamelTestSupport {

private String providerEndPointURI = "http://stackoverflow.com";;
private String timerEndPointURI = "timer://myTimer";
private String mockEndPointURI = "mock:myMock";
private String directEndPointURI = "direct:myDirect";

@Override
protected RouteBuilder createRouteBuilder() throws Exception {

return new RouteBuilder() {
@Override
public void configure() throws Exception {

from(timerEndPointURI +
"?fixedRate=true&delay=1000&period=1000")
.to(providerEndPointURI +
"?throwExceptionOnFailure=false")
.to(mockEndPointURI);
}
};
}

@Test
public void testIsUseAdviceWith() throws Exception {

context.getRouteDefinitions().get(0).adviceWith(context, new
AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {

replaceFromWith(directEndPointURI);

mockEndpoints();

interceptSendToEndpoint(providerEndPointURI)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
System.out.println("INTERCEPTED");
}
})
.skipSendToOriginalEndpoint();
}
});

// we must manually start when we are done with all the advice with
context.start();

getMockEndpoint(mockEndPointURI).expectedMessageCount(1);

template.sendBody(directEndPointURI, "a trigger");

assertMockEndpointsSatisfied();

assertNotNull(context.hasEndpoint(directEndPointURI));
assertNotNull(context.hasEndpoint("mock:" + directEndPointURI));

assertNotNull(context.hasEndpoint(mockEndPointURI));
}

@Override
public boolean isUseAdviceWith() {
return true;
}

@Override
public boolean isUseRouteBuilder() {
return true;
}
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Test-Intercept-with-adviceWith-and-http-tp5723473.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel standlaone application deployment in clustered enviornment

2012-11-30 Thread Charles Moulliard
As camelContexts are independents from each other, you can deploy your
application in different JVM and on different servers, there will never be
in conflict. Nevertheless take care if your endpoints consume the same
resources (files, ...) as they will be in competition in this case.


On Fri, Nov 30, 2012 at 7:05 PM, maheshadepu  wrote:

> Any deployment suggestions?
>
> Do I have to change anything? Is it possible to load only one camel context
> on multiple nodes?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-standlaone-application-deployment-in-clustered-enviornment-tp5723378p5723470.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com


Re: Dead letter queue when header not matched?

2012-11-30 Thread tolk
Scott,

Cheers that makes perfect sense, however I wanted to test was the actual
errorHandler part from first post. I'll use the otherwise to handle
incorrect headers but I want to maintain the errorHandler for unforeseen
problems. I was wondering if there is a way to force a message to hit the
error handler without bypassing my default config (i.e. without writing
directly to the DLQ) just to check I have the error handler setup correctly
in the routeBuilder.

Cheers,

James.




--
View this message in context: 
http://camel.465427.n5.nabble.com/Dead-letter-queue-when-header-not-matched-tp5723462p5723468.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dead letter queue when header not matched?

2012-11-30 Thread Scott England-Sullivan
You can have a mock route that is a consumer of the DLQ just as you would
have a mock route for the happy path.  Here is a short example:

from("seda:start")
  .choice()
.when(header("type").isEqualTo("A"));
  .to("direct:end")
.otherwise()
  .to("direct:my.DLQ")
.routeId("myRoute");

from("direct:end")
  .to("mock:end.result");

from("direct:my.DLQ")
  .to("mock:my.DLQ.result");


Then write your happy path test for the mock:end.result endpoint and your
unhappy path test for the mock:my.DLQ.result.

Make sense?

On Fri, Nov 30, 2012 at 11:17 AM, tolk  wrote:

> Cheers, that's very helpful. I have another related question;
>
> I want to unit test my actual dead letter queue, whats the easiest way to
> mock a broken communication to demonstrate this?
>
> Thanks again.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Dead-letter-queue-when-header-not-matched-tp5723462p5723466.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
-- 
Scott England-Sullivan
Apache Camel Committer
Principal Consultant / Sr. Architect | Red Hat, Inc.
FuseSource is now part of Red Hat
Web: fusesource.com  |
redhat.com
Blog: sully6768.blogspot.com
Twitter: sully6768


Re: Dead letter queue when header not matched?

2012-11-30 Thread tolk
Cheers, that's very helpful. I have another related question;

I want to unit test my actual dead letter queue, whats the easiest way to
mock a broken communication to demonstrate this?

Thanks again.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Dead-letter-queue-when-header-not-matched-tp5723462p5723466.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Singleton Endpoint Question

2012-11-30 Thread gilboy
Hi

If an endpoint is defined to be a singleton and you have 2 camel routes both
referencing the same endpoint URI, will camel call endpoint.createConsumer()
once or twice?

Thanks
Joe



--
View this message in context: 
http://camel.465427.n5.nabble.com/Singleton-Endpoint-Question-tp5723464.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Dead letter queue when header not matched?

2012-11-30 Thread tolk
For the following:

errorHandler(deadLetterChannel("mock:dead").maximumRedeliveries(1).redeliveryDelay(100));

from("seda:start")
.choice()
.when(header("type").isEqualTo("A"))
.to("direct:end")
.routeId("myRoute");

How would I configure the route to send the message to the deadLetterChannel
if the header "type" does not equal "A"?

Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/Dead-letter-queue-when-header-not-matched-tp5723462.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Speed up marshalling objects to XML by explicitly loading classes

2012-11-30 Thread Henryk Konsek
> Is there a way to speed up first request and explicitly load all generated
> classes when I deploy my bundle?

If loading these 1000 classes by classloader is the issue, then you
can use Reflections [1] and eager loaded Spring bean to load all these
classed when bundle context starts up.


  


Regards.

[1] http://code.google.com/p/reflections

--
Henryk Konsek
http://henryk-konsek.blogspot.com


Re: Problems unmarshalling with Java serialization (ClassNotFoundException)

2012-11-30 Thread Matthieu Vincent
Hi, I've already sent another mail to mailing lists without any response :)

Here is what i was saying :

I'm trying to unmarshal with serialization method a bean that is not the
current bundle but in a commons components bundle (with only pojo within).

I get the following error when camel tries to unmarshal my bean :

22:43:11,865 | ERROR | nModule-thread-1 | DefaultErrorHandler | 89 -
org.apache.camel.camel-core - 2.8.0.fuse-06-11 | Failed delivery for
exchangeId: ID-ITEM-64684-49962-1354223882336-2-1. Exhausted after delivery
attempt: 1 caught: java.lang.ClassNotFoundException:
commons.InformationInput java.lang.ClassNotFoundException:
commons.InformationInput at
java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_33] at
java.security.AccessController.doPrivileged(Native Method)[:1.6.0_33] at
java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_33] at
java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_33]
http://stackoverflow.com/questions/6749334/osgi-bundle-access-spring-context-file-from-another-bundleat
java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_33] at
org.apache.felix.framework.ModuleImpl.doImplicitBootDelegation(ModuleImpl.java:1610)
at
org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1547)

My bundle containing the bean is correctly started and i've defined the *
commons* package in the *Export-Package* of the commons bundle definition.
I've also already add the package in the Import-Package part of the bundle
trying to do the unmarshalling

Does anyone managed to such thing ?

Thx !


2012/11/30 Henryk Konsek 

> >   reading this title, i think i may have a similar problem.
> > Do you have any solution ?? :) :)
>
> Hi,
>
> You're referring to the post older than year and which have been
> removed from the Nabble archive. :)
>
> Please describe your problem so we could help you :) .
>
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com
>


Re: Camel multicast configuration file

2012-11-30 Thread Henryk Konsek
Hi Bala,

> I am trying to configure camel multicasting in my project. The requirement
> is to hit multiple services in parallel and consume the response.

As Claus suggested you forgot to aggregate the requests.

And here's how can you aggregate responses from multiple services:

from("direct:serviceAggregator")
  .multicast(new GroupedExchangeAggregationStrategy()).parallelProcessing()
.enrich("http://servicea.com";).enrich("http://serviceb.com";)
  .end();

Laters.

--
Henryk Konsek
http://henryk-konsek.blogspot.com


Re: Problems unmarshalling with Java serialization (ClassNotFoundException)

2012-11-30 Thread Henryk Konsek
>   reading this title, i think i may have a similar problem.
> Do you have any solution ?? :) :)

Hi,

You're referring to the post older than year and which have been
removed from the Nabble archive. :)

Please describe your problem so we could help you :) .

--
Henryk Konsek
http://henryk-konsek.blogspot.com


Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

2012-11-30 Thread Leandro Franchi
Ainda,

Do you have the correct permissions on the server?


Best Regards
Leandro Franchi


On Fri, Nov 30, 2012 at 11:50 AM, Aida  wrote:

> Hi,
>
> I have been having trouble trying to upload files using a sftp endpoint.
>
> The way I'm working to upload a file is using a ProducerTemplate (
> ProducerTemplate.send(endPointDefinition, data2write) where data2write is
> the Exchange with the data I want to upload ). This way works for me
> working
> with FTP servers and "ftp://***"; endpoints, but when trying to use a
> server
> that needs SFTP, the connection is made successfully, but there is a
> failure/exception when tries to access to the directory where the file
> should be uploaded.
>
> I have seen that the reason of this behaviour is that the name of the
> folder
> I want to use haven´t got the first character, so if the folder was
> "myFolder", it tries to  change the directory to "yFolder". The message I
> can retrieve from the received Exchange is "Cannot change directory to:
> yFolder". However, the endpoint is wellformed. I'm sure of this because I
> see it in the log trace (set at INFO level), example:
>
> 2012-11-30 12:33:35,414 INFO
> [org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
> (processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
> Connected and logged in to:
> Endpoint[sftp://myftph...@xxx.xx.xxx.xx
> :22/myFolder?charset=ISO-8859-1&delay=2000&disconnect=true&fileName=myFileName.xml&initialDelay=0&password=**&separator=Auto]
> 2012-11-30 12:33:35,537 WARNING
> [org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
> (processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
> Writing
> file failed with: Cannot change directory to: yFolder
>
> I don´t know if it could be a kind of "escape characters issue", but I put
> here the results of some tests:
>
> 1. Endpoint: sftp://myftph...@xxx.xx.xxx.xx:22/myFolder?charset= ...
>Result message: Cannot change directory to: yFolder
>
> 2. Endpoint:  sftp://myftph...@xxx.xx.xxx.xx:22/mmyFolder?charset= ...
>Result message: Cannot change directory to: myFolder   -> here the dir
> name is OK but it still fails (and strictly the endpoint it´s not correct)
>
> 3. Endpoint:  sftp://myftph...@xxx.xx.xxx.xx:22//myFolder?charset= ...
> Result message: Cannot change directory to: yFolder
>
>
> I have tried with two different separators (Auto and UNIX) when building
> the
> endpoint, but the result is the same.
>
> Looking into the FTP2 component documentation, I have found a way to make
> it
> work. This is using the stepwise option set to false. This way works, but
> what worries me is that (for security issues) not all the FTP servers allow
> this option.
>
> Additional Info:
> Apache Camel version: 2.9.4
> Camel processes running on Windows machine
> FTP where files are uploaded running on Linux machine, using SFTP
>
> Maybe I'm missing something. Any help would be appreciated.
>
> Thanks in advance.
>
>   Aida.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Leandro Franchi*
http://www.frango10.com


[FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

2012-11-30 Thread Aida
Hi,

I have been having trouble trying to upload files using a sftp endpoint.

The way I'm working to upload a file is using a ProducerTemplate ( 
ProducerTemplate.send(endPointDefinition, data2write) where data2write is
the Exchange with the data I want to upload ). This way works for me working
with FTP servers and "ftp://***"; endpoints, but when trying to use a server
that needs SFTP, the connection is made successfully, but there is a
failure/exception when tries to access to the directory where the file
should be uploaded.

I have seen that the reason of this behaviour is that the name of the folder
I want to use haven´t got the first character, so if the folder was
"myFolder", it tries to  change the directory to "yFolder". The message I
can retrieve from the received Exchange is "Cannot change directory to:
yFolder". However, the endpoint is wellformed. I'm sure of this because I
see it in the log trace (set at INFO level), example:

2012-11-30 12:33:35,414 INFO 
[org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
(processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
Connected and logged in to:
Endpoint[sftp://myftph...@xxx.xx.xxx.xx:22/myFolder?charset=ISO-8859-1&delay=2000&disconnect=true&fileName=myFileName.xml&initialDelay=0&password=**&separator=Auto]
2012-11-30 12:33:35,537 WARNING
[org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
(processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN]) Writing
file failed with: Cannot change directory to: yFolder

I don´t know if it could be a kind of "escape characters issue", but I put
here the results of some tests:

1. Endpoint: sftp://myftph...@xxx.xx.xxx.xx:22/myFolder?charset= ...
   Result message: Cannot change directory to: yFolder
   
2. Endpoint:  sftp://myftph...@xxx.xx.xxx.xx:22/mmyFolder?charset= ...
   Result message: Cannot change directory to: myFolder   -> here the dir
name is OK but it still fails (and strictly the endpoint it´s not correct)
   
3. Endpoint:  sftp://myftph...@xxx.xx.xxx.xx:22//myFolder?charset= ...
Result message: Cannot change directory to: yFolder


I have tried with two different separators (Auto and UNIX) when building the
endpoint, but the result is the same.   

Looking into the FTP2 component documentation, I have found a way to make it
work. This is using the stepwise option set to false. This way works, but
what worries me is that (for security issues) not all the FTP servers allow
this option.

Additional Info:
Apache Camel version: 2.9.4
Camel processes running on Windows machine
FTP where files are uploaded running on Linux machine, using SFTP

Maybe I'm missing something. Any help would be appreciated.

Thanks in advance.

  Aida.




--
View this message in context: 
http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Failover with Camel CXF

2012-11-30 Thread mabahma
Hello,

I have many routes with many components like Activemq and CXF.

I'm using the failover protocol to loadbalance Activemq brokers and CXF
webServices. 

*The sysntax : failover:(tcp://server1:61616,tcp://server2:61616)*  is
working and messages 

routed to one broker when the other is down.

 but the one with CXF is not working
*
failover:(cxf:bean:service1,cxf:bean:service2)* gives the exception 

service1 on service2 are 2 CXF endpoint beans defined in Camel context:

*http://localhost:8080/sw/service1"/>*

*Failed to resolve endpoint:
failover://(cxf:bean:service1,cxf:bean:service2) due to: No component found
with scheme: failover*

Have you any idea ?

Many thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/Failover-with-Camel-CXF-tp5723454.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jackson custom configuration

2012-11-30 Thread Martin Stiborský
Thanks, I'll keep my eye on it. I'll check source codes too, to get idea
how it works.


On Fri, Nov 30, 2012 at 1:21 PM, Claus Ibsen  wrote:

> Hi
>
> I have logged a ticket about this
> https://issues.apache.org/jira/browse/CAMEL-5836
>
> On Tue, Nov 27, 2012 at 10:30 AM, Martin Stiborský
>  wrote:
> > Hello guys,
> > how it's possible configure in general Jackson in Camel?
> > For example, I need to use indentation/DefaultPrettyPrinter for all
> > marshalled POJO classes by default.
> >
> > I found this thread:
> >
> http://mail-archives.apache.org/mod_mbox/camel-users/201112.mbox/%3ccapipqn6+vdftwavka7odowxb_nnheutreys8bj4op5jyeab...@mail.gmail.com%3E
> > It gives me a way, but still, I don't have working example for my case.
> >
> > Do you have any hints, please?
> >
> > --
> > S pozdravem / Best regards
> > Martin Stiborský
> >
> > Jabber: st...@njs.netlab.cz
> > Twitter: http://www.twitter.com/stibi
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cib...@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
S pozdravem / Best regards
Martin Stiborský

Jabber: st...@njs.netlab.cz
Twitter: http://www.twitter.com/stibi


Re: JMX attribute - Number of failures handled

2012-11-30 Thread gilboy
Thanks

If my route has an error handler with a retry attempt policy of 5 and a
recoverable error is thrown in the route and on the 2nd attempt it is
successful should the number of failures handled be incremented in this
instance?

Furthermore, if in the same route an error occurs and after the retry
attempts of 5 has been exhausted while still throwing the error - should the
number of failures be incremented in this instance?

Joe



--
View this message in context: 
http://camel.465427.n5.nabble.com/JMX-attribute-Number-of-failures-handled-tp5723159p5723452.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Speed up marshalling objects to XML by explicitly loading classes

2012-11-30 Thread Claus Ibsen
Hi

No there is not.

Maybe if you specify a JAXB data format, and with the contextPath,
then JAXB may load these on startup. Not sure though.



On Tue, Nov 27, 2012 at 12:07 PM, Ben V  wrote:
> I have lots of xsd and create java classes from them (~1000 classes) using
> xjc and deployed them to Servicemix4 as an OSGI bundle.
> Then I have application where I process the request and set exchange body to
> some object from generated classes.
> The problem is when it processes the first request - it takes around ~10
> seconds (JAXB to marshal object and set Exchange Body to XML??).
> Other requests runs without any time loss...
>
> Is there a way to speed up first request and explicitly load all generated
> classes when I deploy my bundle?
>
> ---
> camelContext:
>  xmlns="http://camel.apache.org/schema/blueprint";>
> 
> 
> 
> 
> http://example.com/some_routing"; />
> 
> 
> 
> ---
> requestProcessor:
> import my.package.Subscription;
> ...
> public void process(Exchange exchange) throws Exception {
> 
> Subscription subr = new Subscription();
> subr.setNumber("123");
> exchange.getOut().setBody(subr, Subscription.class);
> log.debug("process DONE");
> .
> }
> ---
> First request:
> 2012-11-27 12:33:09,797 | DEBUG  | qtp24871952-549  | RequestProcessor
> | 176 - my_bundle - 1.0.0.SNAPSHOT | process DONE
> 2012-11-27 12:33:18,045 | DEBUG  | qtp24871952-549  | RQUEST
> | 91 - org.apache.camel.camel-core - 2.8.5 | Exchange[
> , ExchangePattern:InOut
> , BodyType:my.package.Subscription
> , Body:
> http://omnitel.lt/cdm";>
> 123
> 
> ]
> ---
> Other requests:
> 2012-11-27 12:36:48,053 | DEBUG  | qtp24871952-549  | RequestProcessor
> | 176 - my_bundle - 1.0.0.SNAPSHOT | process DONE
> 2012-11-27 12:36:48,055 | DEBUG  | qtp24871952-549  | RQUEST
> | 91 - org.apache.camel.camel-core - 2.8.5 | Exchange[
> , ExchangePattern:InOut
> , BodyType:my.package.Subscription
> , Body:
> http://omnitel.lt/cdm";>
> 123
> 
> ]
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Speed-up-marshalling-objects-to-XML-by-explicitly-loading-classes-tp5723299.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Jackson custom configuration

2012-11-30 Thread Claus Ibsen
Hi

I have logged a ticket about this
https://issues.apache.org/jira/browse/CAMEL-5836

On Tue, Nov 27, 2012 at 10:30 AM, Martin Stiborský
 wrote:
> Hello guys,
> how it's possible configure in general Jackson in Camel?
> For example, I need to use indentation/DefaultPrettyPrinter for all
> marshalled POJO classes by default.
>
> I found this thread:
> http://mail-archives.apache.org/mod_mbox/camel-users/201112.mbox/%3ccapipqn6+vdftwavka7odowxb_nnheutreys8bj4op5jyeab...@mail.gmail.com%3E
> It gives me a way, but still, I don't have working example for my case.
>
> Do you have any hints, please?
>
> --
> S pozdravem / Best regards
> Martin Stiborský
>
> Jabber: st...@njs.netlab.cz
> Twitter: http://www.twitter.com/stibi



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Spring Transaction Propagating?

2012-11-30 Thread tolk
Not sure I follow (I'm newish to Camel and Spring TX). So basically it can't
be done, so I'll be better off setting up functionality so that I can start
my transaction at the consumer method rather than the producer to avoid
changing thread during the transaction?

Cheers for the help.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723449.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Spring Transaction Propagating?

2012-11-30 Thread Claus Ibsen
On Fri, Nov 30, 2012 at 12:41 PM, tolk  wrote:
> I noticed Camel has some functionality relating to transactional behaviour.
> Is this just internal transactional behaviour then i.e. only over the camel
> communication itself?
>

No it integrates with Spring TX. And ensures the route is run under
the orchestration of the Spring TX manager.
eg deep down there is some code that runs inside a Spring
doInTransaction() method.



> Thanks.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723447.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Spring Transaction Propagating?

2012-11-30 Thread tolk
I noticed Camel has some functionality relating to transactional behaviour.
Is this just internal transactional behaviour then i.e. only over the camel
communication itself?

Thanks.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723447.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: aggregator issue

2012-11-30 Thread Claus Ibsen
On Thu, Nov 29, 2012 at 12:09 PM, Jason Chaffee  wrote:
> I have a custom aggregator strategy but for some reason the oldExchange is 
> always  null.  Any ideas?
>
>
> Here is my route.
>
> from("seda:Split")
>   .routeId("Split")
>   .aggregate(new MyAggregationStrategy())
> .constant(true)
> .completionFromBatchConsumer()
> .completionPredicate(header("CamelBatchComplete").isEqualTo(true))
>   .to("file://./target/?fileName=aggregated.xml")
>

You should prefer to use direct endpoint, instead of seda.
Also you got 2 completions, can you try with either one.



>
> Here is my AggregationStrategy:
>
> @Override
> public Exchange aggregate(final Exchange oldExchange, final Exchange 
> newExchange) {
> MyObjects c = new MyObjects();
>
> if (oldExchange != null) {
> C = oldExchange.getIn().getBody(MyObjects.class);
> }
>
> final Message newIn = newExchange.getIn();
> final MyObject myObject= newExchange.getIn().getBody(MyObject.class);
>
> c.addMyObject(myObject);
> newIn.setBody(c);
>
> return newExchange;
> }



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: issue with jsonFormatting and timestamps

2012-11-30 Thread Claus Ibsen
I logged a new ticket just in case we didnt have that ticket I think we have
https://issues.apache.org/jira/browse/CAMEL-5836

On Fri, Nov 30, 2012 at 12:25 PM, Claus Ibsen  wrote:
> Hi
>
> Yeah I think we may have a JIRA ticket to improve the json data format
> to allow to configure it.
>
> Frankly we should maybe let json default be jackson. And add ways to
> configure it, so you can set custom serializers etc.
>
>
>
> On Thu, Nov 29, 2012 at 11:12 PM, Marco Mistroni  wrote:
>> Hello all
>>i have a serverside camelapp in which i am exposing an http channel
>> which returns json data.
>> the problem i have is that one of the object i serialize contains a
>> timestamp, and this is how the object is beign serialized
>>
>> [{"title":"[video] Tablet Boom: A Derivative
>> Play?","description":"","newsItemId":{"ticker":"MCD","publishedDate":135396900}}
>>
>> i had a look at JsonDataFormat but i cannot plug any serializer in there
>>
>> as i am using Jackson, are there any system properties i can set to
>> serlialize the timestamp perhaps into a readable string?
>>
>> thanks in advance and sorry for bothering
>>
>> regards
>>  marco
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cib...@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: issue with jsonFormatting and timestamps

2012-11-30 Thread Claus Ibsen
Hi

Yeah I think we may have a JIRA ticket to improve the json data format
to allow to configure it.

Frankly we should maybe let json default be jackson. And add ways to
configure it, so you can set custom serializers etc.



On Thu, Nov 29, 2012 at 11:12 PM, Marco Mistroni  wrote:
> Hello all
>i have a serverside camelapp in which i am exposing an http channel
> which returns json data.
> the problem i have is that one of the object i serialize contains a
> timestamp, and this is how the object is beign serialized
>
> [{"title":"[video] Tablet Boom: A Derivative
> Play?","description":"","newsItemId":{"ticker":"MCD","publishedDate":135396900}}
>
> i had a look at JsonDataFormat but i cannot plug any serializer in there
>
> as i am using Jackson, are there any system properties i can set to
> serlialize the timestamp perhaps into a readable string?
>
> thanks in advance and sorry for bothering
>
> regards
>  marco



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Spring Transaction Propagating?

2012-11-30 Thread Claus Ibsen
Hi

No you can't propagate spring TX accross different threads.


On Fri, Nov 30, 2012 at 12:01 PM, tolk  wrote:
> I have a situation similar to the simplified example below. Basically, I'm
> trying to use camel on an internal service to send an async message to
> itself via the SEDA component - a little odd perhaps but I don't have any
> choice in this:
>
> public class MyServiceImpl
> {
> ProducerTemplate producerTemplate;
>
> ...
>
> @Transactional(propagation = Propagation.REQUIRED)
> public void startingMethod(...)
> {
> ...
> producerTemplate.sendMessage("seda:start"...);
> }
>
> public void endingMethod(...)
> {
> ...
> }
> }
>
> public class MyRouteBuilder extends RouteBuilder
> {
> public void configure()
> {
> 
> from("seda:start").to("bean:myServiceImplBean?method=endingMethod");
> }
> }
>
> My questions are; what will happen to the spring transaction delimitated by
> the annotation, will it be lost? If so is there a way to propagate this
> transaction using camel?
>
> Thanks!
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Spring Transaction Propagating?

2012-11-30 Thread tolk
I have a situation similar to the simplified example below. Basically, I'm
trying to use camel on an internal service to send an async message to
itself via the SEDA component - a little odd perhaps but I don't have any
choice in this:

public class MyServiceImpl
{
ProducerTemplate producerTemplate;

...

@Transactional(propagation = Propagation.REQUIRED)
public void startingMethod(...)
{
...
producerTemplate.sendMessage("seda:start"...);
}

public void endingMethod(...)
{
...
}
}

public class MyRouteBuilder extends RouteBuilder
{
public void configure()
{

from("seda:start").to("bean:myServiceImplBean?method=endingMethod");
}
}

My questions are; what will happen to the spring transaction delimitated by
the annotation, will it be lost? If so is there a way to propagate this
transaction using camel?

Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Transactions, Error, Stop route

2012-11-30 Thread Praan
Dear All,

I would like to discuss/have some advice on the following:
Functional requirement:
In case an error occurs in our route while while processing a message from
ActiveMQ queue.
We want the message to return back to the queue and the route to stop
working. 

Technically we think we need a combination of Transaction, onException
handeling and a way to stop the route from further processing/running.

This results in the following code:

Camel transaction/activemq related configuration:



















//stop the route in the onException
onException(IOException.class)
.process(new Processor() {
Thread stopRouteInAnotherThread;

@Override
public void process(final Exchange exchange) throws
Exception {
// stopRouteInAnotherThread this route using a
thread that will stopRouteInAnotherThread
// this route gracefully while we are still running
if (stopRouteInAnotherThread == null) {
stopRouteInAnotherThread = new Thread() {
@Override
public void run() {
try {
   
exchange.getContext().stopRoute("poc-transaction");
} catch (Exception e) {
// ignore
}
}
};
}

// start the thread that stops this route
stopRouteInAnotherThread.start();
}
})
.maximumRedeliveries(0)
.handled(true);
Simple Route:
from("jms:queue:myQueueStart")
.routeId("poc-transaction")
.transacted(TX_POLICY_SPRING_BEAN)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception
{
throw new IOException("test");
}
}).to("jms:queue:myQueueEnd");

The route is stopped though we expected the message not to be dequeue'd but
it is dequeue'd. 

Does anyone know how to achieve this?

Cheers,
Praan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Transactions-Error-Stop-route-tp5723438.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: aggregator issue

2012-11-30 Thread Henryk Konsek
> I want to merge the message bodies into a container object.

I would use GroupedExchangeAggregationStrategy and then forward the
results of the aggregation to the processor.

from("direct:aggregateMe").
  aggregate(constant(true),new GroupedExchangeAggregationStrategy()).
  completionSize(2).
  .setBody(property(Exchange.GROUPED_EXCHANGE)).
  process(new MyMergeProcessor()).
  to("mock:merged");

Keep in mind that this approach separates aggregation logic from
message normalization.

Have a nice day :) .

--
Henryk Konsek
http://henryk-konsek.blogspot.com