Re: Starting and stopping routes leak threads

2014-12-10 Thread Claus Ibsen
Hi

Thanks for reporting. You are welcome to log a JIRA ticket about this bug.

On Wed, Dec 10, 2014 at 4:59 PM, Bjørn Ellingsen
 wrote:
> Using Camel 2.14.0, I'm experiencing the exact same situation as described
> in this old Jira issue: https://issues.apache.org/jira/browse/CAMEL-5677
> only difference is that my routes are file (or SFTP) based, not SEDA.
>
> Trying something like:
>
> for (int i = 0; i < 50; i++) {
> camelContext.startRoute(routeId);
> camelContext.stopRoute(routeId);
> }
>
> results in 50 orphan threads of this type:
>
> "Camel (camel) thread #231 - sftp://user@host/path"; #10170 daemon prio=5
> os_prio=0 tid=0x7fa4b46a5800 nid=0x10fc waiting on condition
> [0x7fa452934000]
>java.lang.Thread.State: TIMED_WAITING (parking)
>   at sun.misc.Unsafe.park(Native Method)
>   - parking to wait for  <0xb83dc900> (a
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
>   at
> java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
>   at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
>   at
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
>   at
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>   at
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
>   at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
>   at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>   at java.lang.Thread.run(Thread.java:745)
>
> Switching to suspend/resume solves the problem, however I guess the
> start/stop issue should be addressed.
>
> --
> Bjørn E.
>



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Re: Sending to Syslog

2014-12-10 Thread Claus Ibsen
Hi

Isn't there more details about why syslog cannot be created? Also do
you have the JARs on the classpath for it? And what version of Camel
do you use?

On Wed, Dec 10, 2014 at 7:16 PM, mtod09  wrote:
> I would like to setup a ActiveMQ queue for syslog messages and use Camel to
> send to the Syslog Server.
>
> I looked at the following link but I'm unable to get this to work.
>
> http://camel.apache.org/syslog.html
>
> I'm using Spring for the configuration.
>
>xmlns="http://www.springframework.org/schema/beans";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>   http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
>   http://activemq.apache.org/schema/core
> http://activemq.apache.org/schema/core/activemq-core.xsd";>
>
>
>  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> 
> 
> file:${activemq.conf}/credentials.properties
> 
> 
>
>  class="org.apache.camel.builder.DeadLetterChannelBuilder">
> 
>  ref="myRedeliveryPolicyConfig"/>
> 
>
>  class="org.apache.camel.processor.RedeliveryPolicy">
> 
> 
> 
>
>  xmlns="http://camel.apache.org/schema/spring";
> xmlns:km="http://xsdrepo.foundationmedicine.com/messaging/esb";>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> I keep getting an error loading the datatype.
>
> "because of Data format 'syslog' could not be created"
>
> Any help would be appreciated.
>
> Mike
>
>
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Sending-to-Syslog-tp5760517.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Camel activemq topic route adds addtional subscriber to the activeMQ topic upon each processing

2014-12-10 Thread Aryan
Hi All,

We are using camel 2.13.2 with apache activeMQ 5.9.0 configured to store
messages in the database. We are using a standalone java class  which
publishes the messages to that topic.

Here is our activeMQ configuration.











We have a route which creates a subscriber(we tried with both durable and
non durable subscriber)






We have added a simple debug statement to the repositoryRefreshProcessor.

We have written a sample publisher which puts a message on the topic. When
the topic subscriber route picks up the message, it invokes
repositoryRefreshProcessor and the message is processed. But the consumer
created (because of this route processing is still registered to the topic).
When a second message is sent, this route registers a new consumer and the
message is consumed twice (one by this new consumer and one by the previous
existing consumer). This goes on and on and every time a new consumer gets
added and message gets processed for +1 times.

Also another issue is that the message does not get removed from JMS DB (we
are using oracle). But this message is not processed again. It gets
processed only once but is not removed from DB after processing
Even If we delete the messages manually, the consumers are still not
removed. Every time the route processes a message. a new consumer gets added
and hence message gets processed that many number of times.

It appears we are missing some configuration which cause this behavior.
Please advice.

Regards,
Aryan




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-activemq-topic-route-adds-addtional-subscriber-to-the-activeMQ-topic-upon-each-processing-tp5760532.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Issue in publishTopicName in mqtt component

2014-12-10 Thread Jinesh M.K
Hi,

I have a spring DSL route definition







here message is consumed from test/hello topic and publishing is happen in
the same consumed topic (publishTopicName is ignored). How to solve it?

Thanks
-- 

Jinesh M.K


Simple expression with JSON and redis

2014-12-10 Thread gmh
All,
I have a requirement where we take data from rabbitmq and insert them into
redis
Below is my exchange taken from stacktrace:
Exchange[
Id  ID-MRT-GMH1119-49410-1418246041340-0-2
ExchangePattern InOptionalOut
Headers
{breadcrumbId=ID-MRT-GMH1119-49410-1418246041340-0-1,
CamelRedelivered=false, CamelRedeliveryCounter=0, contentEncoding=null,
contentType=null, correlationId=null, expiration=null, messageId=null,
priority=null, replyTo=null, type=null}
BodyTypejava.util.HashMap
Body{id=lol919xsx, op=i,
objectId=5488b7a11c64c229e3627bce, o={createdOn=2014-11-24T10:13:21.444Z,
modifiedOn=null, attributes=[{name=Crib 1, value=Inventory}, {name=Access,
value=Level1}], tagId=lol919xsx}, type=tags}
]
The data I am pulling from rabbitmq is in JSON. I converted it into a map
and then I tried to use simple expression language to insert data into redis

Below is my syntax
   
"${body.type)"
"${body.id)"

I kept getting incorrect syntax exception.
Can anyone help me with my syntax?
Thanks,Gordon





--
View this message in context: 
http://camel.465427.n5.nabble.com/Simple-expression-with-JSON-and-redis-tp5760520.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Simple expression with JSON and redis

2014-12-10 Thread gmh
Found the answer here:

http://camel.465427.n5.nabble.com/Simple-td3242568.html#a3242571


Gordon



--
View this message in context: 
http://camel.465427.n5.nabble.com/Simple-expression-with-JSON-and-redis-tp5760520p5760521.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Aggregator race condition in recovery task?

2014-12-10 Thread bendherville
The issue you're experiencing may be related to
https://issues.apache.org/jira/browse/CAMEL-4271



--
View this message in context: 
http://camel.465427.n5.nabble.com/Aggregator-race-condition-in-recovery-task-tp5758315p5760530.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Exchange[Message: [Body is null]] even though Server is sending Response

2014-12-10 Thread ScalaKp
Hi  All , 

I found the problem myself. Issue with Codec. 
I added my custom codec now starts working .



--
View this message in context: 
http://camel.465427.n5.nabble.com/Exchange-Message-Body-is-null-even-though-Server-is-sending-Response-tp5760434p5760529.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Need leading/trailing spaces support in camel:simple

2014-12-10 Thread Aki Yoshida
you can set the trim attribute in the expression.
trim=false

and it think you should be using \r and \n instead of relying on the
implicit LF or the xml-char ref to be on the safer side in preserving
those chararacters.


2014-12-09 11:08 GMT+01:00 Goyal, Arpit :
> Hi Colleagues,
>
> We have the following XML DSL (part of the whole xml), where we set the body 
> using camel:simple tag. Somehow in the processing, we see that the spaces are 
> trimmed at the end.
>
>
> 
>
> NameIDPlace
>
> A 1 X
>
> B 2 D
>
> B 3 Bangalore
>
> E 4 A
>
> 
>
>
>
> Camel Version: 2.12.x
>
>
>
> Any pointers how to preserve this while using 'camel:simple' - some property 
> may be?
>
>
>
> Regards,
>
> A.
>


Re: AW: camel - xsd

2014-12-10 Thread Aki Yoshida
i meant woodstox-core-asl (e.g., woodstox-core-asl-4.4.1.jar).
its maven coordinate is

mvn:org.codehaus.woodstox/woodstox-core-asl/4.4.1

you need to have woodstox or some other parser that reliably reports
the offset location at each parse event.
Sjsxp (sun/oracle implementation included in JDK) doesn't do that, so
you can't use it.

jmtest.tar.gz contains a maven project that can be executed directly
by typing mvn test at the console or can be imported into your eclipse
IDE.

2014-12-10 13:13 GMT+01:00 Aki Yoshida :
> i just created a test that uses your data and verified that it is working 
> fine.
> please take a look at this file at my dropbox.
> https://www.dropbox.com/s/pfgvs9si9bvujxo/jmtest.tar.gz?dl=0
> just extract the files into camel-core and run JMNewsTest.
> and see if that works in your environment, (i believe it does).
>
> in that case, we need to find out the difference to your case.
> do you have woodstox-api in your class path?
>
>
> 2014-12-10 12:15 GMT+01:00 Aki Yoshida :
>> okay.
>> let me take a look.
>>
>>
>> 2014-12-10 12:02 GMT+01:00 Jan Matèrne (jhm) :
>>> No, input is valid xml.
>>> After invoking xtokenize() the xml is invalid.
>>>
>>> CAMEL-8106 is very  short. I can't see whether it is related.
>>>
>>>
>>> I posted an example on the user list
>>> http://mail-archives.apache.org/mod_mbox/camel-users/201412.mbox/%3C002b01d01452%24e8ee27a0%24baca76e0%24%40de%3E
>>>
>>> I had done a 'workaround' for this special example
>>> // Workaround of a bug?? in XMLTokenizerExpression
>>> .setBody(simple("${body.replace('news:Newsletter>', 
>>> 'news:Newsletter>')}"))
>>> .setBody(simple("${body.replace('', 
>>> 'news:Newsletter>')}"))
>>>
>>> Without that the split messages have wrong end tags.
>>>
>>>
>>> Jan
>>>
>>>
 -Ursprüngliche Nachricht-
 Von: Aki Yoshida [mailto:elak...@gmail.com]
 Gesendet: Mittwoch, 10. Dezember 2014 10:34
 An: users@camel.apache.org
 Betreff: Re: AW: camel - xsd

 you are talking about the invalid-xml parsing bug in xtokenzier.
 that has been fixe with CAMEL-8106. It should be part of the new
 2.14.1, which is to be released shortly.

 regards, aki

 2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) :
 > I played a little bit.
 >
 > Jan
 >
 >
 > public class XmlTest extends CamelTestSupport {
 >
 > @EndpointInject(uri="mock:valid")
 > MockEndpoint valid;
 >
 > @EndpointInject(uri="mock:validationError")
 > MockEndpoint validationError;
 >
 >
 >
 > @Test
 > public void validNewsfeed() throws Exception {
 > // Newsfeed contains 2 news
 > valid.expectedMessageCount(2);
 > valid.expectedMessagesMatches(
 > // Use helper methods from the static imported
 PredicateBuilder
 > and(
 > header("newsfeed.date").isEqualTo("2014.12.09
 14:15"),
 > header("news.author").isEqualTo("Jan"),
 >
 >
 body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/com
 > plex/\
 > "")
 > )
 > );
 > // no error expected
 > validationError.expectedMessageCount(0);
 >
 > // Read xml from classpath and send to Camel route
 > String xml =
 >
 IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/tes
 > t/xml/
 > complex/validNewsfeed.xml"));
 > sendBody("direct:in", xml);
 >
 > // 'execute' all tests
 > assertMockEndpointsSatisfied();
 > }
 >
 >
 > @Test
 > public void invalidXml() throws Exception {
 > valid.expectedMessageCount(0);
 > validationError.expectedMessageCount(1);
 >
 > String xml = "";
 > sendBody("direct:in", xml);
 >
 > assertMockEndpointsSatisfied();
 > }
 >
 >
 >
 > @Override
 > protected RouteBuilder createRouteBuilder() throws Exception {
 > return new RouteBuilder() {
 > @Override
 > public void configure() throws Exception {
 > // Our XML uses namespaces, so we have to deal with
 that.
 > Namespaces ns = new Namespaces("news",
 > "http://www.materne.de/camel/test/xml/complex/";);
 >
 > // XSD-invalid data goes to this endpoint
 > onException(ValidationException.class)
 > .to("mock:validationError");
 >
 > from("direct:in")
 > // XSD-validation
 >
 > .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")
 >
 > // Store newsfeed data in the header before
 split,
 > so we haven't to do that on each
 >   

Elasticsearch component - bulk requests with ids

2014-12-10 Thread slush
Hello! I'm new to the camel forums. First off, thank you to all the
contributors. Camel is a wonderful framework.

While doing some work recently I came across an issue with the elasticsearch
component. Specifically, I need to be able to send a bulk request where the
documents in the bulk request have application-provided (not
automatically-generated, as is what happens by default with the
elasticsearch-java client) document ids.

I see that the INDEX operation supports an index header as of version 2.15.0
(which is yet to be released). However, this still wouldn't satisfy my need,
as I want to send bulk updates, not individual index requests for
speed/efficiency.

So, I've temporarily forked the elasticsearch component and added support
for my use case and others. To do this, 

My question is whether this is a suitable change to the component. If so,
I'll attempt to create a ticket in the issue tracker and a pull request for
the changes I've made after I'm done finalizing them (I haven't read through
the contribution guide yet, i'm sure I need tests, doc, coding standards,
etc.).

Additionally, is it common for components to provide other helper classes,
like AggregationStrategies? I've written an aggregation strategy that will
collect individual IndexRequests into a BulkRequest so that the change I've
made in the Elasticsearch component can support my needs. This is easily
reproducible by others and follows after the ArrayListAggregationStrategy
example in the camel guide, but I think the use case would be common so it
may be good to include with the patch as well.

Thank you!
Derek Abdine



--
View this message in context: 
http://camel.465427.n5.nabble.com/Elasticsearch-component-bulk-requests-with-ids-tp5760522.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel Mina2 not receiving data using Socket

2014-12-10 Thread Saurabh Singhal
Hi

Thanks for the reply. Basically when I send the data using a socket
programming code as mentioned in the problem, it does not print the output.
I even copied the from to code from Apache camel site as below: 


from("mina2:tcp://localhost:6789?sync=true&textline=true").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
exchange.getOut().setBody("Bye " + body);
   
exchange.getOut().setHeader(Mina2Constants.MINA_CLOSE_SESSION_WHEN_COMPLETE,
true);
}
});

I have seen a couple of posts which says that there are issues with camel
netty4 regarding session etc. Moreover my code is working with mina and not
mina2 .. surprising !!

Any help would be appreciated. Thanks in advance



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372p5760518.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Sending to Syslog

2014-12-10 Thread mtod09
I would like to setup a ActiveMQ queue for syslog messages and use Camel to
send to the Syslog Server.

I looked at the following link but I'm unable to get this to work.

http://camel.apache.org/syslog.html

I'm using Spring for the configuration.

http://www.springframework.org/schema/beans";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
  http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd";>





file:${activemq.conf}/credentials.properties













http://camel.apache.org/schema/spring";
xmlns:km="http://xsdrepo.foundationmedicine.com/messaging/esb";> 











I keep getting an error loading the datatype.

"because of Data format 'syslog' could not be created"

Any help would be appreciated.

Mike







--
View this message in context: 
http://camel.465427.n5.nabble.com/Sending-to-Syslog-tp5760517.html
Sent from the Camel - Users mailing list archive at Nabble.com.


File renaming problems under Windows

2014-12-10 Thread Adriano Ferranti
Hello guys, 

I'm getting the same problem related  in
https://issues.apache.org/jira/browse/CAMEL-6756.  I mean, when the route
raises any exception, the file is not moved or deleted at the end of the
process.

I believe that occurred a misunderstanding about the correction of  issue
related above, since it was closed as the main problem would be the
AmbiguousMethodCallException, and it was given a solution for not raising
this exception. Besides the comment gave for the guy closing the bug was
"You should avoid keeping throw exception in the route.".

In this way, the root problem was not corrected, of course you can avoid
throwing exceptions and adapt your route to work in other way but in the
case of an unexpected exception, the problem will occur.   



Throttling based on content in camel

2014-12-10 Thread yogu13

Hi,

We need to do throttling based on id which is received as part of the
request but what I see that the default implementation of
org.apache.camel.impl.ThrottlingInflightRoutePolicy is based on predefined
rule set in the xml, there was a request raised sometime back for a more
dynamic implementation but looks like nothing has happened on this...
wondering if an implementation like below can be desired.

Two implementations to be a made available as part of camel

1. the existing implementation based on the rule set defined in xml
2. camel to provide an interface having a method boolean
processRequest(Exchange) .. user implements this interface .. the return of
this method is used to obtain a lock...

Let me know the thoughts so i can update this JIRA @
https://issues.apache.org/jira/browse/CAMEL-5599

Regards,
-Yogesh



--
View this message in context: 
http://camel.465427.n5.nabble.com/Throttling-based-on-content-in-camel-tp5760505.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Rép: Splitting Message from Ftp Consumer

2014-12-10 Thread noamRamonet
Correction. Inserting an explicit conversion to String solves the problem: 
 

ftp://user:pass@host/
postalBox/inBox?fileName=simpleTextData.txt&localWorkDirectory=temp&binary=true"/>


 
 
 






--
View this message in context: 
http://camel.465427.n5.nabble.com/Rep-Splitting-Message-from-Ftp-Consumer-tp5760220p5760489.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Starting and stopping routes leak threads

2014-12-10 Thread Bjørn Ellingsen
Using Camel 2.14.0, I'm experiencing the exact same situation as 
described in this old Jira issue: 
https://issues.apache.org/jira/browse/CAMEL-5677 only difference is that 
my routes are file (or SFTP) based, not SEDA.


Trying something like:

for (int i = 0; i < 50; i++) {
camelContext.startRoute(routeId);
camelContext.stopRoute(routeId);
}

results in 50 orphan threads of this type:

"Camel (camel) thread #231 - sftp://user@host/path"; #10170 daemon prio=5 
os_prio=0 tid=0x7fa4b46a5800 nid=0x10fc waiting on condition 
[0x7fa452934000]

   java.lang.Thread.State: TIMED_WAITING (parking)
  at sun.misc.Unsafe.park(Native Method)
  - parking to wait for  <0xb83dc900> (a 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
  at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
  at 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
  at 
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
  at 
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
  at 
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
  at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
  at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

  at java.lang.Thread.run(Thread.java:745)

Switching to suspend/resume solves the problem, however I guess the 
start/stop issue should be addressed.


--
Bjørn E.



Re: jmx- annotated RouteBuilder not showing up in JConsole

2014-12-10 Thread Claus Ibsen
Hi

It needs to extends ServiceSupport and depending on how its created,
you may need to manually add it to camel context, using addService so
Camel can register it as a service and in jmx

On Wed, Dec 10, 2014 at 4:41 PM, dermoritz  wrote:
> I tried to annotate a RouteBuilder with @ManagedResource and a method from it
> with @ManagedOperation but i can't find it in JConsole. The other classes
> including my annotated custom endpoint is showing up fine.
>
> I am not sure if these annotations work with all kinds of classes within
> camel?! In my case the annotated RouteBuilder is some kind of central
> control class. Is does not contain a route but is loading several other
> RouteBuilders. It also adds global (context scope) exception handlers and
> adds a RoutePolicyFactory that centrally handles start up and control logic.
>
> The methods i want to make available via JMX re method that start/stop
> certain groups of routes.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/jmx-annotated-RouteBuilder-not-showing-up-in-JConsole-tp5760486.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


jmx- annotated RouteBuilder not showing up in JConsole

2014-12-10 Thread dermoritz
I tried to annotate a RouteBuilder with @ManagedResource and a method from it
with @ManagedOperation but i can't find it in JConsole. The other classes
including my annotated custom endpoint is showing up fine.

I am not sure if these annotations work with all kinds of classes within
camel?! In my case the annotated RouteBuilder is some kind of central
control class. Is does not contain a route but is loading several other
RouteBuilders. It also adds global (context scope) exception handlers and
adds a RoutePolicyFactory that centrally handles start up and control logic.

The methods i want to make available via JMX re method that start/stop
certain groups of routes.



--
View this message in context: 
http://camel.465427.n5.nabble.com/jmx-annotated-RouteBuilder-not-showing-up-in-JConsole-tp5760486.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Rép: Splitting Message from Ftp Consumer

2014-12-10 Thread Noam Ramonet
Hi,

I’ve testing a little more and the issue seems related to the Expresion
used by split to iterate.

Ftp consumers generates a message with body input of type  RemoteFile<
FtpFile>. org.apache.commons.net.ftp.FtpFile#toString() method returns the
strange splitted content which originated the post “-rw-r--r--1
513  51283 Dec 05 09:55 simpleTextData.txt”.

RouteBuilder#body() Expresion generates this String as output. It can be
seen using  Java DSL. Next route presents the same log as the Spring
counterpart:

from("ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txt&localWorkDirectory=temp")
.split(body().tokenize("\n"))
.log("Line: ${body}")
.end();

Whereas below route works as I need:

from("ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txt&localWorkDirectory=temp")
.split(body(String.class).tokenize("\n"))
.log("Line: ${body}")
.end();

Is there any way to force the String type conversion in Spring DSL? I
already tried , pointed by
Francois, without success.

Is this an expected behaviour or a bug?

Meanwhile, a simple workaround for Spring DSL would be replacing the
tokenizer with a custom bean for splitting:






public class CustomTokenizer {
public List splitFtpFile(String remote){
return Arrays.asList(remote.split("\n"));
}
}


Re: Camel-Hive

2014-12-10 Thread smilevasu6
Hi All,

Any one is there to help me on below one please



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


Re: AW: camel - xsd

2014-12-10 Thread Aki Yoshida
i just created a test that uses your data and verified that it is working fine.
please take a look at this file at my dropbox.
https://www.dropbox.com/s/pfgvs9si9bvujxo/jmtest.tar.gz?dl=0
just extract the files into camel-core and run JMNewsTest.
and see if that works in your environment, (i believe it does).

in that case, we need to find out the difference to your case.
do you have woodstox-api in your class path?


2014-12-10 12:15 GMT+01:00 Aki Yoshida :
> okay.
> let me take a look.
>
>
> 2014-12-10 12:02 GMT+01:00 Jan Matèrne (jhm) :
>> No, input is valid xml.
>> After invoking xtokenize() the xml is invalid.
>>
>> CAMEL-8106 is very  short. I can't see whether it is related.
>>
>>
>> I posted an example on the user list
>> http://mail-archives.apache.org/mod_mbox/camel-users/201412.mbox/%3C002b01d01452%24e8ee27a0%24baca76e0%24%40de%3E
>>
>> I had done a 'workaround' for this special example
>> // Workaround of a bug?? in XMLTokenizerExpression
>> .setBody(simple("${body.replace('news:Newsletter>', 
>> 'news:Newsletter>')}"))
>> .setBody(simple("${body.replace('', 
>> 'news:Newsletter>')}"))
>>
>> Without that the split messages have wrong end tags.
>>
>>
>> Jan
>>
>>
>>> -Ursprüngliche Nachricht-
>>> Von: Aki Yoshida [mailto:elak...@gmail.com]
>>> Gesendet: Mittwoch, 10. Dezember 2014 10:34
>>> An: users@camel.apache.org
>>> Betreff: Re: AW: camel - xsd
>>>
>>> you are talking about the invalid-xml parsing bug in xtokenzier.
>>> that has been fixe with CAMEL-8106. It should be part of the new
>>> 2.14.1, which is to be released shortly.
>>>
>>> regards, aki
>>>
>>> 2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) :
>>> > I played a little bit.
>>> >
>>> > Jan
>>> >
>>> >
>>> > public class XmlTest extends CamelTestSupport {
>>> >
>>> > @EndpointInject(uri="mock:valid")
>>> > MockEndpoint valid;
>>> >
>>> > @EndpointInject(uri="mock:validationError")
>>> > MockEndpoint validationError;
>>> >
>>> >
>>> >
>>> > @Test
>>> > public void validNewsfeed() throws Exception {
>>> > // Newsfeed contains 2 news
>>> > valid.expectedMessageCount(2);
>>> > valid.expectedMessagesMatches(
>>> > // Use helper methods from the static imported
>>> PredicateBuilder
>>> > and(
>>> > header("newsfeed.date").isEqualTo("2014.12.09
>>> 14:15"),
>>> > header("news.author").isEqualTo("Jan"),
>>> >
>>> >
>>> body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/com
>>> > plex/\
>>> > "")
>>> > )
>>> > );
>>> > // no error expected
>>> > validationError.expectedMessageCount(0);
>>> >
>>> > // Read xml from classpath and send to Camel route
>>> > String xml =
>>> >
>>> IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/tes
>>> > t/xml/
>>> > complex/validNewsfeed.xml"));
>>> > sendBody("direct:in", xml);
>>> >
>>> > // 'execute' all tests
>>> > assertMockEndpointsSatisfied();
>>> > }
>>> >
>>> >
>>> > @Test
>>> > public void invalidXml() throws Exception {
>>> > valid.expectedMessageCount(0);
>>> > validationError.expectedMessageCount(1);
>>> >
>>> > String xml = "";
>>> > sendBody("direct:in", xml);
>>> >
>>> > assertMockEndpointsSatisfied();
>>> > }
>>> >
>>> >
>>> >
>>> > @Override
>>> > protected RouteBuilder createRouteBuilder() throws Exception {
>>> > return new RouteBuilder() {
>>> > @Override
>>> > public void configure() throws Exception {
>>> > // Our XML uses namespaces, so we have to deal with
>>> that.
>>> > Namespaces ns = new Namespaces("news",
>>> > "http://www.materne.de/camel/test/xml/complex/";);
>>> >
>>> > // XSD-invalid data goes to this endpoint
>>> > onException(ValidationException.class)
>>> > .to("mock:validationError");
>>> >
>>> > from("direct:in")
>>> > // XSD-validation
>>> >
>>> > .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")
>>> >
>>> > // Store newsfeed data in the header before
>>> split,
>>> > so we haven't to do that on each
>>> > // splittet news-message.
>>> > .setHeader("newsfeed.date",
>>> > ns.xpath("/news:Newsletter/@date";, String.class))
>>> >
>>> > // http://camel.apache.org/splitter.html
>>> > // xtokenize() is available since Camel 2.14.
>>> > // Use the 'wrap'-mode so we keep the Newsletter-
>>> Header
>>> > .split().xtokenize("/news:Newsletter/News";, 'w',
>>> > ns)
>>> >
>>> > // Workaround of a bug?? in
>>> XMLTokenizerExpression
>>> >
>>> > .setBody(simple("${body.replace('news:Newsletter>',
>>> > 'news:Newsletter>')}"))
>>> >
>>> > .setBody(simple("$

Re: AW: camel - xsd

2014-12-10 Thread Aki Yoshida
okay.
let me take a look.


2014-12-10 12:02 GMT+01:00 Jan Matèrne (jhm) :
> No, input is valid xml.
> After invoking xtokenize() the xml is invalid.
>
> CAMEL-8106 is very  short. I can't see whether it is related.
>
>
> I posted an example on the user list
> http://mail-archives.apache.org/mod_mbox/camel-users/201412.mbox/%3C002b01d01452%24e8ee27a0%24baca76e0%24%40de%3E
>
> I had done a 'workaround' for this special example
> // Workaround of a bug?? in XMLTokenizerExpression
> .setBody(simple("${body.replace('news:Newsletter>', 
> 'news:Newsletter>')}"))
> .setBody(simple("${body.replace('', 
> 'news:Newsletter>')}"))
>
> Without that the split messages have wrong end tags.
>
>
> Jan
>
>
>> -Ursprüngliche Nachricht-
>> Von: Aki Yoshida [mailto:elak...@gmail.com]
>> Gesendet: Mittwoch, 10. Dezember 2014 10:34
>> An: users@camel.apache.org
>> Betreff: Re: AW: camel - xsd
>>
>> you are talking about the invalid-xml parsing bug in xtokenzier.
>> that has been fixe with CAMEL-8106. It should be part of the new
>> 2.14.1, which is to be released shortly.
>>
>> regards, aki
>>
>> 2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) :
>> > I played a little bit.
>> >
>> > Jan
>> >
>> >
>> > public class XmlTest extends CamelTestSupport {
>> >
>> > @EndpointInject(uri="mock:valid")
>> > MockEndpoint valid;
>> >
>> > @EndpointInject(uri="mock:validationError")
>> > MockEndpoint validationError;
>> >
>> >
>> >
>> > @Test
>> > public void validNewsfeed() throws Exception {
>> > // Newsfeed contains 2 news
>> > valid.expectedMessageCount(2);
>> > valid.expectedMessagesMatches(
>> > // Use helper methods from the static imported
>> PredicateBuilder
>> > and(
>> > header("newsfeed.date").isEqualTo("2014.12.09
>> 14:15"),
>> > header("news.author").isEqualTo("Jan"),
>> >
>> >
>> body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/com
>> > plex/\
>> > "")
>> > )
>> > );
>> > // no error expected
>> > validationError.expectedMessageCount(0);
>> >
>> > // Read xml from classpath and send to Camel route
>> > String xml =
>> >
>> IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/tes
>> > t/xml/
>> > complex/validNewsfeed.xml"));
>> > sendBody("direct:in", xml);
>> >
>> > // 'execute' all tests
>> > assertMockEndpointsSatisfied();
>> > }
>> >
>> >
>> > @Test
>> > public void invalidXml() throws Exception {
>> > valid.expectedMessageCount(0);
>> > validationError.expectedMessageCount(1);
>> >
>> > String xml = "";
>> > sendBody("direct:in", xml);
>> >
>> > assertMockEndpointsSatisfied();
>> > }
>> >
>> >
>> >
>> > @Override
>> > protected RouteBuilder createRouteBuilder() throws Exception {
>> > return new RouteBuilder() {
>> > @Override
>> > public void configure() throws Exception {
>> > // Our XML uses namespaces, so we have to deal with
>> that.
>> > Namespaces ns = new Namespaces("news",
>> > "http://www.materne.de/camel/test/xml/complex/";);
>> >
>> > // XSD-invalid data goes to this endpoint
>> > onException(ValidationException.class)
>> > .to("mock:validationError");
>> >
>> > from("direct:in")
>> > // XSD-validation
>> >
>> > .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")
>> >
>> > // Store newsfeed data in the header before
>> split,
>> > so we haven't to do that on each
>> > // splittet news-message.
>> > .setHeader("newsfeed.date",
>> > ns.xpath("/news:Newsletter/@date";, String.class))
>> >
>> > // http://camel.apache.org/splitter.html
>> > // xtokenize() is available since Camel 2.14.
>> > // Use the 'wrap'-mode so we keep the Newsletter-
>> Header
>> > .split().xtokenize("/news:Newsletter/News";, 'w',
>> > ns)
>> >
>> > // Workaround of a bug?? in
>> XMLTokenizerExpression
>> >
>> > .setBody(simple("${body.replace('news:Newsletter>',
>> > 'news:Newsletter>')}"))
>> >
>> > .setBody(simple("${body.replace('',
>> > 'news:Newsletter>')}"))
>> >
>> > // Get some data from the splittet news
>> > .setHeader("news.date",
>> > ns.xpath("/news:Newsletter/News/@date";, String.class))
>> > .setHeader("news.author",
>> > ns.xpath("/news:Newsletter//News/@author";, String.class))
>> >
>> > .to("mock:valid");
>> > }
>> > };
>> > }
>> >
>> > }
>> >
>> >
>> >
>> >  > > xmlns="http://www.w3.org/2001/XMLSchema";
>> > xmlns:news="http://www.materne.de/camel/test/xml/compl

Camel-Hive

2014-12-10 Thread smilevasu6
Hi,

I am trying to insert into hive table like


insert overwrite table BD_COMPANIES
t1.BD_COM_ID,t1.BD_COM_NAME,t1.COM_FUNCTIONAL_CURRENCY,t1.BD_COM_CLOSING_ACCP_ID,t1.BD_COM_SET_OF_BOOKS,t1.BD_COM_PERIOD_SET_NAME,t1.BD_COM_LOCATION,t1.BD_COM_ATTRIBUTE1,t1.BD_COM_ATTRIBUTE2,t1.BD_COM_ATTRIBUTE3,t1.BD_COM_ATTRIBUTE4,t1.BD_COM_ATTRIBUTE5
values select
t2.COM_ID,t2.COM_NAME,t2.COM_FUNCTIONAL_CURRENCY,t2.COM_CLOSING_ACCP_ID,t2.COM_SET_OF_BOOKS,t2.COM_PERIOD_SET_NAME,t2.COM_LOCATION,t2.COM_ATTRIBUTE1,t2.COM_ATTRIBUTE2,t2.COM_ATTRIBUTE3,t2.COM_ATTRIBUTE4,t2.COM_ATTRIBUTE5
from BD_COMPANIES_T t2 left outer join BD_COMPANIES t1 on
t1.BD_COM_ID=t2.COM_ID


But its saying 


java.sql.SQLException: Error while compiling statement: FAILED:
ParseException line 1:36 cannot recognize input near 't1' '.' 'BD_COM_ID' in
select clause


Please advice



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


Re: AW: camel - xsd

2014-12-10 Thread smilevasu6
Then Aki tell me how can i read below xsd and fetch mapping attributes

 
http://www.w3.org/2001/XMLSchema";>
  

  


  

  
  

  













  

  
  

  


  

  





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


AW: AW: camel - xsd

2014-12-10 Thread jhm
No, input is valid xml.
After invoking xtokenize() the xml is invalid.

CAMEL-8106 is very  short. I can't see whether it is related.


I posted an example on the user list
http://mail-archives.apache.org/mod_mbox/camel-users/201412.mbox/%3C002b01d01452%24e8ee27a0%24baca76e0%24%40de%3E

I had done a 'workaround' for this special example
// Workaround of a bug?? in XMLTokenizerExpression
.setBody(simple("${body.replace('news:Newsletter>', 
'news:Newsletter>')}"))
.setBody(simple("${body.replace('', 
'news:Newsletter>')}"))

Without that the split messages have wrong end tags.


Jan


> -Ursprüngliche Nachricht-
> Von: Aki Yoshida [mailto:elak...@gmail.com]
> Gesendet: Mittwoch, 10. Dezember 2014 10:34
> An: users@camel.apache.org
> Betreff: Re: AW: camel - xsd
> 
> you are talking about the invalid-xml parsing bug in xtokenzier.
> that has been fixe with CAMEL-8106. It should be part of the new
> 2.14.1, which is to be released shortly.
> 
> regards, aki
> 
> 2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) :
> > I played a little bit.
> >
> > Jan
> >
> >
> > public class XmlTest extends CamelTestSupport {
> >
> > @EndpointInject(uri="mock:valid")
> > MockEndpoint valid;
> >
> > @EndpointInject(uri="mock:validationError")
> > MockEndpoint validationError;
> >
> >
> >
> > @Test
> > public void validNewsfeed() throws Exception {
> > // Newsfeed contains 2 news
> > valid.expectedMessageCount(2);
> > valid.expectedMessagesMatches(
> > // Use helper methods from the static imported
> PredicateBuilder
> > and(
> > header("newsfeed.date").isEqualTo("2014.12.09
> 14:15"),
> > header("news.author").isEqualTo("Jan"),
> >
> >
> body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/com
> > plex/\
> > "")
> > )
> > );
> > // no error expected
> > validationError.expectedMessageCount(0);
> >
> > // Read xml from classpath and send to Camel route
> > String xml =
> >
> IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/tes
> > t/xml/
> > complex/validNewsfeed.xml"));
> > sendBody("direct:in", xml);
> >
> > // 'execute' all tests
> > assertMockEndpointsSatisfied();
> > }
> >
> >
> > @Test
> > public void invalidXml() throws Exception {
> > valid.expectedMessageCount(0);
> > validationError.expectedMessageCount(1);
> >
> > String xml = "";
> > sendBody("direct:in", xml);
> >
> > assertMockEndpointsSatisfied();
> > }
> >
> >
> >
> > @Override
> > protected RouteBuilder createRouteBuilder() throws Exception {
> > return new RouteBuilder() {
> > @Override
> > public void configure() throws Exception {
> > // Our XML uses namespaces, so we have to deal with
> that.
> > Namespaces ns = new Namespaces("news",
> > "http://www.materne.de/camel/test/xml/complex/";);
> >
> > // XSD-invalid data goes to this endpoint
> > onException(ValidationException.class)
> > .to("mock:validationError");
> >
> > from("direct:in")
> > // XSD-validation
> >
> > .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")
> >
> > // Store newsfeed data in the header before
> split,
> > so we haven't to do that on each
> > // splittet news-message.
> > .setHeader("newsfeed.date",
> > ns.xpath("/news:Newsletter/@date";, String.class))
> >
> > // http://camel.apache.org/splitter.html
> > // xtokenize() is available since Camel 2.14.
> > // Use the 'wrap'-mode so we keep the Newsletter-
> Header
> > .split().xtokenize("/news:Newsletter/News";, 'w',
> > ns)
> >
> > // Workaround of a bug?? in
> XMLTokenizerExpression
> >
> > .setBody(simple("${body.replace('news:Newsletter>',
> > 'news:Newsletter>')}"))
> >
> > .setBody(simple("${body.replace('',
> > 'news:Newsletter>')}"))
> >
> > // Get some data from the splittet news
> > .setHeader("news.date",
> > ns.xpath("/news:Newsletter/News/@date";, String.class))
> > .setHeader("news.author",
> > ns.xpath("/news:Newsletter//News/@author";, String.class))
> >
> > .to("mock:valid");
> > }
> > };
> > }
> >
> > }
> >
> >
> >
> >   > xmlns="http://www.w3.org/2001/XMLSchema";
> > xmlns:news="http://www.materne.de/camel/test/xml/complex/";
> >
> > targetNamespace="http://www.materne.de/camel/test/xml/complex/";>
> >
> > 
> > 
> > 
> >  > maxOccurs="unbounded">
> > 
> > 

Re: AW: camel - xsd

2014-12-10 Thread Aki Yoshida
you are talking about the invalid-xml parsing bug in xtokenzier.
that has been fixe with CAMEL-8106. It should be part of the new
2.14.1, which is to be released shortly.

regards, aki

2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) :
> I played a little bit.
>
> Jan
>
>
> public class XmlTest extends CamelTestSupport {
>
> @EndpointInject(uri="mock:valid")
> MockEndpoint valid;
>
> @EndpointInject(uri="mock:validationError")
> MockEndpoint validationError;
>
>
>
> @Test
> public void validNewsfeed() throws Exception {
> // Newsfeed contains 2 news
> valid.expectedMessageCount(2);
> valid.expectedMessagesMatches(
> // Use helper methods from the static imported PredicateBuilder
> and(
> header("newsfeed.date").isEqualTo("2014.12.09 14:15"),
> header("news.author").isEqualTo("Jan"),
>
> body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/complex/\
> "")
> )
> );
> // no error expected
> validationError.expectedMessageCount(0);
>
> // Read xml from classpath and send to Camel route
> String xml =
> IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/test/xml/
> complex/validNewsfeed.xml"));
> sendBody("direct:in", xml);
>
> // 'execute' all tests
> assertMockEndpointsSatisfied();
> }
>
>
> @Test
> public void invalidXml() throws Exception {
> valid.expectedMessageCount(0);
> validationError.expectedMessageCount(1);
>
> String xml = "";
> sendBody("direct:in", xml);
>
> assertMockEndpointsSatisfied();
> }
>
>
>
> @Override
> protected RouteBuilder createRouteBuilder() throws Exception {
> return new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> // Our XML uses namespaces, so we have to deal with that.
> Namespaces ns = new Namespaces("news",
> "http://www.materne.de/camel/test/xml/complex/";);
>
> // XSD-invalid data goes to this endpoint
> onException(ValidationException.class)
> .to("mock:validationError");
>
> from("direct:in")
> // XSD-validation
>
> .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")
>
> // Store newsfeed data in the header before split, so we
> haven't to do that on each
> // splittet news-message.
> .setHeader("newsfeed.date",
> ns.xpath("/news:Newsletter/@date";, String.class))
>
> // http://camel.apache.org/splitter.html
> // xtokenize() is available since Camel 2.14.
> // Use the 'wrap'-mode so we keep the Newsletter-Header
> .split().xtokenize("/news:Newsletter/News";, 'w', ns)
>
> // Workaround of a bug?? in XMLTokenizerExpression
> .setBody(simple("${body.replace('news:Newsletter>',
> 'news:Newsletter>')}"))
> .setBody(simple("${body.replace('',
> 'news:Newsletter>')}"))
>
> // Get some data from the splittet news
> .setHeader("news.date",
> ns.xpath("/news:Newsletter/News/@date";, String.class))
> .setHeader("news.author",
> ns.xpath("/news:Newsletter//News/@author";, String.class))
>
> .to("mock:valid");
> }
> };
> }
>
> }
>
>
>
> 
>  xmlns="http://www.w3.org/2001/XMLSchema";
> xmlns:news="http://www.materne.de/camel/test/xml/complex/";
> targetNamespace="http://www.materne.de/camel/test/xml/complex/";>
>
> 
> 
> 
>  maxOccurs="unbounded">
> 
> 
>  base="string">
>  name="date" type="string"/>
>  name="author" type="string"/>
> 
> 
> 
> 
> 
> 
> 
> 
>
> 
>
>
>
>  xmlns:news="http://www.materne.de/camel/test/xml/complex/";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>
> xsi:schemaLocation="http://www.materne.de/camel/test/xml/complex/
> newsfeed.xsd "
> date="2014.12.09 14:15">
> 
> Here is a demo news.
> 
> 
> Second news paragraph.
> 
> news:Newsletter>
>
>
>
>> -Ursprüngliche Nachricht-
>> Von: smilevasu6 [m

Re: Apache Camel Mina2 not receiving data using Socket

2014-12-10 Thread Thomas Termin
Hello,

my answer was a bit confussing maybe. The first sentence is realted to your
sync=false which will not work in camel-mina2.
Btw. you should give camel-netty4 a try.

Thomas

On Wed, Dec 10, 2014 at 9:34 AM, Thomas Termin 
wrote:

> Hello,
>
> Since camel-mina2 all consumer(from) exchanges are InOut. This is
> different to camel-mina. Maybe it is related to that one.
> But actually you say just it does not work. But what exactly is not
> working?
>
> Thomas
>
> On Tue, Dec 9, 2014 at 10:33 AM, Saurabh Singhal 
> wrote:
>
>> I have been trying to send data through socket programming to Apache Camel
>> and I am trying to use *Apache Mina2*. The idea is to send the data over
>> TCP
>> to Camel. For TCP, I am using socket programing. This is what my code is
>> for
>> *Mina2*:
>>
>> public void configure() throws Exception {
>> from("mina2:tcp://localhost:6789?sync=false&")
>> .process(new LogProcessor());
>> }
>>
>> *LogProcessor *only prints the body of the received message using :
>> *exchange.getIn().getBody(String.class)*
>>
>> This piece of code works fine with Apache Mina as below:
>>
>> *from("mina:tcp://localhost:6789?textline=true&sync=true")
>> .process(new LogProcessor());*
>>
>> The socket programming client code that I am using is as below:
>>
>>   try
>>   {
>>  Socket client = new Socket();
>>
>>
>>  PrintWriter s_out = null;*/
>>
>>  client.connect(new InetSocketAddress("localhost", 6789));
>>
>>  OutputStream outToServer = client.getOutputStream();
>>  DataOutputStream out = new DataOutputStream(outToServer);
>>  System.out.println("After Dataoutput stream");
>>  out.writeBytes("Content gets received in server\n");
>>
>>  client.close();
>>   }
>> The same piece of code works fine for Mina but does not work with Mina2. I
>> am unable to figure out what is causing the problem. Do I need to add some
>> parameters in the from clause of Camel.
>>
>> Kindly help.
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>


Re: Apache Camel Mina2 not receiving data using Socket

2014-12-10 Thread Thomas Termin
Hello,

Since camel-mina2 all consumer(from) exchanges are InOut. This is different
to camel-mina. Maybe it is related to that one.
But actually you say just it does not work. But what exactly is not working?

Thomas

On Tue, Dec 9, 2014 at 10:33 AM, Saurabh Singhal 
wrote:

> I have been trying to send data through socket programming to Apache Camel
> and I am trying to use *Apache Mina2*. The idea is to send the data over
> TCP
> to Camel. For TCP, I am using socket programing. This is what my code is
> for
> *Mina2*:
>
> public void configure() throws Exception {
> from("mina2:tcp://localhost:6789?sync=false&")
> .process(new LogProcessor());
> }
>
> *LogProcessor *only prints the body of the received message using :
> *exchange.getIn().getBody(String.class)*
>
> This piece of code works fine with Apache Mina as below:
>
> *from("mina:tcp://localhost:6789?textline=true&sync=true")
> .process(new LogProcessor());*
>
> The socket programming client code that I am using is as below:
>
>   try
>   {
>  Socket client = new Socket();
>
>
>  PrintWriter s_out = null;*/
>
>  client.connect(new InetSocketAddress("localhost", 6789));
>
>  OutputStream outToServer = client.getOutputStream();
>  DataOutputStream out = new DataOutputStream(outToServer);
>  System.out.println("After Dataoutput stream");
>  out.writeBytes("Content gets received in server\n");
>
>  client.close();
>   }
> The same piece of code works fine for Mina but does not work with Mina2. I
> am unable to figure out what is causing the problem. Do I need to add some
> parameters in the from clause of Camel.
>
> Kindly help.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-not-receiving-data-using-Socket-tp5760372.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


AW: AW: camel - xsd

2014-12-10 Thread jhm
I played a little bit.

Jan


public class XmlTest extends CamelTestSupport {

@EndpointInject(uri="mock:valid")
MockEndpoint valid;

@EndpointInject(uri="mock:validationError")
MockEndpoint validationError;



@Test
public void validNewsfeed() throws Exception {
// Newsfeed contains 2 news
valid.expectedMessageCount(2);
valid.expectedMessagesMatches(
// Use helper methods from the static imported PredicateBuilder
and(
header("newsfeed.date").isEqualTo("2014.12.09 14:15"),
header("news.author").isEqualTo("Jan"),
 
body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/complex/\
"")
)  
);
// no error expected
validationError.expectedMessageCount(0);

// Read xml from classpath and send to Camel route
String xml =
IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/test/xml/
complex/validNewsfeed.xml"));
sendBody("direct:in", xml);

// 'execute' all tests
assertMockEndpointsSatisfied();
}


@Test
public void invalidXml() throws Exception {
valid.expectedMessageCount(0);
validationError.expectedMessageCount(1);

String xml = "";
sendBody("direct:in", xml);

assertMockEndpointsSatisfied();
}



@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
// Our XML uses namespaces, so we have to deal with that.
Namespaces ns = new Namespaces("news",
"http://www.materne.de/camel/test/xml/complex/";);

// XSD-invalid data goes to this endpoint
onException(ValidationException.class)
.to("mock:validationError");

from("direct:in")
// XSD-validation
 
.to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd")

// Store newsfeed data in the header before split, so we
haven't to do that on each 
// splittet news-message.
.setHeader("newsfeed.date",
ns.xpath("/news:Newsletter/@date";, String.class))

// http://camel.apache.org/splitter.html
// xtokenize() is available since Camel 2.14.
// Use the 'wrap'-mode so we keep the Newsletter-Header
.split().xtokenize("/news:Newsletter/News";, 'w', ns)

// Workaround of a bug?? in XMLTokenizerExpression
.setBody(simple("${body.replace('news:Newsletter>',
'news:Newsletter>')}"))
.setBody(simple("${body.replace('',
'news:Newsletter>')}"))

// Get some data from the splittet news
.setHeader("news.date",
ns.xpath("/news:Newsletter/News/@date";, String.class))
.setHeader("news.author",
ns.xpath("/news:Newsletter//News/@author";, String.class))

.to("mock:valid");
}
};
}

}




http://www.w3.org/2001/XMLSchema"; 
xmlns:news="http://www.materne.de/camel/test/xml/complex/";
targetNamespace="http://www.materne.de/camel/test/xml/complex/";>

























Here is a demo news.


Second news paragraph.

news:Newsletter>



> -Ursprüngliche Nachricht-
> Von: smilevasu6 [mailto:srinivas.thu...@gmail.com]
> Gesendet: Dienstag, 9. Dezember 2014 15:12
> An: users@camel.apache.org
> Betreff: Re: AW: camel - xsd
> 
> Don't mind can you give me sample code instead of link
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-
> xsd-tp5760376p5760396.html
> Sent from the Camel - Users mailing list archive at Nabble.com.