Exception thrown when reading a mail with an attached file, which name contains a semicolon

2015-08-24 Thread Thierry Frossard
Hi,

I'm using Camel 2.15.2 with JDK 1.7 under Windows 7 and Eclipse 4.2.2 as
development tool.

My route reads from an IMAP server (IBM Lotus Notes). I have one big problem
: when the route handles an email, which contains an attached file with a
semicolon in his name, then the route always throws this exception :

Failed to extract body due to: Unable to load BODYSTRUCTURE.

4.08.15 15:10:11:313 CEST] 0172 SystemOut O [15:10:11.313] WARN 
[Camel (Mail vers Indexation) thread #0 - imap://gmain2p01.groupemutuel.ch]
org.apache.camel.util.CamelLogger.log:224 : Caused by:
[org.apache.camel.RuntimeCamelException - Failed to extract body due to:
Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3].
Message: com.sun.mail.imap.IMAPMessage@16e6c70e]
org.apache.camel.RuntimeCamelException: Failed to extract body due to:
Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3].
Message: com.sun.mail.imap.IMAPMessage@16e6c70e
at
org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:275)
~[camel-mail-2.15.2.jar:2.15.2]
at
org.apache.camel.component.mail.MailMessage.createBody(MailMessage.java:103)
~[camel-mail-2.15.2.jar:2.15.2]
at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:41)
~[camel-core-2.15.2.jar:2.15.2]
at
org.apache.camel.component.mail.MailConsumer.createExchanges(MailConsumer.java:326)
~[camel-mail-2.15.2.jar:2.15.2]
at 
org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:121)
~[camel-mail-2.15.2.jar:2.15.2]
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
[camel-core-2.15.2.jar:2.15.2]
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
[camel-core-2.15.2.jar:2.15.2]
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482)
[na:1.7.0]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:315)
[na:1.7.0]
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:189)
[na:1.7.0]
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
[na:1.7.0]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
[na:1.7.0]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626)
[na:1.7.0]
at java.lang.Thread.run(Thread.java:804) [na:1.7.0]
Caused by: javax.mail.MessagingException: Unable to load BODYSTRUCTURE
at 
com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1261)
~[com.ibm.ws.prereq.javamail.jar:na]
at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:597)
~[com.ibm.ws.prereq.javamail.jar:na]
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1395)
~[com.ibm.ws.prereq.javamail.jar:na]
at
org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:247)
~[camel-mail-2.15.2.jar:2.15.2]
... 13 common frames omitted

Here is the route (very simple) :

  @Override
  public void configure() throws Exception {
from(getPropertiesUri())
/**/.to(log:dummy);
  }

  protected String getPropertiesUri() {
String prefix = Constants.MAIL.concat(provider);
StringBuilder uri = new StringBuilder();

   
uri.append(getContext().getProperties().get(prefix.concat(.protocol))).append(://);
   
uri.append(getContext().getProperties().get(prefix.concat(.host))).append(?);
   
uri.append(username=).append(getContext().getProperties().get(prefix.concat(.user)));
   
uri.append(password=).append(getContext().getProperties().get(prefix.concat(.password)));
   
uri.append(folderName=).append(getContext().getProperties().get(prefix.concat(.folder)));
   
uri.append(unseen=).append(getContext().getProperties().get(prefix.concat(.unseen)));
   
uri.append(consumer.delay=).append(getContext().getProperties().get(prefix.concat(.consuming.delay)));
   
uri.append(delete=).append(getContext().getProperties().get(prefix.concat(.delete)));

String options =
getContext().getProperties().get(prefix.concat(.options));

if (StringUtils.isNotBlank(options)) {
 
uri.append().append(getContext().getProperties().get(prefix.concat(.options)));
}

return uri.toString();
  }

and the uri used to retrieve the mail :

imap://gmain2p01.groupemutuel.ch?username=usernamepassword=passwordfolderName=IMAPunseen=trueconsumer.delay=3delete=true

I didn't find anywhere a similar problem with Camel mail component so I
don't know if it's a bug or if I'm doing something wrong.

Kind regards and thanks a lot for helping.

Thierry Frossard



--
View this message in context: 
http://camel.465427.n5.nabble.com/Exception-thrown-when-reading-a-mail-with-an-attached-file-which-name-contains-a-semicolon-tp5770941.html
Sent from the Camel - Users mailing list archive at 

NoClassDefFoundError: net/minidev/json/parser/ContainerFactory

2015-08-24 Thread shuston
This is for Camel 2.15.3 (also had the problem with 2.15.2)

I am a new Camel user, and trying to use jsonpath. I have in my pom.xml:

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-jsonpath/artifactId
  version${camel.version}/version
/dependency

In my XML config, I have:
route
  from uri=seda:from_rraa/
  process ref=issPreprocessor/
  choice
when
  jsonpath$.header[?(@.name ==
VerifyEmployeeRequest)]/jsonpath
  unmarshal ref=VerifyEmployeeRequest/
/when
  /choice
  
  process ref=crewMock/
  to uri=seda:to_rraa/
/route

I get at runtime (mvn test):

java.lang.NoClassDefFoundError: net/minidev/json/parser/ContainerFactory
at
com.jayway.jsonpath.spi.impl.JsonSmartJsonProvider.init(JsonSmartJsonProvider.java:38)
at
com.jayway.jsonpath.spi.impl.JsonSmartJsonProvider.init(JsonSmartJsonProvider.java:41)
at
com.jayway.jsonpath.spi.JsonProviderFactory.clinit(JsonProviderFactory.java:24)
at
com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:62)
at 
org.apache.camel.jsonpath.JsonPathEngine.init(JsonPathEngine.java:41)
at
org.apache.camel.jsonpath.JsonPathExpression.init(JsonPathExpression.java:33)
at
org.apache.camel.jsonpath.JsonPathLanguage.createPredicate(JsonPathLanguage.java:27)
...

