Re: Unable to throw Soap Fault
Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: > > Hi, > > Can I have a look at your Camel route? > And which camel-cxf DataFormat are you using ? > If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest > Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] > > [1]https://issues.apache.org/activemq/browse/CAMEL-2495 > > HiS wrote: >> Hi All, >> >> We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on >> Tomcat >> 6.0. A requirement is that if incoming request does not have a parameter, >> soap fault needs to be thrown. >> >> As the Fault and Out Consolidation has happened in Camel 2.0.0, I am >> creating a soap fault and setting it in the Out stream of Exchange inside >> a >> processor. >> >> SOAPMessage msg = null; >> try { >> MessageFactory factory = >> MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); >> msg = factory.createMessage(); >> SOAPBody body = msg.getSOAPBody(); >> QName qName = SOAPConstants.SOAP_SENDER_FAULT; >> >> SOAPFault soapFault = body.addFault(qName, "Test Code"); >> Detail detail = soapFault.addDetail(); >> detail.setValue("Test Description"); >> >> exchange.getOut().setFault(true); >> >> exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, >> new Integer(500)); >> exchange.getOut().setBody(body); >> >> } catch (SOAPException e) { >> e.printStackTrace(); >> } >> >> After doing this, I am not getting any exception but the soap fault is >> also >> not getting thrown, instead a Soap Envelope with empty Body is coming as >> output. >> >> Any ideas on what could be going wrong in the above? >> >> Thanks, >> Himanshu > > > -- View this message in context: http://old.nabble.com/Unable-to-throw-Soap-Fault-tp28010828p28011453.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Unable to throw Soap Fault
Hi, I'm no expert on this, but have you tried setting it as an exception instead? This is working for me: public class SoapFaultConversionProcessor implements Processor { private static final String ANONYMOUS_FAULT_STRING = "An unexpected error has occured."; private static final Logger log = LoggerFactory.getLogger( SoapFaultConversionProcessor.class ); private void processException( Exchange exchange, Exception ex, boolean rethrow ) throws Exception { if( ex instanceof SoapFault ) { SoapFault soapFault = (SoapFault)ex; if( "client".equalsIgnoreCase( soapFault.getFaultCode().getLocalPart() ) ) { log.debug( "Ignoring original client soap:fault." ); if( rethrow ) { throw ex ; } else { return ; } } } String faultMessage = ANONYMOUS_FAULT_STRING ; SoapFault fault = new SoapFault( faultMessage, SoapFault.FAULT_CODE_SERVER ); Element detail = fault.getOrCreateDetail(); Document doc = detail.getOwnerDocument(); Element corrId = doc.createElement( "CorrelationId" ); corrId.setTextContent( exchange.getExchangeId() ); detail.appendChild( corrId ); if( rethrow ) { log.debug( "Throwing new soap:fault." ); exchange.setProperty( Exchange.EXCEPTION_CAUGHT, fault); } else { log.debug( "Setting new soap:fault." ); exchange.setException( fault ); } } @Override public void process( Exchange exchange ) throws Exception { log.debug( "Checking caught exception" ); Exception caused = exchange.getProperty( Exchange.EXCEPTION_CAUGHT, Exception.class ); if( null != caused ) { log.warn( "Exception caught" ); log.warn( caused.toString() ); processException( exchange, caused, true ); } log.debug( "Checking contained exception" ); Exception ex = exchange.getException(); if( null != ex ) { log.warn( "Exception found in exchange" ); log.warn( ex.toString() ); processException( exchange, ex, false ); } } @Override public String toString() { return this.getClass().getName(); } } with: from( sourceEndpoint ) .onException( Throwable.class ).processRef( "cxfSoapFaultConversionProcessor" ).end() .loadBalance().roundRobin().to( destinationEndpoints ); ; Jim On 24/03/2010 07:30, HiS wrote: Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: Hi, Can I have a look at your Camel route? And which camel-cxf DataFormat are you using ? If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] [1]https://issues.apache.org/activemq/browse/CAMEL-2495 HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrac
Re: quartz + pollEnrich +sftp ==> 'move' parameter ignored
Hi If you want to store to a file directory directly from FTP you can use localWorkDirectory option, while causes Camel to stream directly to a temp file in the directory. But then if you do .to("file:xxx") afterwards then Camel can do a fast IO move operation. Then I assume the SFTP consumer would have better change doing the move operation afterwards. See more here http://camel.apache.org/ftp2.html On Mon, Mar 22, 2010 at 8:29 PM, Pitre, Russell wrote: > Thanks for the quick response! No luck though. I know the sftp uri works > because i can move it to the 'from' and all is well. Here's the stacktrace: > > > from("quartz://myGroup/DownloadFilesTrigger?cron=0+23+15+*+*+?"). > pollEnrich("sftp://"; + sourceLocation() + "?password=" + password + > "&move=.done"). > to("file:" + INBOX_LOCATION ); > > > > > efaultQuartzScheduler_Worker-1] EventLog INFO Event: > 67985393-5224-4834-85cc-07dbe5ff83ae exchange created: Exchange[Message: > [Body is null]] > [efaultQuartzScheduler_Worker-1] EventLog INFO Event: > 67985393-5224-4834-85cc-07dbe5ff83ae exchange Exchange[Message: > GenericFile[locations_test.xml]] sent to: file://\\dev-data\Intranet\adp\hris > took: 28 ms. > [efaultQuartzScheduler_Worker-1] EventLog INFO Event: > 67985393-5224-4834-85cc-07dbe5ff83ae exchange completed: Exchange[Message: > GenericFile[locations_test.xml]] > [ove=.done&password=x] ilePollingConsumerPollStrategy WARN Trying to > recover by disconnecting from remote server forcing a re-connect at next > poll: sftp://padprsftpshawmut...@server:22 > [efaultQuartzScheduler_Worker-1] GenericFileOnCompletion ERROR Caused > by: [org.apache.camel.component.file.GenericFileOperationFailedException - > Cannot change current directory to: /home/pADPRsftpshawmutdes] > org.apache.camel.component.file.GenericFileOperationFailedException: Cannot > change current directory to: /home/pADPRsftpshawmutdes > at > org.apache.camel.component.file.remote.SftpOperations.changeCurrentDirectory(SftpOperations.java:289) > at > org.apache.camel.component.file.remote.SftpOperations.buildDirectory(SftpOperations.java:244) > at > org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:85) > at > org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:72) > at > org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:122) > at > org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:83) > at > org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:52) > at > org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:145) > at > org.apache.camel.processor.UnitOfWorkProcessor.done(UnitOfWorkProcessor.java:82) > at > org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:71) > at > org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48) > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) > at > org.apache.camel.processor.loadbalancer.QueueLoadBalancer.process(QueueLoadBalancer.java:41) > at > org.apache.camel.component.quartz.QuartzEndpoint.onJobExecute(QuartzEndpoint.java:104) > at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:33) > at org.quartz.core.JobRunShell.run(JobRunShell.java:202) > at > org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534) > Caused by: 4: > at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1749) > at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:269) > at > org.apache.camel.component.file.remote.SftpOperations.changeCurrentDirectory(SftpOperations.java:287) > ... 16 more > Caused by: java.io.IOException: inputstream is closed > at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2325) > at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2349) > at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1730) > ... 18 more > [ove=.done&password=x] ilePollingConsumerPollStrategy WARN Consumer > Consumer[sftp://padprsftpshawmut...@server:22/OUTBOUND?move=.done&password=x] > could not poll endpoint: > sftp://padprsftpshawmut...@server:22/OUTBOUND?move=.done&password=x > caused by: Cannot list directory: OUTBOUND > org.apache.camel.component.file.GenericFileOperationFailedException: Cannot > list directory: OUTBOUND > at > org.apache.camel.component.file.remote.SftpOperations.listFiles(SftpOp
Re: Unable to throw Soap Fault
Hi, Is the from("http:requestset") a CXF endpoint or other something ? I just went through the CxfConsumer code of camel trunk, it should be able to deal with the fault message that you set in the ErrorProcessor. If you can't upgrade the Camel version, I'm afraid you need to buy a customer support, as we don't do min patch release for Camel 2.0.0. Willem HiS wrote: Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: Hi, Can I have a look at your Camel route? And which camel-cxf DataFormat are you using ? If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] [1]https://issues.apache.org/activemq/browse/CAMEL-2495 HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrace(); } After doing this, I am not getting any exception but the soap fault is also not getting thrown, instead a Soap Envelope with empty Body is coming as output. Any ideas on what could be going wrong in the above? Thanks, Himanshu
Re: Unable to throw Soap Fault
Hi, I tried setting the Soap Fault in exchange.setException() but that also is not working. Still getting the soap envelope with empty body. Just wondering if you are using camel 2.0.0 too, coz then I can be sure this issue is not due to the specific version. Thanks, Himanshu Jim Talbut wrote: > > Hi, > I'm no expert on this, but have you tried setting it as an exception > instead? > This is working for me: > public class SoapFaultConversionProcessor implements Processor > { > private static final String ANONYMOUS_FAULT_STRING = "An unexpected > error has occured."; > private static final Logger log = LoggerFactory.getLogger( > SoapFaultConversionProcessor.class ); > > private void processException( Exchange exchange, Exception ex, > boolean rethrow ) throws Exception > { > if( ex instanceof SoapFault ) > { > SoapFault soapFault = (SoapFault)ex; > if( "client".equalsIgnoreCase( > soapFault.getFaultCode().getLocalPart() ) ) > { > log.debug( "Ignoring original client soap:fault." ); > if( rethrow ) > { > throw ex ; > } > else > { > return ; > } > } > } > String faultMessage = ANONYMOUS_FAULT_STRING ; > SoapFault fault = new SoapFault( faultMessage, > SoapFault.FAULT_CODE_SERVER ); > Element detail = fault.getOrCreateDetail(); > Document doc = detail.getOwnerDocument(); > Element corrId = doc.createElement( "CorrelationId" ); > corrId.setTextContent( exchange.getExchangeId() ); > > detail.appendChild( corrId ); > if( rethrow ) > { > log.debug( "Throwing new soap:fault." ); > exchange.setProperty( Exchange.EXCEPTION_CAUGHT, fault); > } > else > { > log.debug( "Setting new soap:fault." ); > exchange.setException( fault ); > } > } > > @Override > public void process( Exchange exchange ) throws Exception > { > log.debug( "Checking caught exception" ); > Exception caused = exchange.getProperty( > Exchange.EXCEPTION_CAUGHT, Exception.class ); > if( null != caused ) > { > log.warn( "Exception caught" ); > log.warn( caused.toString() ); > processException( exchange, caused, true ); > } > > log.debug( "Checking contained exception" ); > Exception ex = exchange.getException(); > if( null != ex ) > { > log.warn( "Exception found in exchange" ); > log.warn( ex.toString() ); > processException( exchange, ex, false ); > } > } > > @Override > public String toString() > { > return this.getClass().getName(); > } > > } > > with: > from( sourceEndpoint ) > .onException( Throwable.class ).processRef( > "cxfSoapFaultConversionProcessor" ).end() > .loadBalance().roundRobin().to( > destinationEndpoints ); > ; > > Jim > > > On 24/03/2010 07:30, HiS wrote: >> Hi Willem, >> >> Thanks for your response. >> I am having the following groovy route: >> >> from("http:requestset") >> .onException(Exception.class) >>.handled(true) >>.processRef('ErrorProcessor').end() >> .process(new ValidateRequestProcessor()); >> >> Here the 'ValidateRequestProcessor' validates the request and on finding >> missing parameter throws an exception. The exception is caught by the >> 'ErrorProcessor' where the code for returning soap fault is written. >> >> We are using PAYLOAD DataFormat for camel-cxf but could not migrate to >> Camel >> 2.3.0 due to other dependencies. >> >> Is there any workaround to the issue which can be used to return the soap >> fault (I saw examples of using setFaultBody in the route but that also >> did >> not seem to work) ? >> >> Thanks, >> Himanshu >> >> >> willem.jiang wrote: >> >>> Hi, >>> >>> Can I have a look at your Camel route? >>> And which camel-cxf DataFormat are you using ? >>> If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest >>> Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] >>> >>> [1]https://issues.apache.org/activemq/browse/CAMEL-2495 >>> >>> HiS wrote: >>> Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = n
Re: Unable to throw Soap Fault
Hi, For generalization I had written the endpoint as ("http:requestset"), but this is actually a custom endpoint which internally uses CXF to create the web-service endpoint. Its working fine when sending normal response but only when soap fault needs to be returned does is not work. We can't migrate to the latest camel but wanted to fix this problem in the current version, can I use CXF interceptors to send soap fault? Thanks, Himanshu willem.jiang wrote: > > Hi, > > Is the from("http:requestset") a CXF endpoint or other something ? > I just went through the CxfConsumer code of camel trunk, it should be > able to deal with the fault message that you set in the ErrorProcessor. > > If you can't upgrade the Camel version, I'm afraid you need to buy a > customer support, as we don't do min patch release for Camel 2.0.0. > > Willem > > > HiS wrote: >> Hi Willem, >> >> Thanks for your response. >> I am having the following groovy route: >> >> from("http:requestset") >>.onException(Exception.class) >> .handled(true) >> .processRef('ErrorProcessor').end() >> .process(new ValidateRequestProcessor()); >> >> Here the 'ValidateRequestProcessor' validates the request and on finding >> missing parameter throws an exception. The exception is caught by the >> 'ErrorProcessor' where the code for returning soap fault is written. >> >> We are using PAYLOAD DataFormat for camel-cxf but could not migrate to >> Camel >> 2.3.0 due to other dependencies. >> >> Is there any workaround to the issue which can be used to return the soap >> fault (I saw examples of using setFaultBody in the route but that also >> did >> not seem to work) ? >> >> Thanks, >> Himanshu >> >> >> willem.jiang wrote: >>> Hi, >>> >>> Can I have a look at your Camel route? >>> And which camel-cxf DataFormat are you using ? >>> If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest >>> Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] >>> >>> [1]https://issues.apache.org/activemq/browse/CAMEL-2495 >>> >>> HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrace(); } After doing this, I am not getting any exception but the soap fault is also not getting thrown, instead a Soap Envelope with empty Body is coming as output. Any ideas on what could be going wrong in the above? Thanks, Himanshu >>> >>> >> > > > -- View this message in context: http://old.nabble.com/Unable-to-throw-Soap-Fault-tp28010828p28012624.html Sent from the Camel - Users mailing list archive at Nabble.com.
Problems with paths.
Hi - this might not be strictly Camel question but here goes: I'm having some problems finding handling different paths when working with files in Camel: from("file://data/in/inbox?move=data/in/backup/${date:now:MMddhh}/${file:name}")...etc I have a standard Eclipse project with /bin and /src. Next to these i have /data, /settings and /schemas. So, when I run the above route Camel reads from the correct directory but then wants to create from the read position, so I get /data/in/inbox/data/in/backup/etc instead og /data/in/inbox. This can be corrected with ../../../ but that's not really elegant - what to do? I'm also trying to use the new PropertiesComponent in Camel 2.3.0 and I have troubles reaching the correct directory there too. PropertiesComponent pc = new PropertiesComponent(); pc.setLocation("settings/opsigclient.properties"); This is not working I get an exception saying that this directory cannot be found on the classpath. It works if I move the settings directory inside the java-package where the .class files are placed. -- View this message in context: http://old.nabble.com/Problems-with-paths.-tp28013388p28013388.html Sent from the Camel - Users mailing list archive at Nabble.com.
JMS send Timeout
Hi, I have an HTTP endpoint that submits messages to an ActiveMQ queue. When the consumer gets slow, the Queue is throttled and the HTTP call hangs infinitely. Is there a way to tell the broker that if a JMS message is not accepted within a timeout, the exchange is interrupted and the HTTP endpoint returns an HTTP error? I tried RequestTimeout but that does not seem to do what I expected. HttpEndpoint httpEndpoint = (HttpEndpoint) endpoint("jetty:http://0.0.0.0:8162/queue";); JmsEndpoint topic = (JmsEndpoint) endpoint("activemq:topic:MyTopic"); topic.setReceiveTimeout(5000); topic.setRequestTimeout(5000); from(httpEndpoint).inOnly(topic); Regards, Leen
Re: JMS send Timeout
Maybe, you should consider to use an async route : http://camel.apache.org/asynchronous-processing.html Kind regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com twitter : http://twitter.com/cmoulliard Linkedlin : http://www.linkedin.com/in/charlesmoulliard Apache Camel Group : http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm On Wed, Mar 24, 2010 at 12:16 PM, Leen Toelen wrote: > Hi, > > I have an HTTP endpoint that submits messages to an ActiveMQ queue. > When the consumer gets slow, the Queue is throttled and the HTTP call > hangs infinitely. Is there a way to tell the broker that if a JMS > message is not accepted within a timeout, the exchange is interrupted > and the HTTP endpoint returns an HTTP error? I tried RequestTimeout > but that does not seem to do what I expected. > > HttpEndpoint httpEndpoint = (HttpEndpoint) > endpoint("jetty:http://0.0.0.0:8162/queue";); > > JmsEndpoint topic = (JmsEndpoint) endpoint("activemq:topic:MyTopic"); > topic.setReceiveTimeout(5000); > topic.setRequestTimeout(5000); > > from(httpEndpoint).inOnly(topic); > > Regards, > Leen >
Re: Not able to invoke webservice using http component
Hi, thanks for the reply. I did not changed the input soap message into Document and directly sent it. I got the soap message reply in the form of String. The reply is as follows http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>http://tutorial.com";>Hello Harbeer Kadian Now i want to read this output and change it into java objects, just like what a webservice client do. Do there are any standard api to do this. Or I have to use some sort of XQuery or XSLT Transformer to get the soap body. With Regards Harbeer Kadian willem.jiang wrote: > > Yes, if you want to send a request from camel-http endpoint, you just > need put the a Sting, InputStream or HttpEntity into to the message > body, otherwise camel-http endponit may not send right request to the > service. > > Willem > > ychawla wrote: >> Hi Habeer, >> Do you need to do the DOM conversions that you are doing: >> >> Document input = xmlConverter.toDOMDocument(soapMessage); >> exchange.getIn().setBody(input); >> >> Can't you just set the body to be a string? >> >> Same with the return message. That might be tripping something up. >> Also, >> are you able to get to your webservice using a browser/basic auth: >> >> http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin >> >> When I was first setting up a web service connection through HTTP, I set >> up >> a polling folder and result folder and got that working first. I just >> made >> the entire soap message in a text editor which it looks like you already >> have. Then you can set up a simple route to test for web service >> connectivity: >> >> >> > uri="http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin"; >> /> >> >> >> Cheers, >> Yogesh >> >> >> Harbeer Kadian wrote: >>> Hi, >>> >>> I deployed a simple webservice on TomCat Server. >>> I created following route to access the webservice using apache camel. >>> >>> from("direct:ProducerUri") >>> .to("http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin";); >>> >>> I created the exchange in the following way >>> String soapMessage = ">> xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; >>> xmlns:tut=\"http://tutorial.com\";>" >>> + "Harbeer Kadian" + >>> ""; >>> XmlConverter xmlConverter = new XmlConverter(); >>> >>> Document input = xmlConverter.toDOMDocument(soapMessage); >>> exchange.getIn().setBody(input); >>> exchange.setPattern(ExchangePattern.InOut); >>> //added this line after seeing no soapAction found error on Tom Cat >>> Server >>> log >>> exchange.getIn().setHeader("SOAPAction", ""); >>> exchange = producerTemplate.send("direct:ProducerUri", exchange); >>> Document output = (Document)exchange.getOut().getBody(); >>> System.out.println(output); >>> >>> I am getting null as output. >>> Also on the tom cat server log, no exception is coming. >>> >>> I have no idea how to invoke webservice using http component. >>> Please help me. >>> >>> With Regards >>> Harbeer Kadian >>> >>> >> > > > -- View this message in context: http://old.nabble.com/Not-able-to-invoke-webservice-using-http-component-tp28001459p28013965.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problems with paths.
The move options is relative to where the file was picked up. But the game changes when you use ${ } Read more at - Fine grained control over Move and PreMove option http://camel.apache.org/file2.html On Wed, Mar 24, 2010 at 11:52 AM, ankelee wrote: > > Hi - this might not be strictly Camel question but here goes: > > I'm having some problems finding handling different paths when working with > files in Camel: > > from("file://data/in/inbox?move=data/in/backup/${date:now:MMddhh}/${file:name}")...etc > > I have a standard Eclipse project with /bin and /src. Next to these i have > /data, /settings and /schemas. > > So, when I run the above route Camel reads from the correct directory but > then wants to create from the read position, so I get > /data/in/inbox/data/in/backup/etc instead og /data/in/inbox. This can be > corrected with ../../../ but that's not really elegant - what to do? > > I'm also trying to use the new PropertiesComponent in Camel 2.3.0 and I have > troubles reaching the correct directory there too. > > PropertiesComponent pc = new PropertiesComponent(); > pc.setLocation("settings/opsigclient.properties"); > > This is not working I get an exception saying that this directory cannot be > found on the classpath. It works if I move the settings directory inside the > java-package where the .class files are placed. > -- > View this message in context: > http://old.nabble.com/Problems-with-paths.-tp28013388p28013388.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: Unable to throw Soap Fault
I'm afraid CXF interceptor can help you to do that,as we setup some customer interceptor when the camel-cxf endpoint working in PAYLOAD dataformat. Can you try the latest Camel to see if the Error still there? BTW, is there any stack trace in the log that can help us trace the issue ? Willem HiS wrote: Hi, For generalization I had written the endpoint as ("http:requestset"), but this is actually a custom endpoint which internally uses CXF to create the web-service endpoint. Its working fine when sending normal response but only when soap fault needs to be returned does is not work. We can't migrate to the latest camel but wanted to fix this problem in the current version, can I use CXF interceptors to send soap fault? Thanks, Himanshu willem.jiang wrote: Hi, Is the from("http:requestset") a CXF endpoint or other something ? I just went through the CxfConsumer code of camel trunk, it should be able to deal with the fault message that you set in the ErrorProcessor. If you can't upgrade the Camel version, I'm afraid you need to buy a customer support, as we don't do min patch release for Camel 2.0.0. Willem HiS wrote: Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: Hi, Can I have a look at your Camel route? And which camel-cxf DataFormat are you using ? If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] [1]https://issues.apache.org/activemq/browse/CAMEL-2495 HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrace(); } After doing this, I am not getting any exception but the soap fault is also not getting thrown, instead a Soap Envelope with empty Body is coming as output. Any ideas on what could be going wrong in the above? Thanks, Himanshu
Re: Not able to invoke webservice using http component
Hi, You can try to use the soap dataformat[1] which is new to Camel 2.3.0. And you need to download the Camel 2.3.0-SNAPSHOT for it. [1]http://camel.apache.org/soap.html Willem Harbeer Kadian wrote: Hi, thanks for the reply. I did not changed the input soap message into Document and directly sent it. I got the soap message reply in the form of String. The reply is as follows http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> xmlns="http://tutorial.com";>Hello Harbeer Kadian Now i want to read this output and change it into java objects, just like what a webservice client do. Do there are any standard api to do this. Or I have to use some sort of XQuery or XSLT Transformer to get the soap body. With Regards Harbeer Kadian willem.jiang wrote: Yes, if you want to send a request from camel-http endpoint, you just need put the a Sting, InputStream or HttpEntity into to the message body, otherwise camel-http endponit may not send right request to the service. Willem ychawla wrote: Hi Habeer, Do you need to do the DOM conversions that you are doing: Document input = xmlConverter.toDOMDocument(soapMessage); exchange.getIn().setBody(input); Can't you just set the body to be a string? Same with the return message. That might be tripping something up. Also, are you able to get to your webservice using a browser/basic auth: http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin When I was first setting up a web service connection through HTTP, I set up a polling folder and result folder and got that working first. I just made the entire soap message in a text editor which it looks like you already have. Then you can set up a simple route to test for web service connectivity: http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin"; /> Cheers, Yogesh Harbeer Kadian wrote: Hi, I deployed a simple webservice on TomCat Server. I created following route to access the webservice using apache camel. from("direct:ProducerUri") .to("http://localhost:8095/WebServiceTutorial/services/Hello?username=admin&password=admin";); I created the exchange in the following way String soapMessage = "http://schemas.xmlsoap.org/soap/envelope/\"; xmlns:tut=\"http://tutorial.com\";>" + "Harbeer Kadian" + ""; XmlConverter xmlConverter = new XmlConverter(); Document input = xmlConverter.toDOMDocument(soapMessage); exchange.getIn().setBody(input); exchange.setPattern(ExchangePattern.InOut); //added this line after seeing no soapAction found error on Tom Cat Server log exchange.getIn().setHeader("SOAPAction", ""); exchange = producerTemplate.send("direct:ProducerUri", exchange); Document output = (Document)exchange.getOut().getBody(); System.out.println(output); I am getting null as output. Also on the tom cat server log, no exception is coming. I have no idea how to invoke webservice using http component. Please help me. With Regards Harbeer Kadian
Re: Unable to throw Soap Fault
I think it is hard to workaround the problem. If you can rebuild just the camel-cxf component yourself, you can merge the fix (the change is quite small). Please make sure you pick up https://issues.apache.org/activemq/browse/CAMEL-2544 too. Willem Jiang wrote: I'm afraid CXF interceptor can help you to do that,as we setup some customer interceptor when the camel-cxf endpoint working in PAYLOAD dataformat. Can you try the latest Camel to see if the Error still there? BTW, is there any stack trace in the log that can help us trace the issue ? Willem HiS wrote: Hi, For generalization I had written the endpoint as ("http:requestset"), but this is actually a custom endpoint which internally uses CXF to create the web-service endpoint. Its working fine when sending normal response but only when soap fault needs to be returned does is not work. We can't migrate to the latest camel but wanted to fix this problem in the current version, can I use CXF interceptors to send soap fault? Thanks, Himanshu willem.jiang wrote: Hi, Is the from("http:requestset") a CXF endpoint or other something ? I just went through the CxfConsumer code of camel trunk, it should be able to deal with the fault message that you set in the ErrorProcessor. If you can't upgrade the Camel version, I'm afraid you need to buy a customer support, as we don't do min patch release for Camel 2.0.0. Willem HiS wrote: Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: Hi, Can I have a look at your Camel route? And which camel-cxf DataFormat are you using ? If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] [1]https://issues.apache.org/activemq/browse/CAMEL-2495 HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrace(); } After doing this, I am not getting any exception but the soap fault is also not getting thrown, instead a Soap Envelope with empty Body is coming as output. Any ideas on what could be going wrong in the above? Thanks, Himanshu
Re: Unable to throw Soap Fault
BTW, CAMEL-2544 and CAMEL-2495 are issues for throwing Application SOAP Fault when the CXF endpoint is in PAYLOAD mode and no SEI (serviceClass) is provided. William Tam wrote: I think it is hard to workaround the problem. If you can rebuild just the camel-cxf component yourself, you can merge the fix (the change is quite small). Please make sure you pick up https://issues.apache.org/activemq/browse/CAMEL-2544 too. Willem Jiang wrote: I'm afraid CXF interceptor can help you to do that,as we setup some customer interceptor when the camel-cxf endpoint working in PAYLOAD dataformat. Can you try the latest Camel to see if the Error still there? BTW, is there any stack trace in the log that can help us trace the issue ? Willem HiS wrote: Hi, For generalization I had written the endpoint as ("http:requestset"), but this is actually a custom endpoint which internally uses CXF to create the web-service endpoint. Its working fine when sending normal response but only when soap fault needs to be returned does is not work. We can't migrate to the latest camel but wanted to fix this problem in the current version, can I use CXF interceptors to send soap fault? Thanks, Himanshu willem.jiang wrote: Hi, Is the from("http:requestset") a CXF endpoint or other something ? I just went through the CxfConsumer code of camel trunk, it should be able to deal with the fault message that you set in the ErrorProcessor. If you can't upgrade the Camel version, I'm afraid you need to buy a customer support, as we don't do min patch release for Camel 2.0.0. Willem HiS wrote: Hi Willem, Thanks for your response. I am having the following groovy route: from("http:requestset") .onException(Exception.class) .handled(true) .processRef('ErrorProcessor').end() .process(new ValidateRequestProcessor()); Here the 'ValidateRequestProcessor' validates the request and on finding missing parameter throws an exception. The exception is caught by the 'ErrorProcessor' where the code for returning soap fault is written. We are using PAYLOAD DataFormat for camel-cxf but could not migrate to Camel 2.3.0 due to other dependencies. Is there any workaround to the issue which can be used to return the soap fault (I saw examples of using setFaultBody in the route but that also did not seem to work) ? Thanks, Himanshu willem.jiang wrote: Hi, Can I have a look at your Camel route? And which camel-cxf DataFormat are you using ? If you are using PAYLOAD DataFormat, I'm afraid you need to use Latest Camel 2.3.0 SNAPSHOT. As William Tam just added a enhancement for it[1] [1]https://issues.apache.org/activemq/browse/CAMEL-2495 HiS wrote: Hi All, We are using CXF 2.2.3 with Camel 2.0.0 for exposing an end-point on Tomcat 6.0. A requirement is that if incoming request does not have a parameter, soap fault needs to be thrown. As the Fault and Out Consolidation has happened in Camel 2.0.0, I am creating a soap fault and setting it in the Out stream of Exchange inside a processor. SOAPMessage msg = null; try { MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); msg = factory.createMessage(); SOAPBody body = msg.getSOAPBody(); QName qName = SOAPConstants.SOAP_SENDER_FAULT; SOAPFault soapFault = body.addFault(qName, "Test Code"); Detail detail = soapFault.addDetail(); detail.setValue("Test Description"); exchange.getOut().setFault(true); exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500)); exchange.getOut().setBody(body); } catch (SOAPException e) { e.printStackTrace(); } After doing this, I am not getting any exception but the soap fault is also not getting thrown, instead a Soap Envelope with empty Body is coming as output. Any ideas on what could be going wrong in the above? Thanks, Himanshu
Re: JMS send Timeout
Hi, what I would like as a result is that the HTTP generates a 200 OK as soon as possible, and if the ActiveMQ queue is being throttled I generate a 503 Service Temporarily Unavailable. Regards, Leen On Wed, Mar 24, 2010 at 12:23 PM, Charles Moulliard wrote: > Maybe, you should consider to use an async route : > http://camel.apache.org/asynchronous-processing.html > > Kind regards, > > Charles Moulliard > Senior Enterprise Architect > Apache Camel Committer > > * > blog : http://cmoulliard.blogspot.com > twitter : http://twitter.com/cmoulliard > Linkedlin : http://www.linkedin.com/in/charlesmoulliard > > Apache Camel Group : > http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm > > > On Wed, Mar 24, 2010 at 12:16 PM, Leen Toelen wrote: > >> Hi, >> >> I have an HTTP endpoint that submits messages to an ActiveMQ queue. >> When the consumer gets slow, the Queue is throttled and the HTTP call >> hangs infinitely. Is there a way to tell the broker that if a JMS >> message is not accepted within a timeout, the exchange is interrupted >> and the HTTP endpoint returns an HTTP error? I tried RequestTimeout >> but that does not seem to do what I expected. >> >> HttpEndpoint httpEndpoint = (HttpEndpoint) >> endpoint("jetty:http://0.0.0.0:8162/queue";); >> >> JmsEndpoint topic = (JmsEndpoint) endpoint("activemq:topic:MyTopic"); >> topic.setReceiveTimeout(5000); >> topic.setRequestTimeout(5000); >> >> from(httpEndpoint).inOnly(topic); >> >> Regards, >> Leen >> >
Re: JMS send Timeout
On Wed, Mar 24, 2010 at 3:31 PM, Leen Toelen wrote: > Hi, > > what I would like as a result is that the HTTP generates a 200 OK as > soon as possible, and if the ActiveMQ queue is being throttled I > generate a 503 Service Temporarily Unavailable. > You have to ask at AMQ forum as its about its connection which can live reconnect and whatnot. There are some options you can set to adjust for that. Also something about sendAsync=false to have it return with fail faster. But all those options and whatnot is what the AMQ people know about. > Regards, > Leen > > On Wed, Mar 24, 2010 at 12:23 PM, Charles Moulliard > wrote: >> Maybe, you should consider to use an async route : >> http://camel.apache.org/asynchronous-processing.html >> >> Kind regards, >> >> Charles Moulliard >> Senior Enterprise Architect >> Apache Camel Committer >> >> * >> blog : http://cmoulliard.blogspot.com >> twitter : http://twitter.com/cmoulliard >> Linkedlin : http://www.linkedin.com/in/charlesmoulliard >> >> Apache Camel Group : >> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm >> >> >> On Wed, Mar 24, 2010 at 12:16 PM, Leen Toelen wrote: >> >>> Hi, >>> >>> I have an HTTP endpoint that submits messages to an ActiveMQ queue. >>> When the consumer gets slow, the Queue is throttled and the HTTP call >>> hangs infinitely. Is there a way to tell the broker that if a JMS >>> message is not accepted within a timeout, the exchange is interrupted >>> and the HTTP endpoint returns an HTTP error? I tried RequestTimeout >>> but that does not seem to do what I expected. >>> >>> HttpEndpoint httpEndpoint = (HttpEndpoint) >>> endpoint("jetty:http://0.0.0.0:8162/queue";); >>> >>> JmsEndpoint topic = (JmsEndpoint) endpoint("activemq:topic:MyTopic"); >>> topic.setReceiveTimeout(5000); >>> topic.setRequestTimeout(5000); >>> >>> from(httpEndpoint).inOnly(topic); >>> >>> Regards, >>> Leen >>> >> > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
FileConsumer always reads the data in system charset/encoding
Hi, I have a camel application deployed on RHEL5 with a default encoding/locale of UTF-8 I have to download data from a remote Windows server (CP1251 or ISO-8859-1/latin-1) My route breaks down the processing of the files into two steps: 1 - download 2 - consume and pass split/tokenized String/bytes to POJOs for further processing. My problem stems from the fact that I don't seem to have control over the charset that the FileConsumer uses as it converts the file into a String. The data contains encoded chars which are corrupted if the data is read as UTF-8 instead of as ISO-8859-1. I have a simple test case of a file encoded as ISO-8859-1 and I can read it with a specific charset and this allows me to process the data without corruption. If I read it as UTF-8, the data is corrupted. Is there any way I can instruct each of my FileConsumer endpoints to consume the file using a specific charset/encoding? I cannot change the locale on the server to fix this as other files must be read as UTF-8, not ISO-8859-1 I've looked at the camel source code and the way that camel consumes files seems to rely on some kind of type coercion: in FileBinding: public void loadContent(Exchange exchange, GenericFile file) throws IOException { try { content = exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, file.getFile()); } catch (NoTypeConversionAvailableException e) { throw IOHelper.createIOException("Cannot load file content: " + file.getAbsoluteFilePath(), e); } } Is this the code that actually consumes the file and creates the message, or should I be looking elsewhere? I'm trying to add a property to GenericFileEndpoint that will allow me to set a parameter via the uri : file://target/encoded/?charsetEncoding=ISO-8859-1 Thanks, Kev
Re: FileConsumer always reads the data in system charset/encoding
Hi Use .convertBodyTo(String.class, "utf-8") after the from(file:xxx) to control the charset used for encoding. On Wed, Mar 24, 2010 at 4:25 PM, Kevin Jackson wrote: > Hi, > > I have a camel application deployed on RHEL5 with a default > encoding/locale of UTF-8 > > I have to download data from a remote Windows server (CP1251 or > ISO-8859-1/latin-1) > > My route breaks down the processing of the files into two steps: > 1 - download > 2 - consume and pass split/tokenized String/bytes to POJOs for further > processing. > > My problem stems from the fact that I don't seem to have control over > the charset that the FileConsumer uses as it converts the file into a > String. The data contains encoded chars which are corrupted if the > data is read as UTF-8 instead of as ISO-8859-1. > > I have a simple test case of a file encoded as ISO-8859-1 and I can > read it with a specific charset and this allows me to process the data > without corruption. If I read it as UTF-8, the data is corrupted. > > Is there any way I can instruct each of my FileConsumer endpoints to > consume the file using a specific charset/encoding? I cannot change > the locale on the server to fix this as other files must be read as > UTF-8, not ISO-8859-1 > > I've looked at the camel source code and the way that camel consumes > files seems to rely on some kind of type coercion: > > in FileBinding: > public void loadContent(Exchange exchange, GenericFile file) > throws IOException { > try { > content = > exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, > file.getFile()); > } catch (NoTypeConversionAvailableException e) { > throw IOHelper.createIOException("Cannot load file > content: " + file.getAbsoluteFilePath(), e); > } > } > > Is this the code that actually consumes the file and creates the > message, or should I be looking elsewhere? I'm trying to add a > property to GenericFileEndpoint that will allow me to set a parameter > via the uri : > file://target/encoded/?charsetEncoding=ISO-8859-1 > > Thanks, > Kev > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: FileConsumer always reads the data in system charset/encoding
Hi, > Use > .convertBodyTo(String.class, "utf-8") after the from(file:xxx) to > control the charset used for encoding. Fantastic - should have asked earlier before digging through the src - C'est la vie Kev
Re: error-handling advice with queues
I'll give this a shot. Can you give me a quick example or point me to a sample that does something similar (ex. setting a header in code, performing conditional logic in a route based on a header). -JF Allen Lau-2 wrote: > > I could be wrong here, but you could easily stick the "error" object as > part > of the message header. As long as your components > understand that header, you can easily retrieve it and only send that > portion to an error queue. > > The default message headers in Camel is defined as > > Map headers; > > so basically you can stuff whatever you want into it. > > > On Tue, Mar 23, 2010 at 4:02 PM, jfaath wrote: > >> >> I'm not sure that would work. As I stated in my original post, I don't >> want >> to send the entire message to the error queue, just the portion that was >> invalid. So, if my original message has, say, 11 readings, and 3 of them >> are bad, I only want to send the 3 bad ones to the error queue. During >> processing, I stick the bad readings into an "error object". It's the >> contents of this object (that I can easily marshal to XML) that I want to >> send to the queue. >> >> FYI, here is a simplified version of my route: >> >> >> from("jetty:http://0.0.0.0:8282/process";).convertBodyTo(String.class) >>.inOnly("jms:queue:data.inbound") >>.unmarshal(jaxbDf) >>.beanRef("dataProcessor", "process") >> >> >> Allen Lau-2 wrote: >> > >> > How about just setting a header when you are done processing and there >> is >> > an >> > error? >> > >> > Then in your route, just send any message to the error queue when the >> > header >> > is detected. >> > >> > On Tue, Mar 23, 2010 at 11:57 AM, jfaath wrote: >> > >> >> >> >> I'm looking for some advice on how to deal with errors during a large >> >> processing task. It seems like it should be simple but I'm having >> >> trouble >> >> figuring out what to do. >> >> >> >> I have an HTTP endpoint that receives XML messages then sticks them in >> a >> >> processing queue. From the queue, they get unmarshalled into JAXB >> >> objects >> >> and then processed by a Java class. Now, the messages consist or a >> large >> >> number of readings. Some may be good, some may be bad. The good ones >> >> get >> >> processed, but the bad ones are stuffed into a JAXB object. >> >> >> >> When the processing is done, I'd like to throw this object on an error >> >> queue >> >> (or, marshal then throw on the queue). But I can't figure out how to >> do >> >> this the best way. The processing class should exit gracefully so I >> >> don't >> >> want to throw a final exception. >> >> >> >> What might be the best way to do this? Can I add the error object to >> a >> >> queue programmatically within the processor? Can the processor return >> >> the >> >> error object so I can throw it on the queue via the route? Is there a >> >> nice >> >> and easy way to do this? >> >> >> >> Thanks, >> >> >> >> JF >> >> -- >> >> View this message in context: >> >> >> http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28005566.html >> >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28008395.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28016879.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: FileConsumer always reads the data in system charset/encoding
Hi, Here is my route: http://camel.apache.org/schema/spring";> The file is encoded as iso-8859-1, the locale on the system is utf-8 I think the file consumer is reading the data incorrectly *before* I can convert it with , the FileConsumer is reading the data as UTF-8 when it should be reading as ISO-8859-1 Annoyingly iconv -f ISO-8859-1 -t UTF-8 works perfectly and converts the characters correctly - I really don't want to have to shell out to iconv to perform conversion before consuming the file, but at the moment it seems to be the sanest way of dealing with this problem Thanks, Kev
Re: FileConsumer always reads the data in system charset/encoding
No it does not read the file beforehand. Use Tracer to see the Message Body. And you have not stated which version of Camel you are using, despite its highlighted on the how to get support page http://camel.apache.org/support.html Also you should check JIRA etc if there was a known issue with it For example: https://issues.apache.org/activemq/browse/CAMEL-2387 On Wed, Mar 24, 2010 at 5:37 PM, Kevin Jackson wrote: > Hi, > > Here is my route: > > http://camel.apache.org/schema/spring";> > > uri="file:///tmp?preMove=.inprogress&move=.done&moveFailed=.error&delay=400&noop=false"/> > > > > > > > > > > > > > > > > > > > > > > The file is encoded as iso-8859-1, the locale on the system is utf-8 > > I think the file consumer is reading the data incorrectly *before* I > can convert it with , the FileConsumer is reading the > data as UTF-8 when it should be reading as ISO-8859-1 > > Annoyingly iconv -f ISO-8859-1 -t UTF-8 works perfectly and > converts the characters correctly - I really don't want to have to > shell out to iconv to perform conversion before consuming the file, > but at the moment it seems to be the sanest way of dealing with this > problem > > Thanks, > Kev > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: error-handling advice with queues
Look at these pages for samples. http://camel.apache.org/splitter.html http://camel.apache.org/content-based-router.html I would most likely create a POJO to split the message up and then use the content base router to route the message. On Wed, Mar 24, 2010 at 9:04 AM, jfaath wrote: > > I'll give this a shot. Can you give me a quick example or point me to a > sample that does something similar (ex. setting a header in code, > performing > conditional logic in a route based on a header). > > -JF > > > Allen Lau-2 wrote: > > > > I could be wrong here, but you could easily stick the "error" object as > > part > > of the message header. As long as your components > > understand that header, you can easily retrieve it and only send that > > portion to an error queue. > > > > The default message headers in Camel is defined as > > > > Map headers; > > > > so basically you can stuff whatever you want into it. > > > > > > On Tue, Mar 23, 2010 at 4:02 PM, jfaath wrote: > > > >> > >> I'm not sure that would work. As I stated in my original post, I don't > >> want > >> to send the entire message to the error queue, just the portion that was > >> invalid. So, if my original message has, say, 11 readings, and 3 of > them > >> are bad, I only want to send the 3 bad ones to the error queue. During > >> processing, I stick the bad readings into an "error object". It's the > >> contents of this object (that I can easily marshal to XML) that I want > to > >> send to the queue. > >> > >> FYI, here is a simplified version of my route: > >> > >> > >> from("jetty:http://0.0.0.0:8282/process";).convertBodyTo(String.class) > >>.inOnly("jms:queue:data.inbound") > >>.unmarshal(jaxbDf) > >>.beanRef("dataProcessor", "process") > >> > >> > >> Allen Lau-2 wrote: > >> > > >> > How about just setting a header when you are done processing and there > >> is > >> > an > >> > error? > >> > > >> > Then in your route, just send any message to the error queue when the > >> > header > >> > is detected. > >> > > >> > On Tue, Mar 23, 2010 at 11:57 AM, jfaath wrote: > >> > > >> >> > >> >> I'm looking for some advice on how to deal with errors during a large > >> >> processing task. It seems like it should be simple but I'm having > >> >> trouble > >> >> figuring out what to do. > >> >> > >> >> I have an HTTP endpoint that receives XML messages then sticks them > in > >> a > >> >> processing queue. From the queue, they get unmarshalled into JAXB > >> >> objects > >> >> and then processed by a Java class. Now, the messages consist or a > >> large > >> >> number of readings. Some may be good, some may be bad. The good > ones > >> >> get > >> >> processed, but the bad ones are stuffed into a JAXB object. > >> >> > >> >> When the processing is done, I'd like to throw this object on an > error > >> >> queue > >> >> (or, marshal then throw on the queue). But I can't figure out how to > >> do > >> >> this the best way. The processing class should exit gracefully so I > >> >> don't > >> >> want to throw a final exception. > >> >> > >> >> What might be the best way to do this? Can I add the error object to > >> a > >> >> queue programmatically within the processor? Can the processor > return > >> >> the > >> >> error object so I can throw it on the queue via the route? Is there > a > >> >> nice > >> >> and easy way to do this? > >> >> > >> >> Thanks, > >> >> > >> >> JF > >> >> -- > >> >> View this message in context: > >> >> > >> > http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28005566.html > >> >> Sent from the Camel - Users mailing list archive at Nabble.com. > >> >> > >> >> > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28008395.html > >> Sent from the Camel - Users mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28016879.html > Sent from the Camel - Users mailing list archive at Nabble.com. > >
Re: FileConsumer always reads the data in system charset/encoding
Hi, > No it does not read the file beforehand. > > Use Tracer to see the Message Body. > And you have not stated which version of Camel you are using, despite > its highlighted on the how to get support page > http://camel.apache.org/support.html > > Also you should check JIRA etc if there was a known issue with it > For example: > https://issues.apache.org/activemq/browse/CAMEL-2387 I am currently using 2.1, I will upgrade to 2.2 and see if this resolves the issue for me Sorry to post without following the 'How to ask sensible questions' rule. /me contrite Kev
Re: FileConsumer always reads the data in system charset/encoding
Hi, To clear this whole thing up - I can now report that everything is working as expected, the problem was (and still is) with Spring's transactional test support, not rolling back the data that my processing is adding to the database. This meant that I was checking against an old value in the db and getting a test failure - the correct value was also in the db. So the problem has moved from Camel to Spring @Transactional, which is quite interesting as it works for other tests, just not this particular one. Thanks for the help and I will not post unless I have exhausted the other possibilities. Kev
Building camel from source deletes C:\Temp\*
Hi, Building camel from source on Windows (Vista 64 bit) deletes everything in C:\Temp\* I think it's one of the unit tests but a quick look hasn't shown up which. That is a major bad thing for it to do - it's deleted lots of things from my machine that I did not want to lose. Jim
Re: onException()
thnaks for the help - it works. Only problem: if connection to toUri fails, MyErrorhandler is invoked; but if connection to fromUri fails, MyErrorHandler not invoked! for example, from("file://a.log").onException(Exception.class).process(MyErrHandler).to("ftp://u...@server?";).end() is working if I cant connect to ftp server; but from("ftp://u...@server?";).onException(Exception.class).process(MyErrHandler).to("file://a.log").end() not invoking MyErrHandler if server not online. why this difference in behavior? Claus Ibsen-2 wrote: > > Hi > > onException should be set right after from. So you route should be > >from(fromUri) > .onException(Exception.class).process(new > MyErrorHandler(fromUri)).end(); > .to(toUri); > > And you can use .toF to pass arguments (like String.format). Or its > simply just Java so you can do .to("xxx" + "?yyy=zzz"); > > > On Tue, Mar 23, 2010 at 11:43 PM, /U wrote: >> >> Camel: 2.2.0: >> >> i have route builder which adds a route as follows with a >> deadLetterChannel >> as a fallback error handler and an onException fork: >> >> >> errorHandler(deadLetterChannel("bean:myBean?method=processError")); >> // >> from(fromUri).to(toUri).end(). >> onException(Exception.class).process(new >> MyErrorHandler(fromUri)).stop(); >> >> >> Problem is: when the message cannot be routed to the destination endpoint >> (say, because the endpoint URI is not reachable) >> the onException nominated ErrorHandler is never invoked; instead the >> deadLetterChannel() >> is invoked. This would be fine except for the fact that I need an >> application context >> in the error handler for cleanup: while I am able to pass the required >> context to my >> onException error handler (as shown above), I am not sure how to do that >> with the >> deadLetterChannel. >> >> Questions: >> - why isn't onException() method invoked? >> - is there a way to pass an arbitrary data to a bean which is used as >> an >> endpoint. Eg: >> to("bean:myBean?method=processError&arg="+fromUri) >> >> regardds, >> >> /U >> >> -- >> View this message in context: >> http://old.nabble.com/onException%28%29-tp28008233p28008233.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > > > -- > Claus Ibsen > Apache Camel Committer > > Author of Camel in Action: http://www.manning.com/ibsen/ > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus > > -- View this message in context: http://old.nabble.com/onException%28%29-tp28008233p28022280.html Sent from the Camel - Users mailing list archive at Nabble.com.
Possible cause of slow
Dear All I have strange problem in Camel. I use routingSlip like the following: ... ... There was no problem before in flowing in a 4-endpoint routing slip. But now, the third of the endpoints is visited 30s-38s since last endpoint is visited. What are the possible causes? This are the details: header InvokerEndpointList: q1, q2, q3, q4 This is the way I log my time for all queues above. ... The fact is q3timeGetIn - q2timeGetOut >= 30s Why this happens? Thanks -- ~The best men are men who benefit to others http://michsan.web.id Yang berkualitas memang beda rasanya! http://rizqi-cookies.com
How to invoke specific operation with params for cxf webservice endpoint through configuration
I have the following cxfEndpoint configuration in the camel-context.xml which is a webservice end point, pointing to a 3rd party web service. I am wondering how I can specify (in this configuration) an operation with parameters to be passed to the webservice? As an example, I need to invoke the operation sayHello() in that webservice, passing two parameters (firstName, lastName). Can I do that in the cxfEndPoint itself? If so, how? Also, how can I pass the values itself? http://localhost:8080/someService/"; wsdlURL="../sr-binding/src/main/resources/META-INF/wsdl/someservice.wsdl" endpointName="s:myEndpointName" serviceName="s:myService" xmlns:s="urn:some:company:some:service:wsdl" > OR do I have to write a client code on my side (where this end point points to)? -- View this message in context: http://old.nabble.com/How-to-invoke-specific-operation-with-params-for-cxf-webservice-endpoint-through-configuration-tp28023138p28023138.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: onException()
Hi, The exception handler (MyErrorHandler) only comes into play once the file is read and routed to the to(destinationURI). The exception handler cannot come into play if there is a problem setting up a Consumer connection in the from(sourceURI). This is natural since if there is a problem with setting up the ftp connection the sourceURI, the route will not be started by the camelcontext. Hope this helps. Cheers, Ashwin... /U wrote: > > thnaks for the help - it works. Only problem: > if connection to toUri fails, MyErrorhandler is > invoked; but if connection to fromUri fails, > MyErrorHandler not invoked! > > for example, > > from("file://a.log").onException(Exception.class).process(MyErrHandler).end(). > to("ftp://u...@server?";).end() > is working if I cant connect to ftp server; but > > > from("ftp://u...@server?";).onException(Exception.class).process(MyErrHandler).end(). > to("file://a.log").end() > not invoking MyErrHandler if server not online. > > why this difference in behavior? > > > Claus Ibsen-2 wrote: >> >> Hi >> >> onException should be set right after from. So you route should be >> >>from(fromUri) >> .onException(Exception.class).process(new >> MyErrorHandler(fromUri)).end(); >> .to(toUri); >> >> And you can use .toF to pass arguments (like String.format). Or its >> simply just Java so you can do .to("xxx" + "?yyy=zzz"); >> >> >> On Tue, Mar 23, 2010 at 11:43 PM, /U wrote: >>> >>> Camel: 2.2.0: >>> >>> i have route builder which adds a route as follows with a >>> deadLetterChannel >>> as a fallback error handler and an onException fork: >>> >>> >>> >>> errorHandler(deadLetterChannel("bean:myBean?method=processError")); >>> // >>> from(fromUri).to(toUri).end(). >>> onException(Exception.class).process(new >>> MyErrorHandler(fromUri)).stop(); >>> >>> >>> Problem is: when the message cannot be routed to the destination >>> endpoint >>> (say, because the endpoint URI is not reachable) >>> the onException nominated ErrorHandler is never invoked; instead the >>> deadLetterChannel() >>> is invoked. This would be fine except for the fact that I need an >>> application context >>> in the error handler for cleanup: while I am able to pass the required >>> context to my >>> onException error handler (as shown above), I am not sure how to do that >>> with the >>> deadLetterChannel. >>> >>> Questions: >>> - why isn't onException() method invoked? >>> - is there a way to pass an arbitrary data to a bean which is used as >>> an >>> endpoint. Eg: >>> to("bean:myBean?method=processError&arg="+fromUri) >>> >>> regardds, >>> >>> /U >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/onException%28%29-tp28008233p28008233.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >>> >>> >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> >> > > - --- Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence Progress Software Corporation 14 Oak Park Drive Bedford, MA 01730 --- +1-972-304-9084 (Office) +1-972-971-1700 (Mobile) Blog: http://opensourceknowledge.blogspot.com/ -- View this message in context: http://old.nabble.com/onException%28%29-tp28008233p28023140.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to invoke specific operation with params for cxf webservice endpoint through configuration
Hi, You do need to create a client to invoke on the CXF endpoint and send a SOAP payload that can be used to call your method described in WSDL. If you do not want to write a client you could use a tool like SoapUI to do this for you (since you already have the WSDL). Cheers, Ashwin... usha K. wrote: > > I have the following cxfEndpoint configuration in the camel-context.xml > which is a webservice end point, pointing to a 3rd party web service. > > I am wondering how I can specify (in this configuration) an operation > with parameters to be passed to the webservice? As an example, I need to > invoke the operation sayHello() in that webservice, passing two parameters > (firstName, lastName). > > Can I do that in the cxfEndPoint itself? If so, how? Also, how can I pass > the values itself? > > address="http://localhost:8080/someService/"; > wsdlURL="../sr-binding/src/main/resources/META-INF/wsdl/someservice.wsdl" > endpointName="s:myEndpointName" > serviceName="s:myService" > xmlns:s="urn:some:company:some:service:wsdl" > > > > > > > OR do I have to write a client code on my side (where this end point > points to)? > - --- Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence Progress Software Corporation 14 Oak Park Drive Bedford, MA 01730 --- +1-972-304-9084 (Office) +1-972-971-1700 (Mobile) Blog: http://opensourceknowledge.blogspot.com/ -- View this message in context: http://old.nabble.com/How-to-invoke-specific-operation-with-params-for-cxf-webservice-endpoint-through-configuration-tp28023138p28023141.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: onException()
On Wed, Mar 24, 2010 at 11:30 PM, /U wrote: > > thnaks for the help - it works. Only problem: > if connection to toUri fails, MyErrorhandler is > invoked; but if connection to fromUri fails, > MyErrorHandler not invoked! > > for example, > > from("file://a.log").onException(Exception.class).process(MyErrHandler).to("ftp://u...@server?";).end() > is working if I cant connect to ftp server; but > > > from("ftp://u...@server?";).onException(Exception.class).process(MyErrHandler).to("file://a.log").end() > not invoking MyErrHandler if server not online. > > why this difference in behavior? > Read chapter 5 in the Camel in Action book which explains error handling in great details. And see PollingConsumerPollStrategy if you want to do some custom code if the "from" fails http://camel.apache.org/polling-consumer.html > > Claus Ibsen-2 wrote: >> >> Hi >> >> onException should be set right after from. So you route should be >> >> from(fromUri) >> .onException(Exception.class).process(new >> MyErrorHandler(fromUri)).end(); >> .to(toUri); >> >> And you can use .toF to pass arguments (like String.format). Or its >> simply just Java so you can do .to("xxx" + "?yyy=zzz"); >> >> >> On Tue, Mar 23, 2010 at 11:43 PM, /U wrote: >>> >>> Camel: 2.2.0: >>> >>> i have route builder which adds a route as follows with a >>> deadLetterChannel >>> as a fallback error handler and an onException fork: >>> >>> >>> errorHandler(deadLetterChannel("bean:myBean?method=processError")); >>> // >>> from(fromUri).to(toUri).end(). >>> onException(Exception.class).process(new >>> MyErrorHandler(fromUri)).stop(); >>> >>> >>> Problem is: when the message cannot be routed to the destination endpoint >>> (say, because the endpoint URI is not reachable) >>> the onException nominated ErrorHandler is never invoked; instead the >>> deadLetterChannel() >>> is invoked. This would be fine except for the fact that I need an >>> application context >>> in the error handler for cleanup: while I am able to pass the required >>> context to my >>> onException error handler (as shown above), I am not sure how to do that >>> with the >>> deadLetterChannel. >>> >>> Questions: >>> - why isn't onException() method invoked? >>> - is there a way to pass an arbitrary data to a bean which is used as >>> an >>> endpoint. Eg: >>> to("bean:myBean?method=processError&arg="+fromUri) >>> >>> regardds, >>> >>> /U >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/onException%28%29-tp28008233p28008233.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >>> >>> >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> >> > > -- > View this message in context: > http://old.nabble.com/onException%28%29-tp28008233p28022280.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus