Re: Saga EIP // copying data from the point of failure into compensation flow

2020-09-10 Thread Alex Dettinger
Not on the top of my mind. Maybe, it's worth creating a ticket to add such
a feature.

On Thu, Sep 10, 2020 at 6:42 PM Reji Mathews  wrote:

> Thanks for the suggestion. I tried it and noted that only parameters from
> exchange outside the saga scope can be mapped using options. Is there any
> way I can get exchange object which failed inside the saga scope?
>
> Cheers
> Reji
>
> On Tue, Sep 8, 2020 at 4:38 PM Alex Dettinger 
> wrote:
>
> > Hi Reji,
> >
> >   I've never tested but it remind me about option:
> >
> >
> https://camel.apache.org/components/latest/eips/saga-eip.html#_using_custom_identifiers_and_options
> >
> > hth,
> > Alex
> >
> > On Tue, Sep 8, 2020 at 9:48 PM Reji Mathews 
> wrote:
> >
> > > Hello community
> > >
> > > I was wondering if there is a way to retain the exchange data from the
> > > point of failure in a Saga EIP. Find the following route
> > > I have simulated an error right after parsing data from the
> create-order
> > > api. I need to use the same in compensation flow to undo the order
> > > creation.
> > > Logs show that the value of header orderId never trickled down to
> > > compensation flow.
> > >
> > > from("jetty:http://0.0.0.0:8081/testtxn?httpMethodRestrict=GET
> > > ").streamCaching()
> > > .log("received http trigger")
> > >
> > >
> >
> .saga().compensation("direct:rollback").propagation(SagaPropagation.REQUIRES_NEW)
> > > .log("creating fresh order")
> > > .setBody(constant("{ \"item_code\" : \"XAH504004\",
> > > \"item_qty\" : 10 }"))
> > > .setHeader(Exchange.CONTENT_TYPE,
> > constant("application/json"))
> > > .setHeader(Exchange.HTTP_METHOD, constant("POST"))
> > > .setHeader(Exchange.HTTP_URI,
> > > constant("http://localhost:8000/orders;))
> > > .to("http:dummyhost")
> > > .log("order api response ${body}")
> > > .setHeader("orderId",
> jsonpath("$.businessObject.order_id"))
> > > .throwException(new Exception("This is a simulated
> > > error")) // simulating a failure
> > > .end();
> > >
> > > from("direct:rollback")
> > > .log("saga transaction failed. deleting order
> > ${headers.orderId}")
> > > .setHeader(Exchange.HTTP_URI,
> > > simple("http://localhost:8000/orders/${headers.orderId};))
> > > .setHeader(Exchange.HTTP_METHOD, constant("DELETE"))
> > > .to("http:dummyhost")
> > > .log("compensation call response ${body}")
> > > .end();
> > >
> > >
> > >
> > > Logs
> > >
> > > 
> > >
> > > 2020-09-08 15:35:55.832  INFO 80448 --- [nio-8000-exec-2]
> > > o.s.web.servlet.DispatcherServlet: Completed initialization in
> > > 11 ms
> > > 2020-09-08 15:35:57.054  INFO 80448 --- [ qtp18025156-26] route1
> > > : api response
> > >
> > >
> >
> {"message":"success","businessObject":{"order_id":"43657a09-5c32-4303-9b14-73ab03e4e086","item_code":"XAH504004","item_qty":10}}
> > > 2020-09-08 15:35:57.065 ERROR 80448 --- [ qtp18025156-26]
> > > o.a.camel.processor.DefaultErrorHandler  : Failed delivery for
> > > (MessageId: ID-5CG7324CR4-1599593718571-0-4 on ExchangeId:
> > > ID-5CG7324CR4-1599593718571-0-1). Exhausted after delivery attempt: 1
> > > caught: java.lang.Exception: This is a simulated error
> > >
> > > Message History
> > >
> > >
> >
> ---
> > > RouteId  ProcessorId  Processor
> > > Elapsed (ms)
> > > [route1] [route1]
> > > [jetty:http://0.0.0.0:8081/testtxn?httpMethodRestrict=GET
> > > ] [  1373]
> > > [route1] [log1  ] [log
> > >   ] [ 3]
> > > [route1] [output1   ]
> >

Re: Saga EIP // copying data from the point of failure into compensation flow

2020-09-08 Thread Alex Dettinger
Hi Reji,

  I've never tested but it remind me about option:
https://camel.apache.org/components/latest/eips/saga-eip.html#_using_custom_identifiers_and_options

hth,
Alex

On Tue, Sep 8, 2020 at 9:48 PM Reji Mathews  wrote:

> Hello community
>
> I was wondering if there is a way to retain the exchange data from the
> point of failure in a Saga EIP. Find the following route
> I have simulated an error right after parsing data from the create-order
> api. I need to use the same in compensation flow to undo the order
> creation.
> Logs show that the value of header orderId never trickled down to
> compensation flow.
>
> from("jetty:http://0.0.0.0:8081/testtxn?httpMethodRestrict=GET
> ").streamCaching()
> .log("received http trigger")
>
> .saga().compensation("direct:rollback").propagation(SagaPropagation.REQUIRES_NEW)
> .log("creating fresh order")
> .setBody(constant("{ \"item_code\" : \"XAH504004\",
> \"item_qty\" : 10 }"))
> .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> .setHeader(Exchange.HTTP_METHOD, constant("POST"))
> .setHeader(Exchange.HTTP_URI,
> constant("http://localhost:8000/orders;))
> .to("http:dummyhost")
> .log("order api response ${body}")
> .setHeader("orderId", jsonpath("$.businessObject.order_id"))
> .throwException(new Exception("This is a simulated
> error")) // simulating a failure
> .end();
>
> from("direct:rollback")
> .log("saga transaction failed. deleting order ${headers.orderId}")
> .setHeader(Exchange.HTTP_URI,
> simple("http://localhost:8000/orders/${headers.orderId};))
> .setHeader(Exchange.HTTP_METHOD, constant("DELETE"))
> .to("http:dummyhost")
> .log("compensation call response ${body}")
> .end();
>
>
>
> Logs
>
> 
>
> 2020-09-08 15:35:55.832  INFO 80448 --- [nio-8000-exec-2]
> o.s.web.servlet.DispatcherServlet: Completed initialization in
> 11 ms
> 2020-09-08 15:35:57.054  INFO 80448 --- [ qtp18025156-26] route1
> : api response
>
> {"message":"success","businessObject":{"order_id":"43657a09-5c32-4303-9b14-73ab03e4e086","item_code":"XAH504004","item_qty":10}}
> 2020-09-08 15:35:57.065 ERROR 80448 --- [ qtp18025156-26]
> o.a.camel.processor.DefaultErrorHandler  : Failed delivery for
> (MessageId: ID-5CG7324CR4-1599593718571-0-4 on ExchangeId:
> ID-5CG7324CR4-1599593718571-0-1). Exhausted after delivery attempt: 1
> caught: java.lang.Exception: This is a simulated error
>
> Message History
>
> ---
> RouteId  ProcessorId  Processor
> Elapsed (ms)
> [route1] [route1]
> [jetty:http://0.0.0.0:8081/testtxn?httpMethodRestrict=GET
> ] [  1373]
> [route1] [log1  ] [log
>   ] [ 3]
> [route1] [output1   ]
> [saga[compensation:direct:rollback,propagation:REQUIRES_NEW]
> ] [ 0]
> [route1] [log2  ] [log
>   ] [ 0]
> [route1] [setBody1  ] [setBody[constant{{
> "item_code" : "XAH504004", "item_qty" : 10 }}] ] [
> 0]
> [route1] [setHeader1] [setHeader[Content-Type]
>   ] [ 0]
> [route1] [setHeader2] [setHeader[CamelHttpMethod]
>   ] [ 0]
> [route1] [setHeader3] [setHeader[CamelHttpUri]
>   ] [ 0]
> [route1] [to1   ] [http:dummyhost
>   ] [  1354]
> [route1] [log3  ] [log
>   ] [ 0]
> [route1] [setHeader4] [setHeader[orderId]
>   ] [ 6]
> [route1] [throwException1   ]
> [throwException[java.lang.Exception]
> ] [ 0]
>
> Stacktrace
>
> ---
>
> java.lang.Exception: This is a simulated error
> at
> com.reji.poc.cluster.camelclustering.routes.SimpleJdbcDBRoute.configure(SimpleJdbcDBRoute.java:32)
> ~[classes/:na]
> at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:465)
> ~[camel-core-2.25.1.jar:2.25.1]
> at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:403)
> ~[camel-core-2.25.1.jar:2.25.1]
> at
> 

Re: How to configure shutdown timeout

2020-08-18 Thread Alex Dettinger
Hi Alex,

  It seems the timeout is tuned after the context creation. One may achieve
the desired result with either:
@Override
protected void doPostSetup() throws Exception {
  context.getShutdownStrategy().setTimeout(60);
}
OR MAYBE
@Override
protected int getShutdowntimeout() {
  return 60;
}

hth,
Alex



On Tue, Aug 18, 2020 at 3:23 PM Alex Soto  wrote:

> Hello,
>
> Using Camel 3.4.0, in my unit test, I am trying to configure the shutdown
> timeout doing the following:
>
>public class MyTest extends CamelTestSupport {
> . . .
>
> @Override
> protected CamelContext createCamelContext() throws Exception {
> CamelContext result = super.createCamelContext();
>
>
> result.getExecutorServiceManager().setShutdownAwaitTermination(30_000);
> result.getShutdownStrategy().setTimeout(60);
>
> return result;
> }
>
>
> However,  I still see the default timeout of 10 seconds in the logs:
>
> 2020-08-17 20:58:16,726 [main] INFO
> org.apache.camel.impl.engine.DefaultShutdownStrategy  - Starting to
> graceful shutdown 1 routes (timeout 10 seconds)
>
> Any idea how to properly configure the shutdown timeout?
>
> Also, I would like to know how  to do it with Blueprint XML
>
>
> Best regards,
> Alex soto
>
>
>
>
>


Re: [HEADS UP] - Java 8 to be dropped

2020-06-26 Thread Alex Dettinger
Thanks for sharing Claus :)
Is the support ending at june 2021 ? Or maybe I miss something ?

On Fri, Jun 26, 2020 at 10:23 AM Claus Ibsen  wrote:

> Hi
>
> Just a heads up that from Camel 3.5 onwards we will drop Java 8 support.
>
> So this means that minimum Java version is now Java 11.
> We are also working on adding support for Java 14, but it may take a
> few releases, but its planned for the next LTS 3.7 release to have
> both Java 11 and 14 as supported.
>
> Camel 3.4.x is the LTS release that supports both Java 8 and 11, and
> its supported for 1-year (june 2022).
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


Re: How to properly handle Camel files endpoint in jUnit test

2020-06-24 Thread Alex Dettinger
Hi Jessy,

  In such a case, I would rather do something inspired from one of the
camel file test:
https://github.com/apache/camel/tree/master/core/camel-core/src/test/java/org/apache/camel/component/file

hth,
Alex

On Wed, Jun 24, 2020 at 3:00 PM Jessy Chenavas 
wrote:

> Hello,
>
> I found on your website this mailing list to ask some questions about
> Camel.
> I have some trouble making my test work, I have an endpoint that waits for
> files, and I want to test it.
> To achieve this I've created a mock of my endpoint, an exchange with the
> file and I'm sending it.
> The problem is that Camel is renaming my sended file and also removing the
> extension, the rename makes it unusable by my route (which has specific
> filters) and the removal of the extension makes it also unusable since I
> need it in my process.
>
> Here is a stackoverflow post with my test code:
>
> https://stackoverflow.com/questions/62510321/camel-mock-file-endpoint-problem-with-file-extension
>
> Am I missing something ? Some options on the exchange ?
>
> Thanks,
> Jessy CHENAVAS.
>


Re: Unable to XPath, as bean or as split with complex XML

2020-06-18 Thread Alex Dettinger
Hi Mikael,

  I've noticed that the incoming xml file is involving 2 xml namespaces
while the query looks not.
Precising namespaces in the xpath query may help to move further, something
like:
https://github.com/apache/camel/blob/master/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java#L241

hth,
Alex

On Thu, Jun 18, 2020 at 9:36 AM Mikael Andersson Wigander <
mikael.grevs...@gmail.com> wrote:

> Hi
>
> My problem is that I can’t extract some XML using xpath in Camel 3.3.0
>
> My incoming XML is complicated where my target tag  also has a
> tag further down the tree as .
>
> I have created a demo project on Github for share if someone could help
> me. https://github.com/hakuseki/xpath
>
> I have tested with a more “friendly” XML and both tests manage to retrieve
> the XML segment I want.
>
> This type of XML we get from client is based on a EU/ESMA standard.
>
> Pls advice
>
> Thx
>
> /M
>
>


Re: simple language bodyOneLine throws error

2020-06-16 Thread Alex Dettinger
Hi Shiva,

  bodyOneLine was introduced since camel 3 onward,
https://issues.apache.org/jira/browse/CAMEL-13674.
Maybe it's time to get a ride at camel 3
https://camel.apache.org/manual/latest/camel-3-migration-guide.html ;)

Alex

On Tue, Jun 16, 2020 at 9:57 AM Gv, Shivakumar 
wrote:

> Hi team,
>
> I am trying to use camel simple expression bodyOneLine  for logging
> payload in single line. But it throws below error while starting the route.
>
> Camel version= 2.23.1
>
> Code:
> .log(org.apache.camel.LoggingLevel.INFO,"Request Received :
> ${bodyOneLine}")
>
>
> Error:
> Caused by:
> org.apache.camel.language.simple.types.SimpleIllegalSyntaxException: Valid
> syntax: ${body.OGNL} was: bodyOneLine at location 19
>
> Thanks,
> Shiva
> 
> NOTICE: All information in and attached to the e-mails below may be
> proprietary, confidential, privileged and otherwise protected from improper
> or erroneous disclosure. If you are not the sender's intended recipient,
> you are not authorized to intercept, read, print, retain, copy, forward, or
> disseminate this message. If you have erroneously received this
> communication, please notify the sender immediately by phone (704-758-1000)
> or by e-mail and destroy all copies of this message electronic, paper, or
> otherwise. By transmitting documents via this email: Users, Customers,
> Suppliers and Vendors collectively acknowledge and agree the transmittal of
> information via email is voluntary, is offered as a convenience, and is not
> a secured method of communication; Not to transmit any payment information
> E.G. credit card, debit card, checking account, wire transfer information,
> passwords, or sensitive and personal information E.G. Driver's license,
> DOB, social security, or any other information the user wishes to remain
> confidential; To transmit only non-confidential information such as plans,
> pictures and drawings and to assume all risk and liability for and
> indemnify Lowe's from any claims, losses or damages that may arise from the
> transmittal of documents or including non-confidential information in the
> body of an email transmittal. Thank you.
>


Re: GsonDataFormat "useList" option?

2020-06-02 Thread Alex Dettinger
Hi Jeremy,

  It reminds me something, could you please try something like below:
https://github.com/apache/camel-quarkus/blob/master/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/JsonDataformatsRoute.java#L58..L61

hth,
Alex

On Tue, Jun 2, 2020 at 6:42 PM Jeremy Ross  wrote:

> Hi All,
>
> Is it possible to unmarshal a List of some type with the GsonDataFormat?
> JacksonDataFormat has this options, and lots others, but not seeing any
> such option for gson.
>
> Thanks!
>


Re: Problem with Spring Boot Camel application

2020-04-02 Thread Alex Dettinger
Ok, good to know that it's solved :)

On Thu, Apr 2, 2020 at 1:25 PM Gagnon, Joseph - 0553 - MITLL <
joseph.gag...@ll.mit.edu> wrote:

> Alex,
>
> I think that's what the problem was. I eventually, cleared out my local
> maven repo (.m2/repository) and then also needed to remove jars from the
> eclipse project settings.
>
> Once this was done and the project rebuilt, the problem was finally
> resolved.
>
> My guess is that the original project that was basing my code on, which I
> had downloaded, built and run, pulled in the older dependencies, resulting
> in the conflict.
>
> Thanks,
> Joe
>
> -Original Message-
> From: Alex Dettinger 
> Sent: Thursday, April 2, 2020 3:51 AM
> To: users@camel.apache.org
> Subject: Re: Problem with Spring Boot Camel application
>
> Hi Joe,
>
>   Maybe versions alignment, If I'm right mvn dependency:tree would show
> non aligned version while you should have something like camel 3.1.0 /
> spring 5.2.3.RELEASE / spring boot 2.2.4.RELEASE.
>   Checking other examples may help in this regard, they should be
> available here
> https://github.com/apache/camel-spring-boot/tree/camel-spring-boot-3.1.x/examples
> .
>
> Cheers,
> Alex
>
>
>
>
> On Wed, Apr 1, 2020 at 5:21 PM Gagnon, Joseph - 0553 - MITLL <
> joseph.gag...@ll.mit.edu> wrote:
>
> > Hello,
> >
> > I am still very new to using Apache Camel and am trying to adapt an
> > example provided by someone (
> > https://www.javainuse.com/camel/camel-consume-rest) to essentially do
> > the same thing the original application does, except by using a
> > combination of Spring Boot and Camel with XML route configuration.
> >
> > I downloaded the original application code (both the Camel consumer
> > and the HTTP server) and got those to run and execute properly very
> easily.
> >
> > Now, I want to modify the application a little so that Spring Boot is
> > used to do all the behind-the-scenes configuration, and use the XML
> > DSL to configure the Camel routes. The original Camel consumer
> > application does not use Spring at all.
> >
> > I made the changes that seemed to make sense, but cannot get the
> > application to run. I get the following exception:
> >
> >  Exception in thread "main" java.lang.IllegalAccessError: tried to
> > access method
> > org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryN
> > ames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List;
> > from class org.springframework.boot.SpringApplication
> >at
> >
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
> >at
> >
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:412)
> >at
> >
> org.springframework.boot.SpringApplication.(SpringApplication.java:268)
> >at
> >
> org.springframework.boot.SpringApplication.(SpringApplication.java:249)
> >at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
> >at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
> >at org.test.ApplicationMain.main(ApplicationMain.java:12)
> >
> > I do not understand what it's complaining about. I'm including
> > resources below so that people can look at what I'm doing. I apologize
> > in advance for the amount of code.
> >
> > ApplicationMain.java:
> >
> >  @SpringBootApplication
> >  @ImportResource("classpath:camel-context.xml")
> >  public class ApplicationMain {
> >public static void main(String[] args) {
> >SpringApplication.run(ApplicationMain.class, args);
> >}
> >  }
> >
> > Configurer.java:
> >
> >  @Configuration
> >  @ComponentScan("org.test")
> >  public class Configurer {
> >@Bean
> >public MyProcessor myProcessor() {
> >return new MyProcessor();
> >}
> >  }
> >
> > application.yml:
> >
> >  ---
> >  camel:
> >springboot:
> >name: CamelConsumer
> >main-run-controller: true
> >
> > camel-context.xml:
> >
> >  
> >  http://www.springframework.org/schema/beans;
> >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> >xsi:schemaLocation="
> >http://www.springframework.

Re: Problem with Spring Boot Camel application

2020-04-02 Thread Alex Dettinger
Hi Joe,

  Maybe versions alignment, If I'm right mvn dependency:tree would show non
aligned version while you should have something like camel 3.1.0 / spring
5.2.3.RELEASE / spring boot 2.2.4.RELEASE.
  Checking other examples may help in this regard, they should be available
here
https://github.com/apache/camel-spring-boot/tree/camel-spring-boot-3.1.x/examples
.

Cheers,
Alex




On Wed, Apr 1, 2020 at 5:21 PM Gagnon, Joseph - 0553 - MITLL <
joseph.gag...@ll.mit.edu> wrote:

> Hello,
>
> I am still very new to using Apache Camel and am trying to adapt an
> example provided by someone (
> https://www.javainuse.com/camel/camel-consume-rest) to essentially do the
> same thing the original application does, except by using a combination of
> Spring Boot and Camel with XML route configuration.
>
> I downloaded the original application code (both the Camel consumer and
> the HTTP server) and got those to run and execute properly very easily.
>
> Now, I want to modify the application a little so that Spring Boot is used
> to do all the behind-the-scenes configuration, and use the XML DSL to
> configure the Camel routes. The original Camel consumer application does
> not use Spring at all.
>
> I made the changes that seemed to make sense, but cannot get the
> application to run. I get the following exception:
>
>  Exception in thread "main" java.lang.IllegalAccessError: tried to
> access method 
> org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List;
> from class org.springframework.boot.SpringApplication
>at
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
>at
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:412)
>at
> org.springframework.boot.SpringApplication.(SpringApplication.java:268)
>at
> org.springframework.boot.SpringApplication.(SpringApplication.java:249)
>at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
>at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
>at org.test.ApplicationMain.main(ApplicationMain.java:12)
>
> I do not understand what it's complaining about. I'm including resources
> below so that people can look at what I'm doing. I apologize in advance for
> the amount of code.
>
> ApplicationMain.java:
>
>  @SpringBootApplication
>  @ImportResource("classpath:camel-context.xml")
>  public class ApplicationMain {
>public static void main(String[] args) {
>SpringApplication.run(ApplicationMain.class, args);
>}
>  }
>
> Configurer.java:
>
>  @Configuration
>  @ComponentScan("org.test")
>  public class Configurer {
>@Bean
>public MyProcessor myProcessor() {
>return new MyProcessor();
>}
>  }
>
> application.yml:
>
>  ---
>  camel:
>springboot:
>name: CamelConsumer
>main-run-controller: true
>
> camel-context.xml:
>
>  
>  http://www.springframework.org/schema/beans;
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
>xsi:schemaLocation="
>http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd;>
>
>
>
>http://camel.apache.org/schema/spring;>
>
>
>  
>
> routes/routes.xml:
>
> **Note**: I do not know whether I'm using the correct syntax for the
> elements in the route definition below. I'm trying to adapt it from the
> original, which was done in Java DSL. I'm also not sure whether or not I
> need the processor bean definition, since I also have the bean defined in
> the Configurer above.
>
>  
>  http://www.springframework.org/schema/beans;
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
>xsi:schemaLocation="
>http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd;>
>
>
>
>http://camel.apache.org/schema/spring;>
>
>  
>  
> GET
>  
>  http://localhost:8080/employee?id=5; />
>  
>
>
>  
>
> MyProcessor.java:
>
>  public class MyProcessor implements Processor {
>public MyProcessor() {
>}
>public void process(Exchange exchange) throws Exception {
>   System.out.println(exchange.getIn().getBody(String.class));
>}
>  }
>
> pom.xml:
>
> **Note**: You may notice a mix of Spring Boot Camel starters as well as
> Camel dependencies for Camel 

Re: Testing Route in camel-quarkus

2020-03-25 Thread Alex Dettinger
Hi Dennis,

  Interesting idea, this may work in jvm mode and would need to be excluded
when executing @NativeImageTest.
You may also be able to inject a ProducerTemplate in the test to feed the
route directly.

Alex

On Wed, Mar 25, 2020 at 7:55 AM Dennis Holunder 
wrote:

> I could create a quarkus test where the route is injected and external
> endpoint is mocked with quarkus mock support.
>
> Am Fr., 20. März 2020 um 11:52 Uhr schrieb Dennis Holunder
> :
> >
> > Hello,
> >
> > is it possible to test a non-http route in camel-quarkus like we do
> > with CamelTestSupport in camel?
> >
> > Thanks!
>


Re: Camel version 3.0.2

2020-03-13 Thread Alex Dettinger
Hi remco,

  If I recall correctly, it's recommended to upgrade to camel 3.1.0 anyway
as camel 3.0.x will be short lived.

Hope this helps,
Alex

On Fri, Mar 13, 2020 at 3:16 PM Remco Schoen  wrote:

> Hi,
>
> As there are a lot of breaking changes for my projects in version 3.1.0, I
> was wondering if there is going to be a version 3.0.2 and if yes, when will
> it be released?
>
> Kind regards,
>
> Remco Schoen


Re: Stopping a Route when no more messages meet JMS selector

2020-02-24 Thread Alex Dettinger
Not sure about the exact implementation, but I would investigate the camel
code around MainSupport.durationIdle.

On Sun, Feb 23, 2020 at 11:22 PM nomit babraa 
wrote:

> Hi
>
> I was wondering if there is any way to do the following:
>
> - A route starts up.
> - It consumes certain messages from an AMQ queue using a selector.
> - Once all current messages are consumed the route is
> stopped/suspended (Control Bus, CamelContext.stop(),
> THROTTLINGINFLIGHTROUTEPOLICY, etc)
>
> I think I can use schedulers and throttling to almost achieve what I
> want but I explicitly want the route to be stopped when all current
> messages that are found by the selector are consumed.
>
> I'm not sure how to get that metric and act upon it?
>
> Many thanks for any advice...
>
> n
>


Re: ProducerTemplate.request() not returning complete Exchange

2020-02-20 Thread Alex Dettinger
Marci,

  Not sure I get the overall test scenario, but I think it's expected.
"producerTemplate.send("jms:sahara", new Processor() {" is actually sending
a message with MEP InOnly.
So you get the exchange back before "jms:sahara" as treated the message,
and thus can't assert any side effect from jms:sahara route.

  producerTemplate.request(...) should set the MEP to InOut early enough so
that your test is ok.

Alex

On Thu, Feb 20, 2020 at 3:47 AM Marci Wilken  wrote:

>
> The problem or my mis-understanding is in the producertemplate in the
> Junit tests
>
> In the actual code when calling from one route to the other
>
> to(jms:Sahara) header.test = foo
>
> from(jms:Sahara)...  with MEP inout
>
> /* do some cool stuff */
>
> Back to the previous  returns the correct message/exchange header.test =
> bar
>
> what is not happening from the junit test is Exchange reply
> =producerTemplate.send(new Processor etc )
>
>@Test
>@InSequence(15)
>public void testProcessingRun() throws Exception {
>  log.info("\r\n\r\n->>  Begin testProcessingRun()
> <<-");
>   jobID = -1;
>  ArrayList> rtnArray = null;
>
>MockEndpoint mock =
> camelctx.getEndpoint("mock:SaharaCoreTestResult", MockEndpoint.class);
>assertNotNull("Expected mock:SaharaCoreTestResult to
> exist", mock);
>mock.reset();
>mock.expectedMessageCount(1);
>
>  // this is the problem
>ProducerTemplate producerTemplate =
> camelctx.createProducerTemplate();
>
>Map headers = new HashMap Object>();
>
>
>Exchange exchange=
> producerTemplate.send("jms:sahara", new Processor() {
>
>public void process(final Exchange exchange) {
>
>  headers.put("test", "foo");
>  Map payload = new
> HashMap();
>  exchange.getIn().setHeaders(headers);
>exchange.getIn().setBody(payload);
>exchange.setPattern(ExchangePattern.InOut);
>
>}
>});
>
>  assertThat("header is not bar",
> reply.getIn().getHeader("test"), equalTo("bar")) <--- this fails
>  assertThat("header is not bar",
> reply.getOut().getHeader("test"), equalTo("bar")) <--- this fails
>
>  List list = mock.getReceivedExchanges();
>  assertThat("Expected exhange to return",
> list.size(),greaterThan(0));
>  Exchange mockReply = list.get(0);
>  assertThat("header is not bar", mockReply
> .getIn().getHeader("test"), equalTo("bar")) <--- this works
>
>  MockEndpoint.assertIsSatisfied(5L, TimeUnit.SECONDS,
> mock);
>
>log.info("->>  testProcessingRun Complete <<-");
>}
>
>
>
>
> > +1 for getMessage() :)
> >
> > On Mon, Feb 17, 2020 at 11:18 AM Giovanni Condello <
> > giovanni.conde...@coderit.it> wrote:
> >
> >> Hi Marci,
> >>
> >> to add on what Alex said, I found it's always better to use either
> >> getMessage() or to explicitly check if the exchange hasOut() instead of
> >> assuming getIn() is always the right place to look for data coming out
> of a
> >> component
> >>
> >> Giovanni
> >>
> >> -Messaggio originale-
> >> Da: Alex Dettinger 
> >> Inviato: lunedì 17 febbraio 2020 11:04
> >> A: users@camel.apache.org
> >> Oggetto: Re: ProducerTemplate.request() not returning complete Exchange
> >>
> >> Hi Marci,
> >>
> >>I would say that from("jms:Sahara")... has MEP InOUt so In message
> with
> >> header "foo", and OUT message with header "bar".
> >>
> >>So assertThat(“return should be
> >> bar”,reply.get*Out/Message*().getHeader(“test”),equalTo(“bar”)
> >> should be ok.
> >>
> >> Alex
> >>
> >> On Mon, Feb 17, 2020 at 11:02 AM Alex Dettinger 
> >> wrote:
> >>
> >>> Hi Marci,
> >>>
> >>>I would say that from("jms:Sahara")... has MEP InOUt so In message
> >>> with header "foo", and OUT 

Re: ProducerTemplate.request() not returning complete Exchange

2020-02-17 Thread Alex Dettinger
+1 for getMessage() :)

On Mon, Feb 17, 2020 at 11:18 AM Giovanni Condello <
giovanni.conde...@coderit.it> wrote:

> Hi Marci,
>
> to add on what Alex said, I found it's always better to use either
> getMessage() or to explicitly check if the exchange hasOut() instead of
> assuming getIn() is always the right place to look for data coming out of a
> component
>
> Giovanni
>
> -Messaggio originale-
> Da: Alex Dettinger 
> Inviato: lunedì 17 febbraio 2020 11:04
> A: users@camel.apache.org
> Oggetto: Re: ProducerTemplate.request() not returning complete Exchange
>
> Hi Marci,
>
>   I would say that from("jms:Sahara")... has MEP InOUt so In message with
> header "foo", and OUT message with header "bar".
>
>   So assertThat(“return should be
> bar”,reply.get*Out/Message*().getHeader(“test”),equalTo(“bar”)
> should be ok.
>
> Alex
>
> On Mon, Feb 17, 2020 at 11:02 AM Alex Dettinger 
> wrote:
>
> > Hi Marci,
> >
> >   I would say that from("jms:Sahara")... has MEP InOUt so In message
> > with header "foo", and OUT mess
> >
> > On Fri, Feb 14, 2020 at 11:43 PM Marci  wrote:
> >
> >>
> >>  I understand that the new Processor(){} is for the message being
> >> sent to the consumers (from(route)) and this is working fine.
> >> What I am not understanding is why the ProducerTemplate.request() is
> >> not returning an exchange back at the end of the route.
> >> For example.
> >> Exchange reply = producerTemplate.request("jms:Sahara", new Processor()
> {
> >> public void process(final Exchange exchange) {
> >> exchange.getIn().setHeader(“test”,”foo”)
> >> }
> >> Route
> >>  From(jms:Sahara”)
> >>   .log(LoggingLevel.INFO,"* Test ID: ${header.test}" )
> >>   .setHeader(“test”,”bar”);
> >> end route
> >>
> >> assertThat(“return should be
> >> bar”,reply.getIn().getHeader(“test”),equalTo(“bar”)
> >> but it is still “foo”
> >> This is failing when  it should pass
> >>
> >> Maybe I’m reading these wrong
> >> From Javadoc.io
> >> Exchangerequest(Endpoint endpoint, Processor processor)
> >> Sends an exchange to an endpoint using a supplied processor Uses an
> >> ExchangePattern.InOut message exchange pattern.
> >>
> >> from the camel apache org website
> >> request*() methods
> >>
> >> The send*() methods use the default Message Exchange Pattern (InOnly,
> >> InOut etc) as the endpoint. If you want to explicitly perform a
> >> request/response (InOut) you can use the request*() methods instead
> >> of the
> >> send*() methods.
> >>
> >> E.g. let’s invoke an endpoint and get the response:
> >>
> >>
> >>
> >> >Camel › Camel - Users › Camel - Users kilidarria
> >>
> >> >Re: ProducerTemplate.request() not returning complete Exchange.
> >> >‹ Previous Topic Next Topic ›
> >>
> >> classic Classic listListthreadedThreaded
> >>  X  Turn off highlighting 1 message Options Options
> >>
> >> Classic Threaded   Reply   More   Close
> >> Jan 15, 2020; 12:34am Claus Ibsen-2 Claus Ibsen-2 Re:
> >> ProducerTemplate.request() not returning complete Exchange.
> >> Hi
> >>
> >> The new Processor(){ } in the request method of the producer template
> >> is not for the reply message, but for preparing the message to send
> >> (eg the input message).
> >>
> >> On Tue, Jan 14, 2020 at 9:16 PM Wilken Marci J < [hidden email]>
> >> wrote:
> >>
> >> > Based on the documentation I was reading the
> >> > ProducerTemplate.request(, Processor) should return the
> >> > Exchange information from the route that was called.  When I am
> >> > running my test
> >> on
> >> > this it is returning the body information in the
> >> > exchange.getOut().getBody() but the exchange.getOut().getHeaders()
> >> > has
> >> the
> >> > headers that I sent and not returned headers that I see if I look
> >> > at the mock endpoint.  I am expecting it to return the header and
> >> > body data in
> >> the
> >> > Exchange.getIn().  Since this test is calling a jms message Queue
> >> (JBoss
> >> > EAP 7.2 Fuse 7.3) I am expectin

Re: ProducerTemplate.request() not returning complete Exchange

2020-02-17 Thread Alex Dettinger
Hi Marci,

  I would say that from("jms:Sahara")... has MEP InOUt so In
message with header "foo",
and OUT message with header "bar".

  So assertThat(“return should be
bar”,reply.get*Out/Message*().getHeader(“test”),equalTo(“bar”)
should be ok.

Alex

On Mon, Feb 17, 2020 at 11:02 AM Alex Dettinger 
wrote:

> Hi Marci,
>
>   I would say that from("jms:Sahara")... has MEP InOUt so In
> message with header "foo",
> and OUT mess
>
> On Fri, Feb 14, 2020 at 11:43 PM Marci  wrote:
>
>>
>>  I understand that the new Processor(){} is for the message being sent to
>> the consumers (from(route)) and this is working fine.
>> What I am not understanding is why the ProducerTemplate.request() is not
>> returning an exchange back at the end of the route.
>> For example.
>> Exchange reply = producerTemplate.request("jms:Sahara", new Processor() {
>> public void process(final Exchange exchange) {
>> exchange.getIn().setHeader(“test”,”foo”)
>> }
>> Route
>>  From(jms:Sahara”)
>>   .log(LoggingLevel.INFO,"* Test ID: ${header.test}" )
>>   .setHeader(“test”,”bar”);
>> end route
>>
>> assertThat(“return should be
>> bar”,reply.getIn().getHeader(“test”),equalTo(“bar”)
>> but it is still “foo”
>> This is failing when  it should pass
>>
>> Maybe I’m reading these wrong
>> From Javadoc.io
>> Exchangerequest(Endpoint endpoint, Processor processor)
>> Sends an exchange to an endpoint using a supplied processor Uses an
>> ExchangePattern.InOut message exchange pattern.
>>
>> from the camel apache org website
>> request*() methods
>>
>> The send*() methods use the default Message Exchange Pattern (InOnly,
>> InOut etc) as the endpoint. If you want to explicitly perform a
>> request/response (InOut) you can use the request*() methods instead of the
>> send*() methods.
>>
>> E.g. let’s invoke an endpoint and get the response:
>>
>>
>>
>> >Camel › Camel - Users › Camel - Users
>> >kilidarria
>>
>> >Re: ProducerTemplate.request() not returning complete Exchange.
>> >‹ Previous Topic Next Topic ›
>>
>> classic Classic listListthreadedThreaded
>>  X  Turn off highlighting 1 message Options Options
>>
>> Classic Threaded   Reply   More   Close
>> Jan 15, 2020; 12:34am Claus Ibsen-2 Claus Ibsen-2 Re:
>> ProducerTemplate.request() not returning complete Exchange.
>> Hi
>>
>> The new Processor(){ } in the request method of the producer template is
>> not for the reply message, but for preparing the message to send (eg the
>> input message).
>>
>> On Tue, Jan 14, 2020 at 9:16 PM Wilken Marci J <
>> [hidden email]> wrote:
>>
>> > Based on the documentation I was reading the
>> > ProducerTemplate.request(, Processor) should return the  Exchange
>> > information from the route that was called.  When I am running my test
>> on
>> > this it is returning the body information in the
>> > exchange.getOut().getBody() but the exchange.getOut().getHeaders() has
>> the
>> > headers that I sent and not returned headers that I see if I look at the
>> > mock endpoint.  I am expecting it to return the header and body data in
>> the
>> > Exchange.getIn().  Since this test is calling a jms message Queue
>> (JBoss
>> > EAP 7.2 Fuse 7.3) I am expecting this to return the same thing as the a
>> > call from another route would see.  Am I understanding this wrong or am
>> I
>> > missing a setting?
>> >
>> >
>> >
>> > *public void testConnection() throws Exception {*
>> >
>> > *   log.info <http://log.info>("->>  Begin testConnection
>> > <<-");*
>> >
>> > *   Assert.assertNotNull("Expected QueueRoute-context to exist",
>> > camelctx);*
>> >
>> > *   Assert.assertEquals(ServiceStatus.Started,
>> camelctx.getStatus());*
>> >
>> >
>> >
>> > *   MockEndpoint mock = camelctx.getEndpoint("mock:JobLogResult",
>> > MockEndpoint.class);*
>> >
>> > *   assertNotNull("Expected mock:JobLogResult to exist", mock);*
>> >
>> > *   mock.reset();*
>> >
>> > *   mock.expectedMessageCount(1);*
>> >
>> >
>> >
>> > *   ProducerTemplate producerTemplate =
>> > camel

Re: ProducerTemplate.request() not returning complete Exchange

2020-02-17 Thread Alex Dettinger
Hi Marci,

  I would say that from("jms:Sahara")... has MEP InOUt so In
message with header "foo",
and OUT mess

On Fri, Feb 14, 2020 at 11:43 PM Marci  wrote:

>
>  I understand that the new Processor(){} is for the message being sent to
> the consumers (from(route)) and this is working fine.
> What I am not understanding is why the ProducerTemplate.request() is not
> returning an exchange back at the end of the route.
> For example.
> Exchange reply = producerTemplate.request("jms:Sahara", new Processor() {
> public void process(final Exchange exchange) {
> exchange.getIn().setHeader(“test”,”foo”)
> }
> Route
>  From(jms:Sahara”)
>   .log(LoggingLevel.INFO,"* Test ID: ${header.test}" )
>   .setHeader(“test”,”bar”);
> end route
>
> assertThat(“return should be
> bar”,reply.getIn().getHeader(“test”),equalTo(“bar”)
> but it is still “foo”
> This is failing when  it should pass
>
> Maybe I’m reading these wrong
> From Javadoc.io
> Exchangerequest(Endpoint endpoint, Processor processor)
> Sends an exchange to an endpoint using a supplied processor Uses an
> ExchangePattern.InOut message exchange pattern.
>
> from the camel apache org website
> request*() methods
>
> The send*() methods use the default Message Exchange Pattern (InOnly,
> InOut etc) as the endpoint. If you want to explicitly perform a
> request/response (InOut) you can use the request*() methods instead of the
> send*() methods.
>
> E.g. let’s invoke an endpoint and get the response:
>
>
>
> >Camel › Camel - Users › Camel - Users
> >kilidarria
>
> >Re: ProducerTemplate.request() not returning complete Exchange.
> >‹ Previous Topic Next Topic ›
>
> classic Classic listListthreadedThreaded
>  X  Turn off highlighting 1 message Options Options
>
> Classic Threaded   Reply   More   Close
> Jan 15, 2020; 12:34am Claus Ibsen-2 Claus Ibsen-2 Re:
> ProducerTemplate.request() not returning complete Exchange.
> Hi
>
> The new Processor(){ } in the request method of the producer template is
> not for the reply message, but for preparing the message to send (eg the
> input message).
>
> On Tue, Jan 14, 2020 at 9:16 PM Wilken Marci J <
> [hidden email]> wrote:
>
> > Based on the documentation I was reading the
> > ProducerTemplate.request(, Processor) should return the  Exchange
> > information from the route that was called.  When I am running my test on
> > this it is returning the body information in the
> > exchange.getOut().getBody() but the exchange.getOut().getHeaders() has
> the
> > headers that I sent and not returned headers that I see if I look at the
> > mock endpoint.  I am expecting it to return the header and body data in
> the
> > Exchange.getIn().  Since this test is calling a jms message Queue  (JBoss
> > EAP 7.2 Fuse 7.3) I am expecting this to return the same thing as the a
> > call from another route would see.  Am I understanding this wrong or am I
> > missing a setting?
> >
> >
> >
> > *public void testConnection() throws Exception {*
> >
> > *   log.info ("->>  Begin testConnection
> > <<-");*
> >
> > *   Assert.assertNotNull("Expected QueueRoute-context to exist",
> > camelctx);*
> >
> > *   Assert.assertEquals(ServiceStatus.Started,
> camelctx.getStatus());*
> >
> >
> >
> > *   MockEndpoint mock = camelctx.getEndpoint("mock:JobLogResult",
> > MockEndpoint.class);*
> >
> > *   assertNotNull("Expected mock:JobLogResult to exist", mock);*
> >
> > *   mock.reset();*
> >
> > *   mock.expectedMessageCount(1);*
> >
> >
> >
> > *   ProducerTemplate producerTemplate =
> > camelctx.createProducerTemplate();*
> >
> > *   Assert.assertNotNull("Expected producerTemplate to exist",
> > producerTemplate);*
> >
> >
> >
> > *   Exchange reply =
> > producerTemplate.request("jms:queue:Sahara.Core.JobIdRequest", new
> > Processor() {*
> >
> >
> >
> > *  public void process(final Exchange exchange) {*
> >
> >
> >
> > * Map headers = new HashMap > Object>();*
> >
> > * headers.put("RequestingSource", requestingSource);*
> >
> > * headers.put("AuthorizationKey", authorizationKey);*
> >
> > * headers.put("RequestType", "testConnection");*
> >
> >
> >
> > * Map payload = new HashMap > Object>();*
> >
> >
> >
> > * exchange.getIn().setHeaders(headers);*
> >
> > * exchange.getIn().setBody(payload);*
> >
> > * exchange.setPattern(ExchangePattern.InOut);*
> >
> >
> >
> > *  }*
> >
> > *   });*
> >
> > *   // these fail*
> >
> > *   assertThat("Request was un-successful", (
> > reply.getIn().getHeader("SQLErrorMessage") == null ? "null"
> > :((String)reply.getIn().getHeader("SQLErrorMessage"))).toLowerCase()
> > ,equalTo("success"));*
> >
> > *   assertThat("Didn't Return Data ", (int)
> > 

Re: Re: Re: Bindy plus Unicode

2020-01-27 Thread Alex Dettinger
Hi Michael,

  You would need to open a PR against master.
  Please, find some helpful information around contributions
https://camel.apache.org/manual/latest/contributing.html.

  I'm sure ICU4J is functionally great. However, license compatibility is a
legal matter, we don't really have choice.
  Could you please point to the ICU4J license you've been using ? I could
have a try with checking the compatibility.

Alex

On Sat, Jan 25, 2020 at 5:42 PM  wrote:

>
> Hi Alex,
>
> well, which would then be the appropriate branch? Master or 3.x?
> I guess if i create a ticket I get informed by e-mail what happens to the
> thing, right?
> I think there could be a ticket + PR in the next two weeks.
>
> I word on ICU4J. Of course I understand, that an Apache Project has to be
> careful, but there
> are features like splitting strings into graphemes, that need features,
> the old logic in the JDK
> doesn't support. The lib is very common (e.g. LibreOffice uses it) and
> AFAIK the de-facto standard
> for working with elaborate Unicode.
>
> -- Mik
>
> 
> Gesendet: Freitag, 24. Januar 2020 um 19:15 Uhr
> Von: "Alex Dettinger" 
> An: users@camel.apache.org
> Betreff: Re: Re: Bindy plus Unicode
> Hi Michael,
>
> Good to know that you sorted it out :) The compatibility between the
> ICU4L and Apache License is not straightforward, we would need to look
> closer.
> Still creating a quick ticket and sharing a github project would make it
> possible to save your work, and may be of interest later on to the
> community.
> Would one provide a PR against 3.x, chances are that this could be
> back-ported to 2.x. Please, keep time frame in mind as 2.x may close end of
> this year.
>
> Alex
>
> On Fri, Jan 24, 2020 at 5:20 PM Michael Greulich 
> wrote:
>
> >
> > Hi Alex,
> >
> > well, your comment was already very helpful. I created a custom
> DataFormat
> > and ModelFactory from the default ones for FixedLength. Of course I
> obeyed
> > the license terms of the Apache license ;-) For some aspect of
> recognizing
> > chars, I used the ICU4J-lib, because the support for some things (e.g.
> > emojis) in the Java runtime is not up to date. The license of ICU it
> quite
> > permitting, too. I’ve no idea, if this is a problem for an Apache
> project...
> >
> > Well I think I’m not the only one, that has this use-case -- so I think
> > this can be useful for the community, too. Currently I’m under pressure,
> > but I think I will create a JIRA ticket when the stress has become less.
> If
> > the community is interested, I can provide the code of my solution and
> > would be glad if this thing goes upstream (i.e. into the camel distro)
> some
> > day.
> >
> > Currently we (the company I work for) are using Camel 2.2 and I guess
> this
> > will be the case for some time. If this feature or bug (not very
> determined
> > what it actually is, I will leave the decision to the community) in which
> > version will it be included? Only Camel 3.x or will it be backported to
> 2.2?
> >
> > -- Mik
> >
> >
> --
> > Gesendet: Freitag, 24. Januar 2020 um 11:43 Uhr
> > Von: "Alex Dettinger" 
> > An: users@camel.apache.org
> > Betreff: Re: Bindy plus Unicode
> > Hi Michael,
> >
> > I was just looking at this component for another purpose and it looks
> > to me that fixed length tokenzation occurs here:
> >
> >
> >
> https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java#L212..L216
> > So, It counts in java chars and not code points. You can maybe experiment
> > injecting a custom BindyFixedLengthFactory, via
> > dataFormat.setModelFactory(..).
> >
> > Would you feel that an extension point to customize count/selection of
> > chars/codepoint/grapheme would be valuable to the community, feel free to
> > raise a JIRA ticket.
> >
> > Alex
> >
> >
> > On Fri, Jan 24, 2020 at 9:52 AM Michael Greulich <
> > mich...@greulich-online.eu>
> > wrote:
> >
> > > Hi,
> > >
> > > I’m having problems with the bindy component and wonder if there is
> > > something I missed. Maybe one can help me addressing it. I cannot
> > believe,
> > > that I’m the first to hit this problem.
> > >
> > > I need to port an EAI application built using bindy, that reads a fixed
> > > type file(*) converts it and sends the data somewhere else. Currently
> > t

Re: Re: Bindy plus Unicode

2020-01-24 Thread Alex Dettinger
Hi Michael,

  Good to know that you sorted it out :) The compatibility between the
ICU4L and Apache License is not straightforward, we would need to look
closer.
Still creating a quick ticket and sharing a github project would make it
possible to save your work, and may be of interest later on to the
community.
  Would one provide a PR against 3.x, chances are that this could be
back-ported to 2.x. Please, keep time frame in mind as 2.x may close end of
this year.

Alex

On Fri, Jan 24, 2020 at 5:20 PM Michael Greulich 
wrote:

>
> Hi Alex,
>
> well, your comment was already very helpful. I created a custom DataFormat
> and ModelFactory from the default ones for FixedLength. Of course I obeyed
> the license terms of the Apache license ;-) For some aspect of recognizing
> chars, I used the ICU4J-lib, because the support for some things (e.g.
> emojis) in the Java runtime is not up to date. The license of ICU it quite
> permitting, too. I’ve no idea, if this is a problem for an Apache project...
>
> Well I think I’m not the only one, that has this use-case -- so I  think
> this can be useful for the community, too. Currently I’m under pressure,
> but I think I will create a JIRA ticket when the stress has become less. If
> the community is interested, I can provide the code of my solution and
> would be glad if this thing goes upstream (i.e. into the camel distro) some
> day.
>
> Currently we (the company I work for) are using Camel 2.2 and I guess this
> will be the case for some time. If this feature or bug (not very determined
> what it actually is, I will leave the decision to the community)  in which
> version will it be included? Only Camel 3.x or will it be backported to 2.2?
>
> -- Mik
>
> ------
> Gesendet: Freitag, 24. Januar 2020 um 11:43 Uhr
> Von: "Alex Dettinger" 
> An: users@camel.apache.org
> Betreff: Re: Bindy plus Unicode
> Hi Michael,
>
> I was just looking at this component for another purpose and it looks
> to me that fixed length tokenzation occurs here:
>
>
> https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java#L212..L216
> So, It counts in java chars and not code points. You can maybe experiment
> injecting a custom BindyFixedLengthFactory, via
> dataFormat.setModelFactory(..).
>
> Would you feel that an extension point to customize count/selection of
> chars/codepoint/grapheme would be valuable to the community, feel free to
> raise a JIRA ticket.
>
> Alex
>
>
> On Fri, Jan 24, 2020 at 9:52 AM Michael Greulich <
> mich...@greulich-online.eu>
> wrote:
>
> > Hi,
> >
> > I’m having problems with the bindy component and wonder if there is
> > something I missed. Maybe one can help me addressing it. I cannot
> believe,
> > that I’m the first to hit this problem.
> >
> > I need to port an EAI application built using bindy, that reads a fixed
> > type file(*) converts it and sends the data somewhere else. Currently
> this
> > file is in Latin 1 encoding, but we need to take it to Unicode –
> > effectively UTF-8. We have an ugly, but effectively unavoidable legacy
> > application that creates the file.
> >
> > Unicode is a bit tricky, when it comes to counting the length of a string
> > specially since Java uses internally UTF-16, which means depending on the
> > codepoint 1 – 2 (Java-)chars. Bindy seems to use internally for selection
> > substring and counts chars like Java does. This means the length of a
> > string is the count of the chars, i.e. UTF-16 surrogates, but not
> > codepoints, which is the common denominator (e.g. see definition of
> string
> > length in XMLSchema). And when one takes combing chars into account (one
> > “base char” plus 0 – n combining chars are perceived as one “char” by
> > users) it becomes even more of a problem.
> >
> > Is there a possibility to tell bindy how it counts an and selects the
> > tokens based on char counts in a given line? Any suggestions? Is the are
> > related bug or change to come that addresses this problem?
> >
> > -- Mik
> >
> > (*) This means, that on certain positions there start certain data
> > (columns if you will).
> >
> >
>
>
>


Re: Bindy plus Unicode

2020-01-24 Thread Alex Dettinger
Hi Michael,

I was just looking at this component for another purpose and it looks
to me that fixed length tokenzation occurs here:

https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java#L212..L216
  So, It counts in java chars and not code points. You can maybe experiment
injecting a custom BindyFixedLengthFactory, via
dataFormat.setModelFactory(..).

  Would you feel that an extension point to customize count/selection of
chars/codepoint/grapheme would be valuable to the community, feel free to
raise a JIRA ticket.

Alex


On Fri, Jan 24, 2020 at 9:52 AM Michael Greulich 
wrote:

> Hi,
>
> I’m having problems with the bindy component and wonder if there is
> something I missed. Maybe one can help me addressing it. I cannot believe,
> that I’m the first to hit this problem.
>
> I need to port an EAI application built using bindy, that reads a fixed
> type file(*) converts it and sends the data somewhere else. Currently this
> file is in Latin 1 encoding, but we need to take it to Unicode –
> effectively UTF-8. We have an ugly, but effectively unavoidable legacy
> application that creates the file.
>
> Unicode is a bit tricky, when it comes to counting the length of a string
> specially since Java uses internally UTF-16, which means depending on the
> codepoint 1 – 2 (Java-)chars. Bindy seems to use internally for selection
> substring and counts chars like Java does. This means the length of a
> string is the count of the chars, i.e. UTF-16 surrogates, but not
> codepoints, which is the common denominator (e.g. see definition of string
> length in XMLSchema). And when one takes combing chars into account (one
> “base char” plus 0 – n combining chars are perceived as one “char” by
> users) it becomes even more of a problem.
>
> Is there a possibility to tell bindy how it counts an and selects the
> tokens based on char counts in a given line? Any suggestions? Is the are
> related bug or change to come that addresses this problem?
>
> -- Mik
>
> (*) This means, that on certain positions there start certain data
> (columns if you will).
>
>


Re: Salesforce PushTopic subscription replayId not working as expected

2020-01-23 Thread Alex Dettinger
Hi Rick,

  My understanding is that there is an issue accessing the replayId in
camel, and not an issue with the -2 durability that is actually served.
  From the code, I think the replayId should be set here in 2.22.x:

https://github.com/apache/camel/blob/camel-2.22.x/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceConsumer.java#L165

  So, few things I would try:
  + getting the CamelSalesforceReplayId header value
  + updating to the last 2.22.x version 2.22.5 (note that this branch is
EOL)
  + updating to 2.24.3
  + debugging and see why the L165 is not called...

Hope that help,
Alex

On Thu, Jan 23, 2020 at 3:49 AM Rick Matusiewicz <
rick.matusiew...@ibotta.com> wrote:

> Hello,
>
> I am attempting to use the camel-salesforce component to subscribe to a
> Salesforce PushTopic. I am having a couple issues:
>
> 1) When I set the replayId = -2 , and when my route starts up there are no
> existing messages coming in even though there are messages on the PushTopic
> in the past 24 hrs. I also see this log line:
> [main] INFO  o.a.c.c.s.i.s.SubscriptionHelper - Set Replay extension to
> replay from `-2` for channel `/topic/AccountUpsert`
>
> 2) I update a record in my org to trigger a PushTopic message. My camel
> route picks up the message. However, I have not been able to access the
> event object, which includes the replayId of the message. Durable Messaging
> is an absolute must for our integration, and so we need the replayId.
>
> Camel version: 2.22.0
> Camel-salesforce version: 2.22.0
>


Re: Parsing JSON within the Camel Velocity component template?

2020-01-06 Thread Alex Dettinger
Hi Gerald,

  The example below shows how to use a pojo from a velocity context:

https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java

  So, chances are that you just need to set the body to a pojo offering a
getName() method and then use it from the velocity context with $body.name.
This is not something I've tested, but looks worth a try.

Alex

On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas  wrote:

> Dear community,
>
> I've following snippet ..
>
>
> [{"name":"Wonderland","surname":"Alice"}]
> 
>
> The body comes from a jsonpath expression earlier. I've just stripped it
> to the essentials.
>
> Is it possible to access inside a Camel Velocity component template to the
> attribute values for name and surname?
>
> Many thanks for any response in advance.
>
> Best
> - Gerald


Re: Springboot Camel Javamailer Mock Testing

2019-12-12 Thread Alex Dettinger
Hi Louis,

  Maybe port 25 is kinda not accessible to the process. In any case, asking
the org.jvnet.mock-javamail community may be a better option.

Alex

On Thu, Dec 12, 2019 at 1:22 PM Louis Becker  wrote:

> Hi
>
> I am trying to set up a mock test for when I am sending email to achieve
> 100% coverage of my code. With the command emailSender.send(message), the
> message needs to be delivered to a mock endpoint that can evaluated and
> asserted. It seems that org.jvnet.mock-javamail is an option, but for the
> life of me I cannot figure how to do the setup in my yml file.
>
> This is what I have in my yml file:
>
> spring:
>   profiles: mock
>
>   mail:
> host: localhost
> port: 25
> protocol: smtp
> properties.mail.smtp.auth: false
> properties.mail.smtp.tls: false
> properties.mail.debug: true
>
> When I then run my test, I get:
>
> com.sun.mail.util.MailConnectException: Couldn't connect to host, port:
> localhost, 25; timeout -1;
>   nested exception is:
>  java.net.SocketException: Permission denied: connect
>
>
> My testing code looks like this:
>
> @ActiveProfiles("mock")
> @RunWith(CamelSpringBootRunner.class)
> @SpringBootTest(properties = {
> "camel.springboot.xmlRoutes=false",
>
> "camel.springboot.javaRoutesIncludePattern=na/com/meatco/edocExchange/alert/**"})
> @MockEndpoints
> @Slf4j
> public class MailProcessorTest {
>
> @Autowired
> MailProcessor mailProcessor;
>
> @Autowired
> CamelContext camelContext;
>
> @BeforeClass
> public static void setUp(){
> Mailbox.clearAll();
> }
>
> @Test
> public void mailProcessorTest() throws Exception {
>
> String subject = "Test";
> String body = "Test Message Body";
>
> Exchange exchange = new DefaultExchange(camelContext);
>
> exchange.setProperty(Exchange.EXCEPTION_CAUGHT, new
> Exception("Test Exception"));
>
> mailProcessor.process(exchange);
>
> List inbox = Mailbox.get("mock_t...@mock.mail.na");
>
> Assert.assertTrue(inbox.size() == 1);
>
> }
>
> }
>
> Can anyone help?
>
> Louis
>
>


Re: own endpoint exmaple?

2019-09-19 Thread Alex Dettinger
Hi Thomas,

  Did you figured it out ?
  From the code, it's hard to see what the issue could be: Do you extend
DefaultComponent ? Do you call setProperties() in createEndpoint() ? and so
on...
  If you have not used an archetype yet, then I would direct you back to
Omar Al-Safi suggestion: Scaffolding your component through maven archetype
https://camel.apache.org/manual/latest/camel-maven-archetypes.html.
  You'll then have a proper layout to start on then.

Alex


On Tue, Sep 17, 2019 at 12:49 PM  wrote:

> Hi,
>
> thanks so far. I didn’t know that I had to explicitely create a Component.
> The direct example helped a lot.
> But there is this contruct, and it will not work with my code.
> name is not set. (it has getter and setter)
>
> I want that name is "thomas" when route-def is like
>
> to("monitoring:thomas")
>
> @UriEndpoint(scheme = "monitoring", title = "monitoring",
> syntax="monitoring:name", label = "Monitoring")
> public class MonitorEndpoint extends DefaultEndpoint
> {
>   @UriPath
>   @Metadata(required = true)
>   private String name;
>
>   public MonitorEndpoint() {
>   }
>
>   public MonitorEndpoint(final String endpointUri, final Component
> component) {
> super(endpointUri, component);
>   }
>
>   @Override
>   public Consumer createConsumer(Processor processor) throws Exception {
> // TODO Auto-generated method stub
> return null;
>   }
>
>
>
>
>
>
> -Ursprüngliche Nachricht-
> Von: Omar Al-Safi 
> Gesendet: Montag, 16. September 2019 13:05
> An: users@camel.apache.org
> Betreff: Re: own endpoint exmaple?
>
> I see, yeah we will need to fix this. By the way, you can start
> scaffolding your component through maven archetype,
> https://camel.apache.org/manual/latest/camel-maven-archetypes.html, as I
> recall, it will also add the necessary files to enable camel auto discovery
> out of the box
>
> On Mon, 16 Sep 2019 at 13:01, Alex Dettinger 
> wrote:
>
> > Also, the source code of the direct component could be a good starter
> > to get inspiration:
> >
> > https://github.com/apache/camel/tree/master/components/camel-direct/sr
> > c/main/java/org/apache/camel/component/direct
> >
> > Alex
> >
> > On Mon, Sep 16, 2019 at 12:57 PM Steve Huston 
> > wrote:
> >
> > > Is it possible that Spring is not finding your endpoint class?
> > >
> > > -Steve
> > >
> > > On 9/16/19, 6:55 AM, "thomas.thi...@telekom.de" <
> > thomas.thi...@telekom.de>
> > > wrote:
> > >
> > > Hi Alex,
> > >
> > > 1. I found this webpage but the links (e.g. createProducer())
> > > goes to "page not found".
> > >
> > > 2. Stupid question: how and where to do this?
> > >
> > > -Ursprüngliche Nachricht-
> > > Von: Alex Dettinger 
> > > Gesendet: Montag, 16. September 2019 12:52
> > > An: users@camel.apache.org
> > > Betreff: Re: own endpoint exmaple?
> > >
> > > Hi Thomas,
> > >
> > >   This link might be of interest:
> > >   https://camel.apache.org/manual/latest/writing-components.html
> > >
> > >   In your case, I wonder if you missed to create the thomas
> > > component first.
> > >
> > > hth,
> > > Alex
> > >
> > > On Mon, Sep 16, 2019 at 12:44 PM  wrote:
> > >
> > > > Hi,
> > > >
> > > > can some point me to a working example where an own endpoint
> > > was created.
> > > >
> > > > In route I say:
> > > >
> > > > .to("thomas://foo")
> > > >
> > > > my Endpoint is
> > > >
> > > > @Component
> > > > @UriEndpoint(scheme = "thomas", title = "Thiele",
> > > > syntax="thomas:name", label = "Thomas") public class ThomasStep
> > > > extends DefaultEndpoint {}
> > > >
> > > > But I get.
> > > >
> > > > thomas://name due to: No component found with scheme: thomas
> > > >
> > >
> > >
> > >
> >
>


Re: own endpoint exmaple?

2019-09-16 Thread Alex Dettinger
Also, the source code of the direct component could be a good starter to
get inspiration:
https://github.com/apache/camel/tree/master/components/camel-direct/src/main/java/org/apache/camel/component/direct

Alex

On Mon, Sep 16, 2019 at 12:57 PM Steve Huston  wrote:

> Is it possible that Spring is not finding your endpoint class?
>
> -Steve
>
> On 9/16/19, 6:55 AM, "thomas.thi...@telekom.de" 
> wrote:
>
> Hi Alex,
>
> 1. I found this webpage but the links (e.g. createProducer()) goes to
> "page not found".
>
> 2. Stupid question: how and where to do this?
>
> -Ursprüngliche Nachricht-
> Von: Alex Dettinger 
> Gesendet: Montag, 16. September 2019 12:52
> An: users@camel.apache.org
> Betreff: Re: own endpoint exmaple?
>
> Hi Thomas,
>
>   This link might be of interest:
>   https://camel.apache.org/manual/latest/writing-components.html
>
>   In your case, I wonder if you missed to create the thomas component
> first.
>
> hth,
> Alex
>
> On Mon, Sep 16, 2019 at 12:44 PM  wrote:
>
> > Hi,
> >
> > can some point me to a working example where an own endpoint was
> created.
> >
> > In route I say:
> >
> > .to("thomas://foo")
> >
> > my Endpoint is
> >
> > @Component
> > @UriEndpoint(scheme = "thomas", title = "Thiele",
> > syntax="thomas:name", label = "Thomas") public class ThomasStep
> > extends DefaultEndpoint {}
> >
> > But I get.
> >
> > thomas://name due to: No component found with scheme: thomas
> >
>
>
>


Re: own endpoint exmaple?

2019-09-16 Thread Alex Dettinger
Hi Thomas,

  This link might be of interest:
  https://camel.apache.org/manual/latest/writing-components.html

  In your case, I wonder if you missed to create the thomas component first.

hth,
Alex

On Mon, Sep 16, 2019 at 12:44 PM  wrote:

> Hi,
>
> can some point me to a working example where an own endpoint was created.
>
> In route I say:
>
> .to("thomas://foo")
>
> my Endpoint is
>
> @Component
> @UriEndpoint(scheme = "thomas", title = "Thiele", syntax="thomas:name",
> label = "Thomas")
> public class ThomasStep extends DefaultEndpoint
> {}
>
> But I get.
>
> thomas://name due to: No component found with scheme: thomas
>


Re: [ANNOUNCEMENT] Brand new Apache Camel website

2019-08-20 Thread Alex Dettinger
Awesome. It looks so fresh and nice :)
Kudos to all Cameleers that made this possible.

Alex

On Tue, Aug 20, 2019 at 3:39 PM Michael Joyner 
wrote:

> Wow, it looks great
>
> On Tue, Aug 20, 2019 at 6:03 AM Zoran Regvart  wrote:
>
> > Hi Cameleers!
> > I'm delighted to announce that the new Apache Camel website is live
> > now. This has been a work that many of you contributed to either
> > directly by modifying the site content working on the design or
> > functionality or indirectly by providing feedback.
> >
> > Have a look at the new website at:
> >
> > https://camel.apache.org/
> >
> > Please feel free to share feedback we're always looking for ways to
> > improve, we already have some issues that we're working on[1].
> >
> > If you find any issues with the website you can either create a an
> > JIRA issue and set the component to 'website', or you can use the new
> > functionality 'Edit this Page' to suggest improvements yourself!
> >
> > zoran
> >
> > [1]
> >
> https://issues.apache.org/jira/issues/?jql=project%20%3D%20CAMEL%20AND%20component%20%3D%20website
> > --
> > Zoran Regvart
> >
>
>
> --
> Sincerely,
> Michael Joyner
>


Re: Read header value in Camel xpath

2019-06-26 Thread Alex Dettinger
If I get it correctly, you may be interested in the "in:header" xpath
function:
https://github.com/apache/camel/blob/master/components/camel-xpath/src/main/docs/xpath-language.adoc
https://github.com/apache/camel/blob/camel-2.24.x/camel-core/src/test/java/org/apache/camel/language/XPathFunctionTest.java

Hope that help,
Alex

On Wed, Jun 26, 2019 at 9:42 AM Bikash Kaushik 
wrote:

> Hi,
>
> I want to use header value in xpath to filter message based on header
> value.
>
> On Wed, Jun 26, 2019, 12:46 PM Claus Ibsen  wrote:
>
> > Hi
> >
> > What do you mean?
> >
> > Do you mean you need to use a Camel Message header to build your xpath
> > expression, or do you want from the xpath expression to refer to a
> > Camel header. Its a bit unclear from your example.
> >
> > On Wed, Jun 26, 2019 at 8:45 AM Bikash Kaushik
> >  wrote:
> > >
> > > Hi,
> > >
> > > I want to know , how to pass header value in Camel xpath ,
> > >
> > >  > >
> >
> headerName="xpathValue">*//*[local-name()='EmployeeDataResult']/text()
> > >
> > > I have to pass header value in between xapth.
> > >
> > >
> > > Regards,
> > > Bikash Kaushik
> >
> >
> >
> > --
> > Claus Ibsen
> > -
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>


Re: How to ensure ordering in camel context polling weblogic jms queue

2019-06-14 Thread Alex Dettinger
Hi Jeffrey,

  I've never faced this exact situation. But I wonder if a resequencer
could help:
https://github.com/apache/camel/blob/master/core/camel-core/src/main/docs/eips/resequence-eip.adoc
I don't know if it plays well with transaction but it looks like it could
be tested quickly.

My 2c,
Alex


On Fri, Jun 14, 2019 at 12:32 AM Jeffrey John  wrote:

> I am trying to setup a camel context that polls a weblogic jms queue,
> consumes the message and sends it to a webservice endpoint. Incase any
> error occurs in the transaction or the target system is unavailable, I need
> to redeliver the same message without losing sequence/ordering.
>
> I have set up a camel jms route with single consumer and enabled transacted
> attribute as per https://camel.apache.org/transactional-client.html and
> set
> the redelivery as unlimited.
>
> When the transaction fails with messageA, the jms message consumption from
> weblogic queue is rollbacked and the messageA is marked for redelivery
> (state string is marked delayed) in weblogic. But during this time if
> another message reaches the weblogic queue, the camel route picks the
> messageB and forwards it to the target endpoint although the messageA is
> still in retrying mode. This distorts the whole ordering of the messages.
>
> The transaction client is used to ensure that messages are not lost while
> the application is shutdown during redelivery.
>
> I expect that there are no message loss and the messages are always sent in
> the correct order as per generated into the weblogic queue to the target
> endpoint. Is there any option in camel for ensuring such ordered
> transactions?
>
> Appreciate your help.
>
> Regards,
>
> Jeff
>


Re: How to receive data from a seda queue in netty4 component decoder

2019-06-09 Thread Alex Dettinger
Just a try but I wonder if the "decoder" plays well with "textline=true".
So, perharps removing that could help.
More info in the doc there:
https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc

My 2 cents,
Alex

On Sun, Jun 9, 2019 at 6:54 AM canukit 
wrote:

> Hello
>
> I am new to netty and camel and am trying to create a proxy using apache
> camel and its netty4 component.
>
> I want to receive data from a server, forward that data to a seda queue
> and then send that data from the seda queue to another server that requires
> a handshake be performed first which I will be trying to do within a
> decoder.
>
> The issue I'm having right now is that when I try to add a custom encoder
> / decoder I never receive the data from the seda queue in the channelRead
> method when extending a ChannelInboundHandlerAdapter
>
> So far I have tried without a decoder/encoder and the data is forwarded
> through the routes and received at the destination server but not when a
> decoder is added to the destination server netty component.  The handshake
> is not added yet as I am trying to get the flow of data correct.
>
> Versions:
> compile group: 'org.apache.camel', name: 'camel-core', version: '2.24.0'
> compile group: 'org.apache.camel', name: 'camel-netty4', version: '2.24.0'
>
> Fedora 29 - openjdk version "11.0.3" 2019-04-16
>
> Classes
>
> NettyCamelPractice.java
>
> public class NettyCamelPractice {
>
> public static void main(String args[]) throws Exception {
> Main camelMain = new Main();
>
> try {
> camelMain.getOrCreateCamelContext();
> camelMain.bind("testDecoderHandler", new TestDecoderHandler());
> camelMain.addRouteBuilder(new
> NettyCamelPracticeRouteBuilder());
>
> camelMain.run();
> } finally {
> camelMain.shutdown();
> }
> }
> }
>
> NettyCamelPracticeRouteBuilder.java
>
> public class NettyCamelPracticeRouteBuilder extends RouteBuilder {
>
> @Override
> public void configure() throws Exception {
> testRoute();
> sedaQueue();
> }
>
> public void testRoute() {
> System.out.println("here");
> from("netty4:tcp://127.0.0.1:1234?clientMode=true=true")
> .to("seda:tmp_queue");
>
> }
>
> public void sedaQueue() {
> from("seda:tmp_queue")
> .log(LoggingLevel.INFO, "Got the message - ${body}")
> .to("netty4:tcp://
> 127.0.0.1:5678?textline=true=#testDecoderHandler");
> }
> }
>
> TestDecoderHandler.java
>
> public class TestDecoderHandler extends ChannelInboundHandlerAdapter {
>
> private Logger logger = LogManager.getLogger(TestDecoderHandler.class);
>
> @Override
> public void channelActive(ChannelHandlerContext ctx) throws Exception {
>
> Channel inboundChannel = ctx.channel();
>
> logger.info("ChannelActive");
> ctx.writeAndFlush("ACK");
> }
>
> @Override
> public void channelRead(ChannelHandlerContext ctx, Object msg) {
>
> logger.info("ChannelRead");
>
> ByteBuf msgBuf = (ByteBuf) msg;
>
> String message = msgBuf.toString(CharsetUtil.UTF_8);
>
> logger.info(message);
>
> }
>
> @Override
> public void channelReadComplete(ChannelHandlerContext ctx) {
> logger.info("ChannelReadComplete");
>
> }
> }
>
> I'm expecting the data to flow from the first netty route, to the seda
> queue. Then from the seda queue to the destination netty component where
> first a handshake is performed inside a custom decoder before the received
> data is sent. Any help would be greatly appreciated.


Re: camel-ftp: meaning of option "UseUserKnownHostsFile" in combination with "knownHostsUri"

2019-06-06 Thread Alex Dettinger
Hi Peter,

  When CAMEL-8202 has been fixed, the isUseUserKnownHostsFile might have
been added to preserve the default behaviour across the camel 2.x line.
But then, the default value should have been false and you would not have
been impacted.

  At the end of the day, setting this option to false is needed as a
workaround in camel 2.x.
  However, I wonder if your idea could deserve creating a ticket against
camel-3.x.

Cheers,
Alex




Re: Null Argument treated as no parameter during method selection

2019-06-02 Thread Alex Dettinger
Hi Ankit,

  I think you have spotted a very specific case. You could help by checking
whether this issue is present in the last camel version.
If it is not fixed there, then building a minimal camel test reproducing
the issue would be the way to go :)

Cheers,
Alex

On Thu, May 30, 2019 at 9:55 AM Ankit Bakshi 
wrote:

> Hi,
>
> I am trying to call Apaches' StringUtils class from my spring XML route
> file.
> I got to with the following code.
>
>  class="com.ericsson.tcrm.bil.customizations.util.ExtendedFieldManagerRouteBean"
> /> 
>
> 
> 
> 
>
> ${bean:org.apache.commons.lang.StringUtils?method=isNotEmpty(${bean:ExtnFieldServ?method=getFieldValueFromExchange(*,in.header.PA_CONTEXT,PaymentMethod)})}
> 
> 
> 
> 
>
> This worked fine when bean:ExtnFieldServ?method=getFieldValueFromExchange
> returned a non-null value. But failed with null.
> Got the following exception
>
> org.apache.camel.component.bean.MethodNotFoundException: Method with name:
> isNotEmpty() (with no parameters) not found on bean:
> org.apache.commons.lang.StringUtils@3030debe of type:
> org.apache.commons.lang.StringUtils. Exchange[Message:
> com.ericsson.etelcrm.bil.common.exec.SessionContext@1bec93f]
>
> So basically camel was looking for a no parameter method when the actual
> argument evaluated to null. This is very strange. I don't know if this is
> normal behavior or a bug.
>
> So I had to think of another way to get the code to work. A couple of
> workarounds would work. One of which is posted below.
>
> 
> 
>
> ${bean:ExtnFieldServ?method=getFieldValueFromExchange(*,in.header.PA_CONTEXT,PaymentMethod)}
> 
> 
> 
> 
> 
>
> ${bean:org.apache.commons.lang.StringUtils?method=isNotEmpty(property.CC_TMP_PAYMM)}
> 
> 
> 
> 
>
> I went with property, the same approach can be taken with headers. Or I
> can create wrapper class around StringUtils which will have methods like
> below, and I would need to declare this wrapper as spring bean or use
> directly if I can using statics.
>
> public boolean isNotBlank()
> {
> return isNotBlank(null);
> }
>
> public boolean isEmpty(String value)
> {
> return org.apache.commons.lang.StringUtils.isEmpty(value);
> }
>
> What I really wanna know if why Camel is looking for  a no parameter
> method when the parameter expression evaluates to null?
>
> Regards,
> Ankit Bakshi
>


Re: Strategy for deleting/moving files

2019-05-18 Thread Alex Dettinger
In this case, chances are that adding .to("file:kind-of-failed-directory")
at some point in the dead letter channel logic helps.
useOriginalMessage() may be of interest too.

Alex

On Sat, May 18, 2019 at 10:14 AM Jonathan Cook 
wrote:

> Thanks for the replies
>
> The moveFailed does do what I want but only when I remove the configured
> errorHandler from my routes. In my error handler I have other logic such
> as sending an email notification. So I don't think I can sue the
> moveFailed unless there is a way to be able to use both?
>
> Thanks
>
> On 17/05/2019 19:03, Jonathan Cook wrote:
> > Hello,
> >
> > I am using the file endpoint with delete=true. My routes pick up files
> > from a directory and then pass through a number of steps, so are
> > reasonably complex. I have a dead letter route where in the event of
> > an error I want to move the original file to a kind of failed
> > directory area.
> >
> > But the problem is that when an error occurs, by the time the code
> > runs inside the dead letter route, the original file has already been
> > deleted by the FileComponent because of delete=true. If I set this to
> > false it works OK but the file stays at the original folder which I
> > don't want.
> >
> > Do I have to manage this myself, i.e not use delete=true and have
> > another step in my route (bean or processor) which would delete or
> > move the file from the original directory at the end of all the
> > processing rather than rely on the file component?
> >
> > Thanks for any suggestions!
> >
> > Paul
> >
>
>


Re: Strategy for deleting/moving files

2019-05-17 Thread Alex Dettinger
Hi Jonathan,

   Depending on the situation, you could try to use
.to("file:kind-of-failed-directory") in the dead letter channel.
   But, it sounds to me that you should not use a dlc and look first at the
moveFailed option of the file-component*:*
*
https://github.com/apache/camel/blob/master/components/camel-file/src/main/docs/file-component.adoc
*

Enjoy :)
Alex

On Fri, May 17, 2019 at 7:03 PM Jonathan Cook 
wrote:

> Hello,
>
> I am using the file endpoint with delete=true. My routes pick up files
> from a directory and then pass through a number of steps, so are
> reasonably complex. I have a dead letter route where in the event of an
> error I want to move the original file to a kind of failed directory area.
>
> But the problem is that when an error occurs, by the time the code runs
> inside the dead letter route, the original file has already been deleted
> by the FileComponent because of delete=true. If I set this to false it
> works OK but the file stays at the original folder which I don't want.
>
> Do I have to manage this myself, i.e not use delete=true and have
> another step in my route (bean or processor) which would delete or move
> the file from the original directory at the end of all the processing
> rather than rely on the file component?
>
> Thanks for any suggestions!
>
> Paul
>
>


Re: Netty4 Little Endian encoding

2019-04-27 Thread Alex Dettinger
Hi Yogesh,

  From the documentation, it looks that the encoding is used only when the
textline codec is activated.

https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc

  So it's worth trying something like:
  

hth,
Alex

On Fri, Apr 26, 2019 at 11:31 PM Yogesh Chawla 
wrote:

> Hello,
> I am trying to send TCP data over a socket connection to a server written
> in .NET. They are trying to decode what I send and are expecting Unicode
> Little Endian with no byte order marking. In .NET this is done as follows:
>
> Encoding encoder = new System.Text.UnicodeEncoding(false, false);
> byte[] byteData = encoder.GetBytes(data);
>
> To do this, I am trying to use Netty to send Unicode Little Endian
> encoding. I thought it would be as simple as:
>
> 
>
> Ignore the IP above. I though the argument "encoding=UTF-16LE" would do it.
> Is there a way we can tell what encoding's the netty4 endpoints allows? Any
> tips on how I can have the message encoded in UTF-16LE format?
>
> Thanks!
> Yogesh
>


Re: using jsonpath for choice

2019-03-27 Thread Alex Dettinger
Hi Rajith,

  Not sure we are in the same context but I think it's worth trying this
expression: $[?(@.approved == true)].

hth,
Alex

On Tue, Mar 26, 2019 at 9:41 PM Rajith Muditha Attapattu 
wrote:

> Thanks for the response Larry.
> The camel version is 2.20.1
> And I do have the camel-jsonpath dependency
>
> The when clause expects a predicate, and I think it's bcos that expression
> doesn't evaluate to a boolean (I stand to be correct though).
>
> On Mon, Mar 25, 2019 at 4:45 PM Larry Shields 
> wrote:
>
> > I'm using the Jsonpath functionality in a split() with the syntax you
> have
> > without any issue.  What version of camel and do you have the
> > camel-jsonpath dependency?
> >
> > On Mon, Mar 25, 2019 at 4:29 PM Rajith Muditha Attapattu <
> > rajit...@gmail.com>
> > wrote:
> >
> > > Is there a better way to do the following ?
> > >
> > >
> >
> .when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))
> > >
> > >
> > > as in
> > > .when().jsonpath(...)
> > >
> > > Already tried .when().jsonpath("$.approved[?(@ == true)]") and it
> doesn't
> > > work.
> > >
> > > --
> > > Regards,
> > >
> > > Rajith Muditha Attapattu 
> > >
> >
>
>
> --
> Regards,
>
> Rajith Muditha Attapattu 
>


Re: File polling issue for filename with multiple dots

2018-11-15 Thread Alex Dettinger
Hi Guillaume,

  Welcome on camel 2.22.x :) I've reported issue
https://issues.apache.org/jira/browse/CAMEL-12940 and provided a fix.
You should be able to check the fix against 2.23.0-SNAPSHOT tomorrow, or
wait for the release of CAMEL-2.22.3.

Enjoy,
Alex

On Thu, Nov 15, 2018 at 3:17 PM DEIMAT Guillaume <
guillaume.dei...@soprasteria.com> wrote:

> Hi guys,
>
> I'm working on un upgrade from Camel 2.6.0 to 2.22.x (yeah... this is huge
> step !!) and need some help for an issue with file polling.
> I'm not very familiar with this framework, so I'll try to give enough info
> to expose our issue. If I'm not, sorry for that !
>
> Our application read file from a given directory which follow the format :
> _MMdd_HHmmss.SSS.ebt
> It was working fine in 2.6.0, but after the upgrade our file are not
> consumed and stay in entry directory.
>
> After a few hours of debugging, I finally found why.
> It's because our file names contains two dots, and the GenericFileEndpoint
> class uses FileUtil.stripExt() function to generate the done file name.
> This function has been updated for CAMEL-9064 issue to work in "single
> mode" and the GenericFileEndpoint does not appear to have been updated too
> (don't know this stuff very well to say if he should have been or not).
>
> Code from GenericFileEndpoint.createDoneFileName
> --
> [...]
> pattern = pattern.replaceFirst("\\$\\{file:name.noext\\}",
> FileUtil.stripExt(onlyName));
> pattern = pattern.replaceFirst("\\$simple\\{file:name.noext\\}",
> FileUtil.stripExt(onlyName));
> [...]
>
> Code from GenericFileEndpoint.createDoneFileName
> --
> public static String stripExt(String name) {
> return stripExt(name, false);
> }
>
> public static String stripExt(String name, boolean singleMode) {
>  [...]
> }
>
> Our road is defined this way :
> --
>
>  
> from("file:?sortBy=reverse:file:modified=B_[A-Z]{3,30}_01.*\.ebt$=UTF-8=true=${file:name.noext}.done",
> "direct:flux04")
>.process(new OurProcessor())
>.to("cxf://ourEndpoint...")
>
>
> We updated our source application to generate file names with a single dot
> for extension, but for compatibility reason we need to read both file names
> (with a single dot & with multiple dots).
> I don't know how to proceed :
> 1) It's really an issue in GenericFileEndpoint => so we just have to
> wait for a patch or even submit it if we are good enough to :)
> 2) Maybe we can set a parameter to accept files with multiple dots in
> their file names => does not seem to be possible in all documentations I
> read
> 3) Or we should extends GenericFileEndpoint to get the behavior that
> we need => I don't know how to proceed for that
>
> Thanks a lot for your help,
>
> Guillaume
>


Re: camel-cxfrs : Urls getting interchanged when CamelDestinationOverrideUrl is used

2018-10-31 Thread Alex Dettinger
Hi Sowjanya,

  It reminds me CAMEL-12252
.
Do you hit the same issue with the last camel version ?
If yes, could you please provide a test reproducing the bug ?

  Links that could be related:
https://github.com/apache/camel/pull/2218
https://github.com/aldettinger/camel/blob/ed07bef9b521133abb7dd20c2b0e698eaad4b053/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java
https://github.com/Talend/apache-camel/blob/master/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringProducerAddressOverride.xml

Alex

On Wed, Oct 31, 2018 at 12:49 AM Sowjanya Mudimala <
sowjanya.mudim...@gmail.com> wrote:

> Hi,
>
> I have a camel route where I am setting Exchange.DESTINATION_OVERRIDE_URL
> header to set a dynamic endpoint url to cxfrs producer component.
>
> Issue with that is lot of times url from previous exchanges is getting set
> instead of the freshly calculated url for the current exchange.
>
> In order to fix the issue, I had to configure maxClientCacheSize = 1 on the
> cxfrs component.  Below information from
> http://camel.apache.org/cxfrs.html.
>
> New in 2.6, you can set a IN message header CamelDestinationOverrideUrl to
> dynamically override the target destination Web Service or REST Service
> defined in your routes.  The implementation caches CXF clients or
> ClientFactoryBean in CxfProvider and CxfRsProvider.  This option allows you
> to configure the maximum size of the cache.
>
> I looked at the  JAXRSClientFactoryBean code where it caches
> ClientFactoryBean but not getting what caused this issue.
> was causing issue in the first place. please suggest.
>
> sample trace log for one of the addresses:
> [TRACE]: org.apache.camel.component.cxf.CxfEndpointUtils - Client address
> is overridden by header 'CamelDestinationOverrideUrl' to value '
>
> https://api.dev.foo.com/dev-ecbo/event/12345/survey?%26%24select%3DQuestion&$expand=Question%28%24filter%3DHelp+eq+%27What+department+are+you+in%3F%27+or+Help+eq+%27What+industry+are+you+in%3F%27+or+Help+eq+%27What%E2%80%99s+your+job+level%3F%27+%29&$filter=+%28Question%2Fany%28x%3A+x%2FHelp+eq+%27What+department+are+you+in%3F%27%29+or+Question%2Fany%28x%3A+x%2FHelp+eq+%27What+industry+are+you+in%3F%27%29+or+Question%2Fany%28x%3A+x%2FHelp+eq+%27What%E2%80%99s+your+job+level%3F%27%29%29
> '
>
>
> Thanks,
> Sowjanya.
>


Re: [HEADS UP] Camel K is here!

2018-10-19 Thread Alex Dettinger
Whaoo, I've had a look at introducing-camel-k
 from Nicolas
and that's awesome.
Well done guys !

On Thu, Oct 18, 2018 at 4:25 AM Willem Jiang  wrote:

> Yeah,  it's great to see we can use Camel more easily with K8S.
> It's awesome that camel-k can be a part of Camel 3 :)
>
> Regards,
>
> Willem Jiang
>
> Twitter: willemjiang
> Weibo: 姜宁willem
>
> On Wed, Oct 17, 2018 at 6:24 AM Nicola Ferraro 
> wrote:
> >
> > Hi folks,
> > after some months of brainstorming with the community and a bit more than
> > one month of development, our Camel K project has reached a good level of
> > stability and I've published the first blog post about it yesterday.
> >
> > For those of you who haven't heard of Camel K, it's now a subproject of
> > Apache Camel (https://github.com/apache/camel-k) with the target of
> > building a lightweight runtime for running integration code directly on
> > cloud platforms like Kubernetes and Openshift. It was inspired by
> > "serverless" principles and it will also target Knative shortly.
> >
> > With the exception of the runtime code, that remains the good old Camel
> > Java framework with 200+ components and full of EIPs, most of the
> > "operator" code in Camel K is written in Go. But the new language has not
> > stopped many adventurer Camel developers that have actively contributed
> to
> > the project during last month. We still have a long way in front of us,
> > let's continue to make Camel great!
> >
> > So, please.. check the project out! Spread it to the world!
> > And provide your feedback, so we can make it always better. We love any
> > kind of contribution!
> >
> > Links follow..
> >
> > Announcement: https://twitter.com/ni_ferraro/status/1051872786946363392
> > Article: https://www.nicolaferraro.me/2018/10/15/introducing-camel-k/
> > Home: https://github.com/apache/camel-k
> >
> > Nicola
>


Re: Apache Camel JAXB unmarshalling returns null properties after upgrade from Camel from 2.20.4 to 2.21.2 or 2.22.1

2018-10-10 Thread Alex Dettinger
Hi Lars,

  You're right, this behavior changed in jaxb-impl 2.3.0.

  You may workaround by force downgrading the version in your pom file:

com.sun.xml.bind
jaxb-impl
2.2.11


  Or changing your class definition with something as below:
@XmlRootElement(name = "entry", namespace = "http://www.w3.org/2005/Atom;)
@XmlAccessorType(XmlAccessType.FIELD)
public class SuccessResponse {
@XmlElement(namespace = "http://www.w3.org/2005/Atom;)
private String id;
...
}

HTH,
Alex

On Wed, Oct 10, 2018 at 11:26 AM Lars Schaps  wrote:

> Hello again.
> Sorry, for posting again, but it seems my digital signature cause problem.
> Did not expect that.
>
> Lars
>
> > Hi all.
> >
> > Sorry for cross posting. I already asked this question on Stack Overflow
> > before I found the mailing list:
> >
> https://stackoverflow.com/questions/52716828/apache-camel-jaxb-unmarshalling-
> > returns-null-properties-after-upgrade-from-camel
> >
> > After upgrading Apache Camel from 2.20.4 to 2.21.2 or even 2.22.1 a unit
> test
> > of my fails and I can't see why.
> >
> > I have a route, which receives an XML response, which I want to
> unmarshal into
> > a data class. This fails since Apache Camel 2.21.2.
> >
> > The JAXB context knows all data classes in the given package and picks
> the
> > right class. The unmarshaller creates the right object, but the
> properties
> > stay null. With debugging the SAX parser, it seemed as if the SAX parser
> > deliberately ignores the text between the tags.
> >
> > I have seen on the Camel website that Camel 2.21.0 "Upgraded to JAXB
> 2.3.0". I
> > don't know what that means for me.
> >
> > My route looks like this:
> >
> > @Component
> > public class NewsletterRoute extends RouteBuilder {
> >
> > 8<-
> >
> > @Override
> > public void configure() {
> > final DataFormat marshalFormat =
> > new JacksonDataFormat(HybrisRequest.class);
> > final JaxbDataFormat unmarshalFormat = new JaxbDataFormat();
> > unmarshalFormat.setContextPath(
> >SuccessResponse.class.getPackage().getName());
> >
> > from(URI)
> > .routeId("subscribeRoute")
> > // Fetch the auth token to send it as 'x-csrf-token' header.
> > .setHeader(Exchange.HTTP_URI,
> > method(this.backendUrlProvider, "getUrl"))
> > .setHeader(Exchange.HTTP_PATH,
> >  constant(this.subscribeUnsubscribePath))
> > .setHeader(Exchange.HTTP_METHOD, HttpMethods.POST)
> > .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> > // Marshal body to JSON
> > .marshal(marshalFormat)
> > .to(String.format("https4:backend" +
> > "?sslContextParameters=hybrisSslContextParams" +
> > "=hybrisHostnameVerifier" +
> > // don't throw on 3XX/4XX/5XX since
> > // we need the response body
> > "=false" +
> > "=#hybrisCookieStore" +
> > "=%s" +
> > "=%s" +
> > "=true" +
> > "=true" +
> > "=3" +
> > "=%d" +
> > "=%d",
> > "RAW(" + username + ")",
> > "RAW(" + password + ")",
> > backendTimeoutMillis,
> > backendTimeoutMillis))
> > .convertBodyTo(String.class)
> > // Store the received response as property before
> > // trying to unmarshal it
> > .setProperty(PROPERTY_RESPONSE_RAW, body())
> > .unmarshal(unmarshalFormat);
> > // @formatter:on
> > }
> > }
> >
> >
> > The data class looks like this
> >
> > @XmlRootElement(name = "entry", namespace = "http://www.w3.org/2005/Atom
> ")
> > public class SuccessResponse {
> > private String id;
> > private String title;
> > public String getId() { return id; }
> > public void setId(String id) { this.id = id; }
> > public String getTitle() { return title; }
> > public void setTitle(String title) { this.title = title; }
> > public String toString() { /*code cut out*/}
> > }
> >
> >
> > With Apache Camel 2.20.4 my unit test worked. With 2.21.2 and 2.22.1 it
> > breaks. The problem is, that the unmarshaler won't fill the properties.
> >
> > The unit test just sends a valid request to Mockito, which returns the
> XML.
> >
> > 
> >  > xml:base="
> https://xxx.xxx.xxx.xxx:44380/sap/opu/odata/sap/CUAN_IMPORT_SRV
> > /"
> > xmlns="http://www.w3.org/2005/Atom;
> > xmlns:m="
> http://schemas.microsoft.com/ado/2007/08/dataservices/metadata;
> > xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices;>
> >  -->
> > bla
> > blub
> > 
> >
> >
> > Any ideas?
> >
> > Thanks
> > Lars
>


Re: Using same queue multiple times in a circuit

2018-09-23 Thread Alex Dettinger
Hi Damien,

  from("jms:queue:queue1") reads messages once at a time.
Using from("jms:queue:q1?concurrentConsumers=2") may help but imply
consequences in terms of resources, thread safety, readability...

  In such a situation, I would avoid reusing q1 if possible. For instance,
you may be able to model the whole circuit in the dynamic router and do
something like:
  from(jms:queue:q1).dynamicRouter().method(DynamicRouterTest.class,
"nextStep");
  from(direct:p1).process(p1);
  from(direct:p2).process(p2);
  from(direct:p3).process(p3);

Hope this help,
Alex


On Sun, Sep 23, 2018 at 11:59 AM Damien Nicolas 
wrote:

> I have several Camel routes defining a "circuit" like this (where `qx` is
> the queue number x, `px` is the processor number x)
>
> q1 -> p1 -> q2 -> p2 -> q1 -> p1 -> q3 -> p3 -> (...)
>
> as
>
>
>
> from("jms:queue:q1).process("p1").dynamicRouter().method(DynamicRouterTest.class,
> "nextStep");
> from("jms:queue:q2).process("p2").to("jms:queue:q1");
> from("jms:queue:q3).process("p3").to(...);
>
>
> As you can notice, I reuse the queue `q1` (for achitectural purpose), the
> `dynamicrouter` indicate dynamically the destination when a message comes
> from `q1`, but when the message arrives at `p2`, I get a timeout exception
> in this style:
>
> 2018-09-22 14:21:21,443 [Camel (camel-1) thread #6 -
> JmsConsumer[QueueTest]] WARN
> org.apache.camel.component.jms.EndpointMessageListener  - Execution of JMS
> message listener failed. Caused by: [org.apache.camel.RuntimeCamelException
> - org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 2 millis due reply message with correlationID:
> ID:373034334442 not received.
>
> How can I make it works without disabling jms replying?
>
> --
> Damien NICOLAS
>


Re: UDP: Netty4 vs. Mina2

2018-09-15 Thread Alex Dettinger
Ron,

  I think there is room for improvement there. I opened
https://issues.apache.org/jira/browse/CAMEL-12813 to setup a proposal in
this respect.
Would you like to have a try with a contribution
https://github.com/apache/camel/blob/master/CONTRIBUTING.md ? Or, I could
take over if you prefer.

Alex

On Fri, Sep 14, 2018 at 9:50 PM Ron Cecchini 
wrote:

>
> Ok, last post.  But I just fixed the route, sans "hack.  And since I've
> seen lots of other people having problems with Netty, maybe this will help
> them.
>
>
> Instead of the transform().method(...) call, just do:
>
>
> .convertBodyTo(String.class, “UTF-8”)
>
> Problem solved.
>
> (Holy cow did this take me too long to figure out...)
>
>
> > On September 14, 2018 at 3:38 PM Ron Cecchini wrote:
> >
> >
> > Hi, Alex. Thank you you for your help.
> >
> >
> > I had read all of those pages (amongst the million or so I
> scanned...) but your comment made it clearer as to what's possibly going on.
> >
> >
> > As it turned out, earlier today I accidentally stumbled upon a
> hackish solution (think: Infinite Monkey Theorem) which fixed my Netty4/UDP
> write problems.
> >
> >
> > I didn't have to use any encoders/decoders. (And OMG, that was a
> Dante-esque trip through Hell ... no offense, Claus; I love Camel).
> >
> >
> > I just had to do this one transform() (see below) ... which, I'm
> still not sure what's going on, as the bean's method is simply returning
> the passed in JSON string as a String ... and that was all that was needed.
> I guess the method is setting something on the Exchange's OutBody (?) that
> is making everything kosher for Netty?
> >
> >
> > Of course, a String is serializable, but why couldn't I just go
> directly from the endpoint (which is already returning a string
> representing a JSON array) to Netty?
> >
> >
> > Anyway, here's the full text of my Server's route builder, along
> with the hack.
> >
> >
> > I would love to hear how this fixed my route!
> >
> >
> > Thank you again.
> >
> >
> > -
> >
> >
> > @Component
> > public class Route extends RouteBuilder
> > {
> > @Override
> > public void configure () throws Exception
> > {
> > restConfiguration()
> > .host("localhost").port(8080)
> > .bindingMode(RestBindingMode.json);
> >
> > from("timer:autos?period={{timer.period}}")
> > .streamCaching()
> > .to("rest:get:auto/list")
> > .to("direct:udp");
> >
> > from("direct:udp")
> > .log("*** BEFORE write to UDP: ${body}")
> > .transform().method("myBean", "foo") // XXX: this one line hack
> fixed it
> >
>  .to("netty4:udp://localhost:4?udpConnectionlessSending=true=false")
> > .log("*** AFTER write to UDP: ${body}");
> > }
> >
> > @Component("myBean")
> > public class Encoder
> > {
> > public String foo (String val) {
> > return val;
> > }
> > }
> > }
> >
> >
> > -
> >
> > > > On September 14, 2018 at 1:23 PM Alex Dettinger wrote:
> > >
> > >
> > > Hi Ron,
> > >
> > > By default, camel-netty4 includes default codecs based on java
> > > serialization. So, it could be that your payload is NOT
> Serializable.
> > > You would then need to configure codecs matching your case.
> > >
> > > You may find below links of interest:
> > >
> https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc#using-multiple-codecs
> > >
> https://github.com/apache/camel/blob/master/components/camel-netty4/src/test/resources/org/apache/camel/component/netty4/multiple-codecs.xml
> > >
> https://github.com/apache/camel/blob/master/components/camel-ganglia/src/test/java/org/apache/camel/component/ganglia/GangliaProtocolV31CamelTest.java#L214-L257
> > >
> > > Hope this help,
> > > Alex
> > >
> > > On Fri, Sep 14, 2018 at 12:26 AM Ron Cecchini
> > > wrote:
> > > > > I'll try a shorter version of my question:
> > >
> > > > > > Why does this work:
> > > &

Re: UDP: Netty4 vs. Mina2

2018-09-14 Thread Alex Dettinger
Hi Ron,

By default, camel-netty4 includes default codecs based on java
serialization. So, it could be that your payload is NOT Serializable.
You would then need to configure codecs matching your case.

You may find below links of interest:
https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc#using-multiple-codecs
https://github.com/apache/camel/blob/master/components/camel-netty4/src/test/resources/org/apache/camel/component/netty4/multiple-codecs.xml
https://github.com/apache/camel/blob/master/components/camel-ganglia/src/test/java/org/apache/camel/component/ganglia/GangliaProtocolV31CamelTest.java#L214-L257

Hope this help,
Alex

On Fri, Sep 14, 2018 at 12:26 AM Ron Cecchini 
wrote:

> I'll try a shorter version of my question:
>
>
> Why does this work:
>
>
> .to("mina2:udp://localhost:4?sync=false")
>
> ...
>
> from("mina2:udp://localhost:4?sync=false")
>
>
> and this doesn't work:
>
>
> .to("netty4:udp://localhost:4?sync=false")
>
> ...
>
> from("netty4:udp://localhost:4?sync=false")
>
>
> In particular, the netty4:udp *write* fails.
>
>
> Thanks.
>
>
> p.s.  I found something about using the 'encoder/decoder' params.  But I
> don't see anything in the docs or book about it being necessary.  Is it
> required?  All I'm trying to do is write some JSON I got from a Rest call.
>
>


Re: Split with regex and group not working

2018-06-19 Thread Alex Dettinger
Hi Rory,

  If I get it well the whole regex is inserted between lines while you were
expecting to insert only the matching part of the regex.
In that case, you are welcome to work on a fix or open a ticket.

  At Apache Camel, we love contributions ;)
https://github.com/apache/camel/blob/master/CONTRIBUTING.md

Many thanks,
Alex

On Tue, Jun 19, 2018 at 1:24 PM, Rory Gilfillan 
wrote:

> The following code doesn't work:
>
>.split().tokenize("\n|\r\n", true, 100, true)
>
>
> It tries to reinsert the token between the lines without taking into
> account that the token is a regex string.
>
>
> The follow code in the GroupTokenIterator is the culprit:
>
> // include token in between
> if (data != null && count > 0 && token != null) {
> bos.write(token.getBytes());
> }
>
>
> The contents of this email and any attachments are confidential, may be
> privileged and may only be read and used by the named recipient(s). If you
> have received it in error please contact the sender immediately and delete
> the e-mail. We endeavour to exclude viruses from our emails, but it is your
> responsibility to check this email for viruses. ITQ Business Solutions
> (Pty) Ltd accepts no liability or responsibility of whatsoever nature for
> any failure or loss arising in any way from the use of email as a means of
> communication.
>


Re: Camel and ActiveMQ ObjectMessage

2018-05-29 Thread Alex Dettinger
Hi John,

  I wonder if you could be interested in "messageConverter", e.g:
https://github.com/apache/camel/blob/master/components/camel-jms/src/test/java/org/apache/camel/component/jms/ConsumeMessageConverterTest.java

Regards,
Alex


On Tue, May 29, 2018 at 7:08 PM, John fansler 
wrote:

> As of ActiveMQ version 5.12, you have to whitelist the objects used by any
> message that is of type ObjectMessage. I believe the default in Camel is to
> handle the serialization when producing and consuming from message queues
> which results in an ObjectMessages.
>
> I know we can explicitly call “marshal()” before producing a message and
> “unmarshal()” after consuming a message to avoid the ObjectMessage type.
>
> Is there a cleaner way to produce and consume from ActiveMQ that does not
> require explicit marshal/unmarshall calls around every message queue?
>
> We are currently using camel version 18.3.
>
> Thanks,
>
> -john
>
>
>
>


Re: can not locate rest api

2018-05-29 Thread Alex Dettinger
Hi Ranabroto,

  Last time I hit a similar issue, I ended up with something like "
http://localhost:8084/camel/test;.
Also, if you are deploying in minishift, you would need to force address
resolution, example at
https://github.com/aldettinger/validator-service#how-could-i-invoke-the-validator-service-on-minishift-
.

Hope this help,
Alex

On Mon, May 28, 2018 at 1:47 PM, Ranabroto Ghosh <
ranabroto.gh...@globalcharge.com> wrote:

> My rest route if requires
>
> http://camel.apache.org/schema/spring;>
> 
> 
> 
> 
> 
> 
>
> On 28 May 2018 at 12:43, Ranabroto Ghosh  >
> wrote:
>
> > Hi I am using springboot with Camel, my routes are getting started
> > correctly but ca not trigger rest apis as i ca not locate them.
> >
> > *pom.xml *
> > 
> > http://maven.apache.org/POM/4.0.0; xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance;
> > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/xsd/maven-4.0.0.xsd;>
> > 4.0.0
> > com.camel
> > spring-camel
> > 0.0.1-SNAPSHOT
> > jar
> >
> > spring-camel
> > Demo project for Spring Boot
> > 
> > UTF-8
> > UTF-8 reporting.outputEncoding>
> > 1.8
> > 2.21.0
> > 
> >
> > 
> > 
> > org.apache.camel
> > camel-spring-boot-starter
> > ${camel.version}
> > 
> > 
> > org.apache.camel
> > camel-restlet
> > ${camel.version}
> > 
> > 
> >
> > 
> > 
> > 
> > org.springframework.boot
> > spring-boot-maven-plugin
> > 
> > 
> > 
> > 
> >
> >
> > *application.xml*
> > camel.springboot.xmlRoutes = true
> > camel.springboot.xmlRoutes = classpath:xml-route/*.xml
> > camel.springboot.main-run-controller=true
> > camel.springboot.xmlRests = true
> > camel.springboot.xmlRests = classpath:xml-rest/*.xml
> > server.port = 8084
> > spring.application.name = spring-camel
> >
> > *Springboot Main class:*
> >
> > @SpringBootApplication
> > @EnableAutoConfiguration
> > public class SpringCamelApplication {
> >
> > public static void main(String[] args) {
> > SpringApplication.run(SpringCamelApplication.class, args);
> > }
> > }
> >
> >
> > *LOG after application started:*
> >
> > 2018-05-28 12:34:46.178  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : StreamCaching is not in use. If using streams then its recommended
> to
> > enable stream caching. See more details at http://camel.apache.org/
> > stream-caching.html
> > 2018-05-28 12:34:46.211  INFO 4852 --- [   main]
> > o.a.camel.component.file.FileEndpoint: Endpoint is configured with
> > noop=true so forcing endpoint to be idempotent as well
> > 2018-05-28 12:34:46.211  INFO 4852 --- [   main]
> > o.a.camel.component.file.FileEndpoint: Using default memory based
> > idempotent repository with cache max size: 1000
> > 2018-05-28 12:34:46.357  INFO 4852 --- [   main]
> > o.a.camel.spring.boot.RoutesCollector: Starting
> > CamelMainRunController to ensure the main thread keeps running
> > 2018-05-28 12:34:46.361  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : Route: first-route started and consuming from: direct://test
> > 2018-05-28 12:34:46.374  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : Route: second-route started and consuming from:
> > file://E://inputFolder?noop=true
> > 2018-05-28 12:34:46.384  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : Route: route1 started and consuming from: restlet:///test?
> > restletMethods=GET
> > 2018-05-28 12:34:46.385  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : Total 3 routes, of which 3 are started
> > 2018-05-28 12:34:46.388  INFO 4852 --- [   main]
> o.a.camel.spring.SpringCamelContext
> > : Apache Camel 2.21.0 (CamelContext: camel-1) started in 0.471
> seconds
> > 2018-05-28 12:34:46.395  INFO 4852 --- [   main] c.c.springcamel.
> SpringCamelApplication
> >  : Started SpringCamelApplication in 3.543 seconds (JVM running for
> 3.878)
> > 2018-05-28 12:34:47.389  INFO 4852 --- [E://inputFolder] second-route
> >: ROUTE STARTED
> >
> >
> >
> > So clearly it says ' route1 started and consuming from: restlet:///test?
> restletMethods=GET'
> > but when i call http:localhost:8084/test its says unreachable.
> >
> >
> > Badly need help, thanks in advance.
> > --
> > Kind Regards
> > Rana
> >
>
>
>
> --
> Kind Regards
> Rana
>


Re: Camel Splitter Group attribute injection not working

2018-05-18 Thread Alex Dettinger
Hi Gary,

  Yes, the first extract should work. The second one is at least missing
some double quotes around the group xml attribute (should be
group="{{noOfLines}}").

Alex

On Fri, May 18, 2018 at 5:43 PM, Mills, Gary (GE Digital) <
gary.l.mi...@ge.com> wrote:

> Hello,
>
> can you inject a value from the config params file in to the splitter
> group attribute? if so, what is the proper way of doing it? thanks!
>
> Is this possible? What am I doing wrong? Thank you!
>
> 
>  
> 
>  
>
> 
>  
> 
>  
>
> Gary Lee Mills
> Work:  331-777-2318
>
>
>


Re: DirectConsumerNotAvailableException: No consumers available on endpoint

2018-04-26 Thread Alex Dettinger
You may be interested in routes startupOrder

or the block option

which you may need to set to true on your own in 2.19.5.

On Thu, Apr 26, 2018 at 6:24 PM, Martin Lichtin 
wrote:

> After upgrading from 2.18 to 2.19.5, I'm often seeing this exception at
> startup.
> It looks like the auto-started route is not immediately ready?
>
> Using a producer template, it can happen that
> "DirectConsumerNotAvailableException" is thrown.
> At next try (e.g. a second later) it works.
> How can this be avoided?
>
> org.apache.camel.component.direct.DirectConsumerNotAvailableException: No
> consumers available on endpoint: direct://myRoute.
> Exchange[ID-mypc-27743-1524756340687-3-2]
> at org.apache.camel.component.direct.DirectProducer.process(Dir
> ectProducer.java:55)
> at org.apache.camel.processor.CamelInternalProcessor.process(Ca
> melInternalProcessor.java:198)
> at org.apache.camel.processor.DelegateAsyncProcessor.process(De
> legateAsyncProcessor.java:97)
> at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerC
> ache.java:529)
> at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerC
> ache.java:497)
> at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCac
> he.java:365)
> at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCac
> he.java:497)
> at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:225)
> at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultPr
> oducerTemplate.java:144)
> at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHea
> ders(DefaultProducerTemplate.java:257)
>
>
> Thanks
>
> - Martin
>
>


Re: Writing file content from a custom header

2018-03-30 Thread Alex Dettinger
Hi Johnathan,

  Writing files directly from a header is not possible afair.
  In such situation, you would merely set the body from the DSL, something
like: setBody(simple("${in.header.FILE}")).

  Depending on your integration logic, you may also be interested in the
new claim check eip implementation:
https://github.com/apache/camel/blob/camel-2.21.x/camel-core/src/main/docs/eips/claimCheck-eip.adoc

Regards,
Alex


On Fri, Mar 30, 2018 at 1:47 PM, Jonathan Cook  wrote:

> Hi,
>
> I wondered if it was possible when using a file producer when writing file
> content to take the file from a custom header rather than the message body?
>
> For example imagine in one processor I store the file for later e.g)
>
> message.setHeader("FILE_OBJECT", file);
>
> Then later is there a way when I do .to(file:/.. to use the file object
> inside the header "FILE_OBJECT" as the message exchange if you see what I
> mean?
>
> I could easily create another bean or processor to do this but wondered if
> it was already possible with the DSL somehow?
>
> Thanks
>
>


Re: Filtering files with the File2 component

2018-02-21 Thread Alex Dettinger
Hi Meissa,

  I've read it quickly. But, it may be that just need to include xml files
and that's all:
from("file:loans?include=.*xml")

Regards,
Alex

On Wed, Feb 21, 2018 at 8:53 AM, Meissa Sakho  wrote:

> Hello everyone,
> I need to write a route with the requirements below:
> 1) The route will pool a source folder and takes only files whose name ends
> with .xml
> 2) The source file content must be saved into a single journal file named
> loan.xml
> 3)If a file name ends with .txt, it should not be included in the message.
>
> I'm trying to combine the include and the exclude option to achieve this.
> Below is an extract of my route:
>
> public void configure() throws Exception {
>
>from("file:loans?include=.*xml=.*txt")
>.to("file:loans/results?fileName=loan.txt=Append");
>
>
> It's not working as expected.
> Do you have any idea about how to include only files ending with a defined
> value and excluding others?
>
> thanks,
> Meissa
>


Re: JMS: override Camel header type conversions?

2018-02-12 Thread Alex Dettinger
Same as Quinn, I would vote for the ISO-8601 standard. However, I would
consider delaying the change to camel 3.0 or making it optional.

On Mon, Feb 12, 2018 at 9:50 PM, Quinn Stevenson <
qu...@pronoia-solutions.com> wrote:

> If it’s going to change, I would vote for the ISO-8601 format - that’s
> what I use for all my timestamps in logs and such.
>
>
> > On Feb 12, 2018, at 12:07 PM, Claus Ibsen  wrote:
> >
> > Hi
> >
> > Maybe it sounds like a better idea to use a iso-xxx date to be
> > consistent, instead of a toString that may be OS locale dependent etc.
> >
> > Or it could store the value as a long value of the epoc.
> >
> >
> >
> >
> > On Mon, Feb 12, 2018 at 12:19 PM, Quinn Stevenson
> >  wrote:
> >> Sorry - ignore that.  That feature is used to customize the mapping of
> the key names - not the values.
> >>
> >> The only way I can think of right off hand is to add you’re own bean
> that manipulates the header values before you send them.
> >>
> >>
> >>> On Feb 12, 2018, at 10:14 AM, Quinn Stevenson <
> qu...@pronoia-solutions.com> wrote:
> >>>
> >>> You can provide your own implementation using the jmsKeyFormatStrategy
> URI Option.
> >>>
> >>>
> >>>
>  On Feb 12, 2018, at 8:34 AM, Probert, Matt <
> matt.prob...@metoffice.gov.uk> wrote:
> 
>  When messages are produced to ActiveMQ, Camel JmsBinding converts
> java.util.Date message headers to string via Date.toString().
> 
>  I want to override the conversion, to give IS0 8601 strings.
> 
>  Is there a way to inject a custom JmsBinding to do it? Or some other
> standard way? I don't want to modify existing route definitions, if
> possible.
> 
>  I'm using the camel-activemq component, Camel 2.14.1, ActiveMQ 5.7.0.
> Routes are defined in the spring XML DSL.
>  Cheers,
>  Matt
> >>>
> >>
> >
> >
> >
> > --
> > Claus Ibsen
> > -
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>


Re: Retrying a message from a specific point of the route

2018-02-09 Thread Alex Dettinger
Hi Hemant,

   I have no more idea that would help you to achieve this with TOS. In
such a situation, I would ask guidance to the Talend community to check if
it would be possible with a home made custom Talend component. Or, rethink
the case globally to avoid tweaking the TOS way.

Regards,
Alex

On Thu, Feb 8, 2018 at 11:58 AM, Hemant Pekhale <hemant.pekh...@gmail.com>
wrote:

> Hi Alex,
> Thanks for reply.
>
> Actually I am using talend open studio for this and the option
> “NoErrorHandler” is not available in ErrorHandler component provided by
> talend. And this option is required to achieve the goal (as mentioned in
> the post you pointed). Do you see any other way to achieve this?
>
> Thanks in advance!
>
> From: Alex Dettinger
> Sent: Monday, February 5, 2018 16:32
> To: users@camel.apache.org
> Subject: Re: Retrying a message from a specific point of the route
>
> Hi,
>
>   You may find this trick
> <http://camel.apache.org/how-do-i-retry-processing-a-
> message-from-a-certain-point-back-or-an-entire-route.html>
> of interest in order to influence the redelivery.
>
> Enjoy,
> Alex
>
> On Mon, Feb 5, 2018 at 7:40 AM, Hemant Pekhale <hemant.pekh...@gmail.com>
> wrote:
>
> > Hi,
> >
> > How to retry a message from a specific point of the route when exception
> > occurs.
> > I am using camel 2.15 and Spring configuration.
> > Some example is most appreciated.
> >
> > Thanks!
> >
>
>


Re: Retrying a message from a specific point of the route

2018-02-05 Thread Alex Dettinger
Hi,

  You may find this trick

of interest in order to influence the redelivery.

Enjoy,
Alex

On Mon, Feb 5, 2018 at 7:40 AM, Hemant Pekhale 
wrote:

> Hi,
>
> How to retry a message from a specific point of the route when exception
> occurs.
> I am using camel 2.15 and Spring configuration.
> Some example is most appreciated.
>
> Thanks!
>