I tried adding this to my pom.xml:
dependency
  groupIdnet.minidev/groupId
  artifactIdjson-smart/artifactId
  version2.1.1/version
/dependency

But that did not help.

Can someone please help steer me in the right direction?




--
View this message in context: 
http://camel.465427.n5.nabble.com/NoClassDefFoundError-net-minidev-json-parser-ContainerFactory-tp5770943.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XA transactions in camel

2015-08-24 Thread Preben.Asmussen
Hi

There is a couple of resources I know of
https://github.com/muellerc/camel-in-transaction
https://github.com/camelinaction (and book)
https://github.com/CamelCookbook (and  book)

Have a look there 

/Preben



--
View this message in context: 
http://camel.465427.n5.nabble.com/XA-transactions-in-camel-tp5770940p5770944.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Is it safe to use ThreadLocalExchange to implement route scope for dependency injection?

2015-08-24 Thread Jan Zankowski
Hi,

My goal is to implement DB multitenancy in a Camel application using
Hibernate and Spring. For this, I need to implement the following Hibernate
interface, which gets called on each read/write to the DB.

public interface CurrentTenantIdentifierResolver {
  public String resolveCurrentTenantIdentifier();
  [...]
}

Because the method doesn't take any parameters, it either needs to use (1)
some static context knowing which tenant the current route execution
belongs to, or (2) a dependency-injected manager holding such a context.

(1) points me to using ThreadLocal holding the current Exchange as it
travels down the route. The Exchange can have some custom field indicating
the tenant.
(2) requires using route scope - where each route execution gets its own
instance of context manager injected into CurrentTenantIdentifierResolver.
Implementing the route scope, however, seems to require the same as (1) -
ThreadLocal referencing the Exchange.

I found the following article ( Git repo) implementing route scope
exactly in this way:
https://blog.jyore.com/2015/01/spring-camel-route-bean-scoping/ It claims
to take advantage of the fact that if a new thread starts processing the
Exchange as it travels down the route, for example after a
parallel-processing multicast, the new thread gets a copy of the original
Exchange, and an ExchangeCreatedEvent is fired, allowing a listener to set
the ThreadLocal on the new thread.

I was able to get this to work, though clearing of the ThreadLocal on
ExchangeCompletedEvent doesn't work as the author claims, because the event
is fired on a different thread (I checked).

Such issues make me wonder if it's safe to use such a solution.

I have the following questions in particular:
(a) Let's assume an Exchange E is travelling down a route with a segment
... - A - B - ... If A and B are executed by different threads, is it
guaranteed that the new thread (or threads) executing B will each copy the
exchange and fire ExchangeCreatedEvent before executing B?
(b) Why is ExchangeCompletedEvent sent by a different thread than the one
executing L, the last endpoint on the route? Can I use some other hook to
clear the ThreadLocal on the thread executing L, after L is executed? Maybe
a custom RoutePolicy, custom SynchronizationAdapter, or onCompletion()?
(c) Can Asynchronous Routing Engine or AsyncProcessors cause any problems
in this setup? (If the answer to (a) is yes, I'd assume they won't cause
problems.)
(d) Any other caveats?

This thread is related:
http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-td5729849.html

Many thanks!
Jan


Re: Camel CXF Transport works within Blueprint only when XSD validation is disabled

