Re: [HTTP4] HttpProducer close temporary file in CachedOutputStream

2012-08-07 Thread alexey-s
Thank you, Willem.
I'm in a catch block forgot to send the resulting error (IOException e) on
the top.

Aleksey



--
View this message in context: 
http://camel.465427.n5.nabble.com/HTTP4-HttpProducer-close-temporary-file-in-CachedOutputStream-tp5716885p5716907.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Need Help converting XML-CSV(flatfile)

2012-08-07 Thread Matheen
hello,

I just stared out with camel...i have done few basic examples

Now i'm trying to convert XML data to CSV. 

Thanks in advance.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Need-Help-converting-XML-CSV-flatfile-tp5716908.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [HTTP4] HttpProducer close temporary file in CachedOutputStream

2012-08-07 Thread Willem Jiang
Don't worry, I'm already take care of it.
I will commit the patch once I finish to run the whole tests rightly.

Willem

On Tue, Aug 7, 2012 at 2:30 PM, alexey-s alex...@mail.ru wrote:
 Thank you, Willem.
 I'm in a catch block forgot to send the resulting error (IOException e) on
 the top.

 Aleksey



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/HTTP4-HttpProducer-close-temporary-file-in-CachedOutputStream-tp5716885p5716907.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Need Help converting XML-CSV(flatfile)

2012-08-07 Thread Henryk Konsek
Hi,

 I just stared out with camel...i have done few basic examples

 Now i'm trying to convert XML data to CSV.

Please share what have you done so far :) .

Which components, data format, etc. are you trying to use? There have
you stuck? How does your route look like?

Best regards.

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


Re: Access to LDAP search results

2012-08-07 Thread helander
Hi Henryk,

thank you very much for the provided example.


/Lars



--
View this message in context: 
http://camel.465427.n5.nabble.com/Access-to-LDAP-search-results-tp5716883p5716914.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Error in DefaultServicePool on Netty Producer Queue is full

2012-08-07 Thread philippe.suray
Hello,

Here is a small test case. I am not familiar with camel testing, I hope my
test is correct.
I try to send 100 messages to a tcp endpoint and forward it to another tcp
endpoint. I don't know how to intercept the error, but if you turn the
logging to DEBUG, you have this error:

[New I/O  worker #9] ServerChannelHandler   DEBUG
Incoming message: 99
[New I/O  worker #9] SendProcessor  DEBUG 
Endpoint[mock://incoming] Exchange[Message: 99]
[New I/O  worker #9] MockEndpoint   DEBUG
mock://incoming  99 : Exchange[Message: 99] with body: 99 and
headers:{breadcrumbId=ID-jack-5708-1344355497315-0-696,
CamelNettyRemoteAddress=/127.0.0.1:5713,
CamelNettyChannelHandlerContext=org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext@c736e4,
CamelNettyMessageEvent=[id: 0x0058cca9, /127.0.0.1:5713 = /127.0.0.1:6520]
RECEIVED: 99}
[New I/O  worker #9] SendProcessor  DEBUG 
Endpoint[tcp://localhost:233] Exchange[Message: 99]
[New I/O  worker #9] NettyProducer  DEBUG
Writing body: 99

[   New I/O  worker #41] ClientChannelHandler   DEBUG
Closing channel as an exception was thrown from Netty
java.lang.IllegalStateException: Queue full
at java.util.AbstractQueue.add(AbstractQueue.java:71)[:1.6.0_26]
at
java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:209)[:1.6.0_26]
at
org.apache.camel.impl.DefaultServicePool.release(DefaultServicePool.java:96)[camel-core-2.10.0.jar:2.10.0]
at
org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:304)[camel-core-2.10.0.jar:2.10.0]
at
org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:125)[camel-core-2.10.0.jar:2.10.0]
at
org.apache.camel.component.netty.handlers.ClientChannelHandler.messageReceived(ClientChannelHandler.java:162)[camel-netty-2.10.0.jar:2.10.0]
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:71)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:423)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:404)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:268)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:91)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:373)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:247)[netty-3.5.1.Final.jar:]
at
org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)[netty-3.5.1.Final.jar:]
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_26]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_26]

I noted that if I replace codecallback.done(false);/code by
codecallback.done(true);/code, the error disappears.


package test;