2015-08-24 Thread metatech
Hello,

My understanding is that there is no simple solution to this problem.
I propose I will create a JIRA ticket so that anyone can investigate it
further later.

Best regards,

metatech



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-CXF-Transport-works-within-Blueprint-only-when-XSD-validation-is-disabled-tp5770593p5770937.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to route pojo in camel

2015-08-24 Thread Christian Müller
Something like this:

from(timer:...)
  .to(sql:...)
  .split(...)
.convertBodyTo(...)
.to(cxf:...)
.to(ftp:...)
  .end();

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Fri, Aug 21, 2015 at 12:38 PM, Amar Sheth shethaa2...@gmail.com wrote:

 Hi,

 I am new to Apache Camel,

 I have an requirement were in I have to route pojo in camel and some
 processing to be done.

 My scenario/requirement is

 I have first component , which do the DB fetch and get the records, now for
 each records, call a webservice, which will return java POJO, we need to
 pass this pojo to route for some processing and ftp

 Pseudo Logic

 from(Java Pojo).Process(Some Process).to(ftp location).

 My question is how do I pass the Java Pojo in from part of the camel?

 Regards,
 Amar S



Re: Apache Camel XA transaction

2015-08-24 Thread Christian Müller
Have a look here:
https://github.com/muellerc/camel-in-transaction/blob/master/src/test/java/org/apache/cmueller/camel/samples/camelone/tx/JmsAndJdbcCompensationTransactionSampleTest.java

Hope this helps,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Thu, Aug 20, 2015 at 3:52 PM, kishoreJ kishore00...@gmail.com wrote:

 Hi claus

 But in that transactional client it is not specifying anything about what i
 need .


 I have to update a database if the message is sent successfully to a queue
 ,
 if one fails then i have to roll back both the transactions.
 Here i am dealing with a database transaction and a camel transaction.

 If any of one fails i have to roll back both the transactions there is
 nothing mentioned about rolling back both database transaction and camel
 transaction at a time in that article.






 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Apache-Camel-XA-transaction-tp5770836p5770855.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Load Bean Definitions from XML in Camel

2015-08-24 Thread Christian Müller
I didn't got the question...

You can create a Camel route from (Spring) XML or you can use Java Code,
e.g. implementing a RouteBuilder.

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Fri, Aug 21, 2015 at 11:04 AM, Felix Thomas felix.tho...@gmail.com
wrote:

 hello,

I know we can load RouteDefinations from XML, but can we have the
 same idea of loading for Beans from a XML like Spring. Is there anything
 already available inAPI?

 Regards,
 Felix T



Re: Apache Camel XA transaction

2015-08-24 Thread Christian Müller
Sorry, I mean this one:
https://github.com/muellerc/camel-in-transaction/tree/master/src/test/java/org/apache/cmueller/camel/samples/camelone/xa

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Mon, Aug 24, 2015 at 10:49 PM, Christian Müller 
christian.muel...@gmail.com wrote:

 Have a look here:

 https://github.com/muellerc/camel-in-transaction/blob/master/src/test/java/org/apache/cmueller/camel/samples/camelone/tx/JmsAndJdbcCompensationTransactionSampleTest.java

 Hope this helps,

 Christian
 -

 Software Integration Specialist

 Apache Member
 V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
 Apache Incubator PMC Member

 https://www.linkedin.com/pub/christian-mueller/11/551/642

 On Thu, Aug 20, 2015 at 3:52 PM, kishoreJ kishore00...@gmail.com wrote:

 Hi claus

 But in that transactional client it is not specifying anything about what
 i
 need .


 I have to update a database if the message is sent successfully to a
 queue ,
 if one fails then i have to roll back both the transactions.
 Here i am dealing with a database transaction and a camel transaction.

 If any of one fails i have to roll back both the transactions there is
 nothing mentioned about rolling back both database transaction and camel
 transaction at a time in that article.






 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Apache-Camel-XA-transaction-tp5770836p5770855.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





Camel File write issue with multiple threads writing to same File

2015-08-24 Thread Vanshul . Chawla
Hello,

We are facing an issue with File write in camel.

Our Camel route runs with 36 threads and it writes to 4 files in parallel 
depending on Message Type. These files are written in append mode and a file 
per minute which we defined using FileName with datetime.

Issue is that some files in a day(during period when load is huge) gets 
corrupted. It gets jumbled data. Seems like one thread is writing and not 
taking a lock and other threads starts writing to same file.

Is there any way that one thread writes to a file and takes lock so that other 
thread waits till this write is completed?


Vanshul