import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.camel.AsyncCallback;
import org.apache.camel.AsyncProcessor;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class NettyTest extends CamelTestSupport {

@Test
public void testConcurrentProducers() throws Exception {
doSendMessages(100, 2);
}

private void doSendMessages(int files, int poolSize) throws Exception {
getMockEndpoint(mock:forward).expectedMessageCount(100);

ExecutorService executor = Executors.newFixedThreadPool(poolSize);
MapInteger, Futurelt;String responses = new
ConcurrentHashMapInteger, Futurelt;String();
for (int i = 0; i  files; i++) {
final int index = i;
FutureString out = executor.submit(new CallableString() {
public String call() throws Exception {
return

Connection pooling with camel-amqp

2012-08-07 Thread helander
I have tried to get a working solution for connection pooling/caching with
camel-amqp.

I found some examples that used the Spring CachingConnectionFactory, but
when using that it get an NPE.

The first time I do a write to a queue, it works, but subsequent writes
causes an NPE.
It looks like the NPE is associated with finding and existing/cached
destination.

Any kind of help on this would be most valuable.

Thanks 

Lars



--
View this message in context: 
http://camel.465427.n5.nabble.com/Connection-pooling-with-camel-amqp-tp5716936.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Jetty consumer restricting methods

2012-08-07 Thread Mark Webb
I am using Jetty for a Camel consumer on a couple routes.  I would
like to limit only GET methods for one route and PUT for another
route.  Is this possible or do I need to set up some kind of
filter/processor to do this?  I don't see anything in the
documentation to support this functionality.

Thanks,
Mark


Re: Connection pooling with camel-amqp

2012-08-07 Thread michal.warecki
Hi helander,

Can you paste the code responsible for pooling?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Connection-pooling-with-camel-amqp-tp5716936p5716939.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Connection pooling with camel-amqp

2012-08-07 Thread helander
This is part of an OSGi blueprint xml file.




bean id=myConnectionFactory
class=org.apache.qpid.client.AMQConnectionFactory
argument
value=amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'
/ 
/bean

bean id=cachingConnectionFactory
class=org.springframework.jms.connection.CachingConnectionFactory
property name=targetConnectionFactory 
ref=myConnectionFactory/
/bean



bean id=mybroker 
class=org.apache.camel.component.amqp.AMQPComponent
property name=connectionFactory 
ref=cachingConnectionFactory/
property name=cacheLevel value=2/  
/bean




camelContext xmlns=http://camel.apache.org/schema/blueprint;
 endpoint id=queue23 uri=mybroker:queue:Q_23/
 route
from uri=direct-vm:q_23 /
to ref=queue23 /
 /route
/camelContext




/Lars



--
View this message in context: 
http://camel.465427.n5.nabble.com/Connection-pooling-with-camel-amqp-tp5716936p5716941.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Consuming a remote FTP server triggered by a route in Camel 2.9

2012-08-07 Thread vishal1981
Hi,
In the older documentation for FTP component I found this,
Consuming a remote FTP server triggered by a route
The FTP consumer is built as a scheduled consumer to be used in the from
route. However if you want to start consuming from a FTP server triggered
within a route it's a bit cumbersome to do this in Camel 1.x (we plan to
improve this in Camel 2.x). However it's possible as this code below
demonstrates.

This is exactly what I want to do i.e. Consume on demand and not poll.
But I cannot find any such improvement/support in 2.x. Was the support
added? Am I missing something?

Thanks in advance,
V



--
View this message in context: 
http://camel.465427.n5.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-in-Camel-2-9-tp5716940.html
Sent from the Camel - Users mailing list archive at Nabble.com.


TransactedErrorHandler requeue JMS message to DLQ

2012-08-07 Thread marnold
Camel Users,

I'm using Camel 2.9.0.  I have the following route:

route id=test
from uri=jms:queue:queue.test /
to uri=jms:queue:queue.someQueue/
process ref=testProcess/
to uri=jms:queue:queue.someOtherQueue/
/route

Where testProcess always throws an exception. For testing purposes!

My goal is to achieve the following: (i) if process fails, the enqueue to
'queue.someQueue' should always be rolled-back; (ii)  if process fails,
Camel should retry the route a configurable maximum number of times; (iii)
If the route fails the maximum number of times, the initial message dequeued
from 'queue.test' should be enqueued onto a dead-letter queue so that the
next message on 'queue.test' can be processed.

My understanding is that this should be a 'transacted' route, and that I
should use a TransactedErrorHandler.  I have read the documentation here:
http://camel.apache.org/transactionerrorhandler.html

But I'm afraid I cannot understand this rather intimidating sentence: When
the ValidationException is thrown from the validate order bean it is
intercepted by the TransactionErrorHandler and it let the
onException(ValidationException.class handle it so the Exchange is routed to
this route and since we use handled(true) then the original exception is
lowered (= cleared) and we transform the message into a fixed response that
are returned to jetty endpoint that returns it to the original caller.

If anyone could offer an explanation, help or advice, or point out an
example that acheives something similar to my desired behaviour, I would be
very appreciative. 

We are using ActiveMQ as our JMS implementation, but would rather keep this
JMS implementation non-specific.

Thanks.








--
View this message in context: 
http://camel.465427.n5.nabble.com/TransactedErrorHandler-requeue-JMS-message-to-DLQ-tp5716945.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Node count in camel

2012-08-07 Thread Deepthi
Hi,

Is there a way to find number of nodes in a given xml in camel using spring.
For Eg: We have the following xml:
order
  item1/item
  item2/item
  item3/item
/order

I want to know the number of item tags in order tag and store it in header
name say itemCount.
I am using camel 2.8.0

Is this possible?

Thanks,
Deepthi



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


Re: Connection pooling with camel-amqp

2012-08-07 Thread michal.warecki
Can you paste your stacktrace also?

If your stacktrace looks like this:
Exception in thread Thread-5 java.lang.NullPointerException
at org.apache.qpid.client.AMQDestination.equals(AMQDestination.java:577)
at
org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.destinationEquals(CachingConnectionFactory.java:467)
at
org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.equals(CachingConnectionFactory.java:474)
at java.util.HashMap.get(HashMap.java:385)
at
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.getCachedProducer(CachingConnectionFactory.java:353)
at
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:320)
at $Proxy1.createProducer(Unknown Source)

this is a QPID bug:
https://issues.apache.org/jira/browse/QPID-3760



--
View this message in context: 
http://camel.465427.n5.nabble.com/Connection-pooling-with-camel-amqp-tp5716936p5716947.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Node count in camel

2012-08-07 Thread michal.warecki
There is count function in XPath. As I know Saxon can handle this function.



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


Re: exposing different operations under same service in camel + cxf routing.

2012-08-07 Thread michal.warecki
I think you should create central route and next use content based router.
Name of current operation is stored in header CxfConstants.OPERATION_NAME.

Something like this:
from(...cxf...)
.choice()
   
.when(header(CxfConstants.OPERATION_NAME).isEqualTo(operationA))
.to(direct:operationARoute)
   
.when(header(CxfConstants.OPERATION_NAME).isEqualTo(operationB))
.to(direct:operationBRoute)
.otherwise()
.to(direct:unsupportedOperation);



--
View this message in context: 
http://camel.465427.n5.nabble.com/exposing-different-operations-under-same-service-in-camel-cxf-routing-tp5716944p5716950.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Connection pooling with camel-amqp

2012-08-07 Thread Lars-Erik Helander
Michal,

my stack trace is more or less identical (java source line numbers are not 
identical).

Do you have any idea how to work around this, patch qpid code or other 
solution? Creation of new connection and destination validation on each 
operation introduces significant overhead.  I turned on debug logging and went 
thru the timing - and found out how much overhead there is :(.

Thanks for finding the bug.

/Lars

Skickat från min iPhone

7 aug 2012 kl. 22:39 skrev michal.warecki michal.ware...@gmail.com:

 Can you paste your stacktrace also?
 
 If your stacktrace looks like this:
 Exception in thread Thread-5 java.lang.NullPointerException
at org.apache.qpid.client.AMQDestination.equals(AMQDestination.java:577)
at
 org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.destinationEquals(CachingConnectionFactory.java:467)
at
 org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.equals(CachingConnectionFactory.java:474)
at java.util.HashMap.get(HashMap.java:385)
at
 org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.getCachedProducer(CachingConnectionFactory.java:353)
at
 org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:320)
at $Proxy1.createProducer(Unknown Source)
 
 this is a QPID bug:
 https://issues.apache.org/jira/browse/QPID-3760
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Connection-pooling-with-camel-amqp-tp5716936p5716947.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


exposing same REST service as both GET and POST

2012-08-07 Thread javakurious
Based on the example in  http://camel.apache.org/cxfrs.html cxfrs example
with camel , I created a REST service exposed as GET operation. Here is the
overview of what I have so far :

REST endpoint in Camel:
cxf:rsServer id=custmoer-rest-get-server
  address=/ serviceClass=com.personal.test.impl.CustomerGETImpl/

And the corresponding resource class used to configure the endpoint...

CustomerGETImpl
@GET
@Path(/Customer)
@Produces(text/xml)
@Override
public Response getCustomer(@QueryParam(CustomerName) String
customerName) 
}

It works fine. 

My question is if I have to expose the same service as POST as well, what do
I have to do ? 

I did the following :

1)Added additional REST endpoint in Camel:
cxf:rsServer id=custmoer-rest-get-server
  address=/ serviceClass=com.personal.test.impl.CustomerGETImpl/
cxf:rsServer id=custmoer-rest-post-server
  address=/ serviceClass=com.personal.test.impl.CustomerPOSTImpl/

2)Created a new corresponding resource class used to configure the
endpoint...

CustomerPOSTImpl
@POST
@Path(/Customer)
@Produces(text/xml)
@Override
public Response getCustomer(@FormParam(CustomerName) String
customerName) 
}

If I deploy this configuration, the POST works but GET return status 405. 

Can anybody shed some light on what I am doing wrong. 

Thanks





--
View this message in context: 
http://camel.465427.n5.nabble.com/exposing-same-REST-service-as-both-GET-and-POST-tp5716952.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty consumer restricting methods

2012-08-07 Thread Willem jiang
Hi,

It's typical Content Base Route, you can define the route like this

from(jetty://address1)
.choice()
 
.when(header(CamelHttpMethod).isEqualTo(GET)).to(direct:doSomeThing)
 .otherwise().to(direct:bye).stop()
.end()
// keep on processing

-- 
Willem Jiang



On Wednesday, August 8, 2012 at 1:20 AM, Mark Webb wrote:

 I am using Jetty for a Camel consumer on a couple routes. I would
 like to limit only GET methods for one route and PUT for another
 route. Is this possible or do I need to set up some kind of
 filter/processor to do this? I don't see anything in the
 documentation to support this functionality.
 
 Thanks,
 Mark
 
 




Re: TransactedErrorHandler requeue JMS message to DLQ

2012-08-07 Thread Willem jiang
First I want to ask work MessageExchangePattern are you using.
I don't think you can do it with InOut MEP, as it more complicated then the 
InOnly.

The TransactionHandler will rollback the transaction when the exception is 
thrown, 
as you testProcess is behind the someQueue endpoint, if you need to make sure 
the transaction token will not be change. You can find some explanation here[1]

[1]http://camel.apache.org/transactional-client.html

-- 
Willem Jiang



On Wednesday, August 8, 2012 at 3:37 AM, marnold wrote:

 Camel Users,
 
 I'm using Camel 2.9.0. I have the following route:
 
 route id=test
 from uri=jms:queue:queue.test /
 to uri=jms:queue:queue.someQueue/
 process ref=testProcess/
 to uri=jms:queue:queue.someOtherQueue/
 /route
 
 Where testProcess always throws an exception. For testing purposes!
 
 My goal is to achieve the following: (i) if process fails, the enqueue to
 'queue.someQueue' should always be rolled-back; (ii) if process fails,
 Camel should retry the route a configurable maximum number of times; (iii)
 If the route fails the maximum number of times, the initial message dequeued
 from 'queue.test' should be enqueued onto a dead-letter queue so that the
 next message on 'queue.test' can be processed.
 
 My understanding is that this should be a 'transacted' route, and that I
 should use a TransactedErrorHandler. I have read the documentation here:
 http://camel.apache.org/transactionerrorhandler.html
 
 But I'm afraid I cannot understand this rather intimidating sentence: When
 the ValidationException is thrown from the validate order bean it is
 intercepted by the TransactionErrorHandler and it let the
 onException(ValidationException.class handle it so the Exchange is routed to
 this route and since we use handled(true) then the original exception is
 lowered (= cleared) and we transform the message into a fixed response that
 are returned to jetty endpoint that returns it to the original caller.
 
 If anyone could offer an explanation, help or advice, or point out an
 example that acheives something similar to my desired behaviour, I would be
 very appreciative. 
 
 We are using ActiveMQ as our JMS implementation, but would rather keep this
 JMS implementation non-specific.
 
 Thanks.
 
 
 
 
 
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/TransactedErrorHandler-requeue-JMS-message-to-DLQ-tp5716945.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).
 
 




Re: Node count in camel

2012-08-07 Thread Deepthi
Hi Michal,

I am trying to give in the following manner:
filter
  xpathcount(/order/item)/xpath
/filter

It is not working. Where am i going wrong?



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


How to set parameter dynamically in uri

2012-08-07 Thread Deepthi
Hi,

I am trying to set parameter dynamically in uri in the following manner:
  camel:route
camel:from
uri=file://[folder path] /
camel:setHeader headerName=id
   
camel:xpath/order/item/id/camel:xpath
/camel:setHeader
camel:to
   
uri=http://localhost:9002/rest/{id}/RestService; /
/camel:route 

Is this the right way to set the parameter? If not, how can I achieve this?
I am using camel 2.8.0.




--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-set-parameter-dynamically-in-uri-tp5716959.html
Sent from the Camel - Users mailing list archive at Nabble.com.