Re: HttpServletRequest and Platform HTTP

2023-10-18 Thread Fyodor Kravchenko

Hi, thank you!

Good that the http headers are abstracted from the actual underlying 
http technology.


What about Cookies? Will getHeader(Exchange.COOKIE_HANDLER) work with 
the Platform Http? Couldn't find if I can specify anything like 
"|?cookieHandler=#exchangeCookieHandler|" in the route url... Or can I 
access and parse the multiple cookie *headers* from the Message?


Accessing the Vert.x objects in Camel 4.2.0 is good, but what if we 
decide to switch platform in the future (again :) Would be nice to have 
a cookie handler or some other session abstraction.


Regards,

Fyodor

On 17.10.2023 10:59, Claus Ibsen wrote:

Hi

You usually just set the a camel message header with the HTTP key/value for
redirect, something ala:


exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);
 exchange.getMessage().setHeader("location", "http
url of the redirect location");


On Mon, Oct 16, 2023 at 1:17 PM Fyodor Kravchenko  wrote:


Thank you, Claus, I'll get familiarized myself with the Vert.X
internals! In the meantime, there must be some way to "send redirect"
(respond with the 302 header) by the Camel means, can you please give
some hint on that?

On 16.10.2023 11:18, Claus Ibsen wrote:

Hi

I created a ticket
https://issues.apache.org/jira/browse/CAMEL-19994

Yeah check vertx-http docs what it offers
https://vertx.io/docs/vertx-web/java/



On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko 

wrote:

Hi, thanks, I get that. And without the Vertx object, what would be a
correct way to obtain somewhat like a session attributes? I'm having
trouble to navigate the documentation and find "vertx-http" description,
can't get how to see and set, for example, the cookies. There are 3
"vertx" entries in the docs, the client, the websocket and some "vertx
json eventbus", so I'm sorry to admit I'm a bit lost.

in essence I need 2 things: organize some sort of a session with a
session state (through cookies or if camel vertx component allows,
differently), and be able to read/print raw bytes to/from the web

client.

On 16.10.2023 09:33, Claus Ibsen wrote:

Hi

platform-http-main is based on vertx-http as HTTP server and this is

NOT

servlet based.
But vertx-http has a similar API where you can get access to headers /
cookies etc.
However we don't store the "raw vertx object" that makes this easy with
Camel.

This needs to be enhanced in camel-platform-http-vertx.


On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko 

wrote:

Hello,

in Camel 2 and Jetty I used to get my hands on HttpServletRequest by

HttpMessage http = exchange.getIn(HttpMessage.class);
HttpServletRequest request = http.getRequest();

, but now I'm migrating to 4.0.1 and platform-http (currently
camel-platform-http-main), and now I'm getting null instead of the
HttpMessage.

Is it related to the note in  the Camel 4 migration guide - " And all
|HttpMessage| has been changed to generic |Message| types"? What is

the

correct method of getting the raw HttpServletRequest and its internals
like headers, sessions and cookies, if there is any? Can't find a
documented way of doing this, for example, by calling
`HttpServletRequest request =

http.getBody(HttpServletRequest.class);`.


Thank you!

-fedd






Re: HttpServletRequest and Platform HTTP

2023-10-16 Thread Fyodor Kravchenko
Thank you, Claus, I'll get familiarized myself with the Vert.X 
internals! In the meantime, there must be some way to "send redirect" 
(respond with the 302 header) by the Camel means, can you please give 
some hint on that?


On 16.10.2023 11:18, Claus Ibsen wrote:

Hi

I created a ticket
https://issues.apache.org/jira/browse/CAMEL-19994

Yeah check vertx-http docs what it offers
https://vertx.io/docs/vertx-web/java/



On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko  wrote:


Hi, thanks, I get that. And without the Vertx object, what would be a
correct way to obtain somewhat like a session attributes? I'm having
trouble to navigate the documentation and find "vertx-http" description,
can't get how to see and set, for example, the cookies. There are 3
"vertx" entries in the docs, the client, the websocket and some "vertx
json eventbus", so I'm sorry to admit I'm a bit lost.

in essence I need 2 things: organize some sort of a session with a
session state (through cookies or if camel vertx component allows,
differently), and be able to read/print raw bytes to/from the web client.

On 16.10.2023 09:33, Claus Ibsen wrote:

Hi

platform-http-main is based on vertx-http as HTTP server and this is NOT
servlet based.
But vertx-http has a similar API where you can get access to headers /
cookies etc.
However we don't store the "raw vertx object" that makes this easy with
Camel.

This needs to be enhanced in camel-platform-http-vertx.


On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko 

wrote:

Hello,

in Camel 2 and Jetty I used to get my hands on HttpServletRequest by

   HttpMessage http = exchange.getIn(HttpMessage.class);
   HttpServletRequest request = http.getRequest();

, but now I'm migrating to 4.0.1 and platform-http (currently
camel-platform-http-main), and now I'm getting null instead of the
HttpMessage.

Is it related to the note in  the Camel 4 migration guide - " And all
|HttpMessage| has been changed to generic |Message| types"? What is the
correct method of getting the raw HttpServletRequest and its internals
like headers, sessions and cookies, if there is any? Can't find a
documented way of doing this, for example, by calling
`HttpServletRequest request = http.getBody(HttpServletRequest.class);`.


Thank you!

-fedd






Re: HttpServletRequest and Platform HTTP

2023-10-16 Thread Fyodor Kravchenko
Hi, thanks, I get that. And without the Vertx object, what would be a 
correct way to obtain somewhat like a session attributes? I'm having 
trouble to navigate the documentation and find "vertx-http" description, 
can't get how to see and set, for example, the cookies. There are 3 
"vertx" entries in the docs, the client, the websocket and some "vertx 
json eventbus", so I'm sorry to admit I'm a bit lost.


in essence I need 2 things: organize some sort of a session with a 
session state (through cookies or if camel vertx component allows, 
differently), and be able to read/print raw bytes to/from the web client.


On 16.10.2023 09:33, Claus Ibsen wrote:

Hi

platform-http-main is based on vertx-http as HTTP server and this is NOT
servlet based.
But vertx-http has a similar API where you can get access to headers /
cookies etc.
However we don't store the "raw vertx object" that makes this easy with
Camel.

This needs to be enhanced in camel-platform-http-vertx.


On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko  wrote:


Hello,

in Camel 2 and Jetty I used to get my hands on HttpServletRequest by

  HttpMessage http = exchange.getIn(HttpMessage.class);
  HttpServletRequest request = http.getRequest();

, but now I'm migrating to 4.0.1 and platform-http (currently
camel-platform-http-main), and now I'm getting null instead of the
HttpMessage.

Is it related to the note in  the Camel 4 migration guide - " And all
|HttpMessage| has been changed to generic |Message| types"? What is the
correct method of getting the raw HttpServletRequest and its internals
like headers, sessions and cookies, if there is any? Can't find a
documented way of doing this, for example, by calling
`HttpServletRequest request = http.getBody(HttpServletRequest.class);`.


Thank you!

-fedd




HttpServletRequest and Platform HTTP

2023-10-15 Thread Fyodor Kravchenko

Hello,

in Camel 2 and Jetty I used to get my hands on HttpServletRequest by

    HttpMessage http = exchange.getIn(HttpMessage.class);
    HttpServletRequest request = http.getRequest();

, but now I'm migrating to 4.0.1 and platform-http (currently 
camel-platform-http-main), and now I'm getting null instead of the 
HttpMessage.


Is it related to the note in  the Camel 4 migration guide - " And all 
|HttpMessage| has been changed to generic |Message| types"? What is the 
correct method of getting the raw HttpServletRequest and its internals 
like headers, sessions and cookies, if there is any? Can't find a 
documented way of doing this, for example, by calling 
`HttpServletRequest request = http.getBody(HttpServletRequest.class);`.



Thank you!

-fedd



Re: Jetty and the Invalid SNI

2023-09-21 Thread Fyodor Kravchenko

Hi, thank you,

seems no-one will be able to test my app without the hassle of creating 
their own keystore, right?


/fedd

On 21.09.2023 17:13, Mattern, Alex wrote:

On converting from Camel 3.x to 4.x:

1. You should get the canonicalHostName

public static String getHostName() {
try {
return 
InetAddress.getLocalHost().getCanonicalHostName();
}
}

2. You should update your keystore to accept the localhost. Change the CN to *..com. 
Change the SAN to www..com. If you have multiple  then you will make 
multiple entries in the keystore.
--
Alex

-Original Message-
From: Fyodor Kravchenko 
Sent: Thursday, September 21, 2023 9:35 AM
To: users@camel.apache.org
Subject: [EXTERNAL SENDER:] Re: Jetty and the Invalid SNI

Hello,

I don't really want to use Jetty, but I'm currently migrating my project that 
uses Jetty from Camel 2 via 3 to 4. I'll be able to use something different 
when it starts working with Jetty so I'm able to fix every other functionality 
before switching to a different web server.
Unfortunately I don't use Spring or Quarkus, but it has to be able to run 
standalone for the time being. I'm looking into Undertow because it offers the 
websockets like Jetty seemed to offer previously, but first I have to make 
Jetty work.


On 21.09.2023 11:32, Claus Ibsen wrote:

Hi

Do you really need to use Jetty? If you use Spring Boot or Quarkus
they come with HTTP server which you can configure for TLS/SSL more
easier than Jetty.

On Mon, Sep 18, 2023 at 12:30 PM Fyodor Kravchenko  wrote:


Hello,

I'm missing how do I set up the new Jetty in Camel 4 to let me access
the localhost via SSL while developing or when needed for other
purposes. I'm getting the "org.eclipse.jetty.http.BadMessageException:
400: Invalid SNI" error.

I'm configuring the SSL as the following:

   JettyHttpComponent jetty = _camel.getComponent(JETTY,
JettyHttpComponent.class);

   // ssl
   File keyStoreFile = new
File(_properties.getProperty("keystoreFile", "sborex.jks"));
   if (keyStoreFile.exists()) {
   String keystorePassword =
_properties.getProperty("keystorePassword", "defaultPassword");
   SSLContextParameters scp = new SSLContextParameters();
   KeyStoreParameters ksp = new KeyStoreParameters();
   try (var stream =
Files.newInputStream(Path.of(keyStoreFile.getPath( {
   KeyStore ks =
KeyStore.getInstance(_properties.getProperty("keystoreType", "jks"));
   ks.load(stream, keystorePassword.toCharArray());
   ksp.setKeyStore(ks);
   }catch(Exception e){
   throw new RuntimeException(e);
   }

   KeyManagersParameters kmp = new KeyManagersParameters();
   kmp.setKeyStore(ksp);
kmp.setKeyPassword(_properties.getProperty("keyPassword"));
   scp.setKeyManagers(kmp);
   SecureRequestCustomizer src = new
SecureRequestCustomizer(false);
   src.setSniRequired(false); // found this in StackOverflow.
Now what?
   jetty.setSslContextParameters(scp);
   }

I've read somewhere that we have to switch off the SNI check for
Jetty through some Secure Request Customizer, but I fail to
understand how do I pass it to the Jetty server; or maybe there is a
more generic API for doing that through the JSSE?
https://urldefense.com/v3/__https://camel.apache.org/manual/camel-con
figuration-utilities.html__;!!KV6Wb-o!8aLqf3hE4j6xQVtSFey5YFtItZV8pSs
8fAZDFZjgMR_60aD7A2h9ftXT4jWpd9OLqb3ksg-nAbTL$


Thanks!



*** IMPORTANT NOTE*
The opinions expressed in this message and/or any attachments are those of the author and not 
necessarily those of Brown Brothers Harriman & Co., its subsidiaries and affiliates 
("BBH"). There is no guarantee that this message is either private or confidential, 
and it may have been altered by unauthorized sources without your or our knowledge. Nothing 
in the message is capable or intended to create any legally binding obligations on either 
party and it is not intended to provide legal advice. BBH accepts no responsibility for loss 
or damage from its use, including damage from virus.
**


Re: Jetty and the Invalid SNI

2023-09-21 Thread Fyodor Kravchenko

Hello,

I don't really want to use Jetty, but I'm currently migrating my project 
that uses Jetty from Camel 2 via 3 to 4. I'll be able to use something 
different when it starts working with Jetty so I'm able to fix every 
other functionality before switching to a different web server. 
Unfortunately I don't use Spring or Quarkus, but it has to be able to 
run standalone for the time being. I'm looking into Undertow because it 
offers the websockets like Jetty seemed to offer previously, but first I 
have to make Jetty work.



On 21.09.2023 11:32, Claus Ibsen wrote:

Hi

Do you really need to use Jetty? If you use Spring Boot or Quarkus they
come with HTTP server which you can configure for TLS/SSL more easier than
Jetty.

On Mon, Sep 18, 2023 at 12:30 PM Fyodor Kravchenko  wrote:


Hello,

I'm missing how do I set up the new Jetty in Camel 4 to let me access
the localhost via SSL while developing or when needed for other
purposes. I'm getting the "org.eclipse.jetty.http.BadMessageException:
400: Invalid SNI" error.

I'm configuring the SSL as the following:

  JettyHttpComponent jetty = _camel.getComponent(JETTY,
JettyHttpComponent.class);

  // ssl
  File keyStoreFile = new
File(_properties.getProperty("keystoreFile", "sborex.jks"));
  if (keyStoreFile.exists()) {
  String keystorePassword =
_properties.getProperty("keystorePassword", "defaultPassword");
  SSLContextParameters scp = new SSLContextParameters();
  KeyStoreParameters ksp = new KeyStoreParameters();
  try (var stream =
Files.newInputStream(Path.of(keyStoreFile.getPath( {
  KeyStore ks =
KeyStore.getInstance(_properties.getProperty("keystoreType", "jks"));
  ks.load(stream, keystorePassword.toCharArray());
  ksp.setKeyStore(ks);
  }catch(Exception e){
  throw new RuntimeException(e);
  }

  KeyManagersParameters kmp = new KeyManagersParameters();
  kmp.setKeyStore(ksp);
kmp.setKeyPassword(_properties.getProperty("keyPassword"));
  scp.setKeyManagers(kmp);
  SecureRequestCustomizer src = new
SecureRequestCustomizer(false);
  src.setSniRequired(false); // found this in StackOverflow.
Now what?
  jetty.setSslContextParameters(scp);
  }

I've read somewhere that we have to switch off the SNI check for Jetty
through some Secure Request Customizer, but I fail to understand how do
I pass it to the Jetty server; or maybe there is a more generic API for
doing that through the JSSE?
https://camel.apache.org/manual/camel-configuration-utilities.html


Thanks!




Jetty and the Invalid SNI

2023-09-18 Thread Fyodor Kravchenko

Hello,

I'm missing how do I set up the new Jetty in Camel 4 to let me access 
the localhost via SSL while developing or when needed for other 
purposes. I'm getting the "org.eclipse.jetty.http.BadMessageException: 
400: Invalid SNI" error.


I'm configuring the SSL as the following:

    JettyHttpComponent jetty = _camel.getComponent(JETTY, 
JettyHttpComponent.class);


    // ssl
    File keyStoreFile = new 
File(_properties.getProperty("keystoreFile", "sborex.jks"));

    if (keyStoreFile.exists()) {
    String keystorePassword = 
_properties.getProperty("keystorePassword", "defaultPassword");

    SSLContextParameters scp = new SSLContextParameters();
    KeyStoreParameters ksp = new KeyStoreParameters();
    try (var stream = 
Files.newInputStream(Path.of(keyStoreFile.getPath( {
    KeyStore ks = 
KeyStore.getInstance(_properties.getProperty("keystoreType", "jks"));

    ks.load(stream, keystorePassword.toCharArray());
    ksp.setKeyStore(ks);
    }catch(Exception e){
    throw new RuntimeException(e);
    }

    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setKeyStore(ksp);
kmp.setKeyPassword(_properties.getProperty("keyPassword"));
    scp.setKeyManagers(kmp);
    SecureRequestCustomizer src = new 
SecureRequestCustomizer(false);
    src.setSniRequired(false); // found this in StackOverflow. 
Now what?

    jetty.setSslContextParameters(scp);
    }

I've read somewhere that we have to switch off the SNI check for Jetty 
through some Secure Request Customizer, but I fail to understand how do 
I pass it to the Jetty server; or maybe there is a more generic API for 
doing that through the JSSE? 
https://camel.apache.org/manual/camel-configuration-utilities.html



Thanks!



Re: Parse xml or yaml snippet into a Processor

2023-09-17 Thread Fyodor Kravchenko

Hello,

Camel internally parses the route files and instantiates route steps as 
Processes. I would like to call this function in my program.


Currently, with xml and Camel 2 I'm doing it with Jaxb, but I would like 
to employ the existing Camel functions that can do it for both xml and 
yaml.


To parse an xml I am wrapping it with some root element and then 
unmarshal it's children with Jaxb.


So we have a String that contains this:


    


The code that creates a Processor from this is this:

    JAXBContext jc = JAXBContext.newInstance(
    "org.apache.camel.model:"
    + "org.apache.camel.model.language:"
    + "org.apache.camel.model.dataformat:"
    + "org.apache.camel.model.rest:"
    + "org.apache.camel.model.transformer:"
    + "org.apache.camel.model.validator:"
    + "org.apache.camel.model.config:"
    + "org.apache.camel.model.loadbalancer:"
    + "org.apache.camel.model.cloud:"
    + "org.apache.camel.model.loadbalancer");
    _unmarshal = jc.createUnmarshaller();

...

    RouteContext rc = new DefaultRouteContext(_context);
    rc.getRoute().setId(.);


    NodeList nl = _convertStringToNodeList(processorsDefinition);
    ArrayList ret = new ArrayList<>();
    for (int i = 0; i < nl.getLength(); i++) {
    if (nl.item(i) instanceof Element) {
    Object def = _unmarshal.unmarshal(nl.item(i));
    if (def instanceof ProcessorDefinition) {
    ProcessorDefinition pd = (ProcessorDefinition) def;
    Processor processor = pd.createProcessor(rc);
    //_context.addService(processor, true);
    ret.add(processor);
    }
    }
    }

    return ret;

.

    private static NodeList _convertStringToNodeList(String xmlStr) { 
// TODO: optimize when all other problems are solved
    String xml = "" + xmlStr 
+ "";
    DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();

    factory.setNamespaceAware(true);
    DocumentBuilder builder;
    try {
    builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(new 
StringReader(xml)));
    return 
doc.getElementsByTagName("root").item(0).getChildNodes();

    } catch (Exception e) {
    throw new RuntimeException(e);
    }
    }


On 17.09.2023 12:36, Claus Ibsen wrote:

Hi

I dont think we understand your question. Can you try to explain this in
more detail?

On Thu, Sep 7, 2023 at 10:31 AM Fyodor Kravchenko  wrote:


Hello,

what is the reliable way in a Java program to create a Processor from a
String containing a definition of a processor that usually are parts of
the route? Camel 4. Like



  ${body[0]}



or


- unmarshal:
  csv:
delimiter: ";"
useMaps: "true"


Thank you!




Re: Parse xml or yaml snippet into a Processor

2023-09-08 Thread Fyodor Kravchenko
Hello, sorry for duplicating this, somehow it didn't make it through the 
first time... the question is below


On 07.09.2023 11:29, Fyodor Kravchenko wrote:

Hello,

what is the reliable way in a Java program to create a Processor from 
a String containing a definition of a processor that usually are parts 
of the route? Camel 4. Like




    ${body[0]}



or


- unmarshal:
    csv:
  delimiter: ";"
  useMaps: "true"


Thank you!



Parse xml or yaml snippet into a Processor

2023-09-07 Thread Fyodor Kravchenko

Hello,

what is the reliable way in a Java program to create a Processor from a 
String containing a definition of a processor that usually are parts of 
the route? Camel 4. Like




    ${body[0]}



or


- unmarshal:
    csv:
  delimiter: ";"
  useMaps: "true"


Thank you!



Re: Load route from a yaml in an embedded Camel

2023-08-19 Thread Fyodor Kravchenko
Thank you, I see the RoutesLoader loads the routes obtained by the 
ResourceLoader#resolveResource method, which can load for example a file.


I need to feed a "dynamically" generated InputStream to the loader. I'm 
guessing I might have to implement my own 
org.​apache.​camel.​spi.Resource to provide the stream/reader, but 
looking at the Resource api I'm failing to understand how do I signal 
the loader that it is a "yaml" character sequence and that the location 
might be fake. Should the getLocation() return something ending in 
".yaml" and how free am I to invent what a getScheme() method returns?


/fedd

On 18.08.2023 14:15, Claus Ibsen wrote:

Hi

Yes you can use RoutesLoader to load routes from whatever resource, and
whatever DSL.

See PluginHelper to get hold of RoutesLoader.


On Fri, Aug 18, 2023 at 9:06 AM Fyodor Kravchenko  wrote:


Hello,

coudn't find it in the docs... what is the official/semi-official API to
load a route definition in a yaml format into the embedded Camel Context?

I tried to use camel-main to load them from files but I wanted to have
more flexibility as camel-main adds a seemingly unneeded extra layer and
to tweak it I anyway had to dive into the source to see how exactly it
loads/reloads the routes stored in the file resources. I see the piece
of code that loads the route in the RouteWatcherReloadStrategy and can
try to hack it out but I'd like to have it more official and also be
sure it survives the upgrade from my current 3.20.4 to, say, Camel 4.
Ideally it should work with a non-file streams as I generate the route
definitions from another snippet. I will provide the id and other
metadata if needed.

Thank you!




Load route from a yaml in an embedded Camel

2023-08-18 Thread Fyodor Kravchenko

Hello,

coudn't find it in the docs... what is the official/semi-official API to 
load a route definition in a yaml format into the embedded Camel Context?


I tried to use camel-main to load them from files but I wanted to have 
more flexibility as camel-main adds a seemingly unneeded extra layer and 
to tweak it I anyway had to dive into the source to see how exactly it 
loads/reloads the routes stored in the file resources. I see the piece 
of code that loads the route in the RouteWatcherReloadStrategy and can 
try to hack it out but I'd like to have it more official and also be 
sure it survives the upgrade from my current 3.20.4 to, say, Camel 4. 
Ideally it should work with a non-file streams as I generate the route 
definitions from another snippet. I will provide the id and other 
metadata if needed.


Thank you!



Jetty HttpServletResponse sendRedirect

2023-06-27 Thread Fyodor Kravchenko

Hello,

one of my producers runs a custom script that is allowed to get access 
to the HttpServletRequest and to invoke sendRedirect method on it. It 
used to work on Camel 2 but with Camel 3.20.4 Jetty tells this:


16:19:38.178 [qtp987805552-43] ERROR 
o.a.camel.component.jetty.CamelContinuationServlet - Error processing 
request

org.eclipse.jetty.io.EofException: Closed
    at 
org.eclipse.jetty.server.HttpOutput.checkWritable(HttpOutput.java:771)

    at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:795)
    at org.apache.camel.util.IOHelper.copy(IOHelper.java:206)
    at org.apache.camel.util.IOHelper.copy(IOHelper.java:161)
    at 
org.apache.camel.http.common.DefaultHttpBinding.copyStream(DefaultHttpBinding.java:500)
    at 
org.apache.camel.http.common.DefaultHttpBinding.doWriteDirectResponse(DefaultHttpBinding.java:566)
    at 
org.apache.camel.http.common.DefaultHttpBinding.doWriteResponse(DefaultHttpBinding.java:439)
    at 
org.apache.camel.http.common.DefaultHttpBinding.writeResponse(DefaultHttpBinding.java:362)


A quick look at the DefaultHttpBinding.writeResponse shows it doesn't 
check for HttpServletRequest.isCommitted(), only for the body to be blanc.


Is there any solution to allow users to send redirects in their scripts 
in the processors? Couldn't find a dedicated Camel HttpMessage method 
for that.


--fedd



Re: HttpMessage.getBody(Map.class) stopped working when migrated from Camel 2 to 3.20.4

2023-06-22 Thread Fyodor Kravchenko

Hi Chirag,

thanks for helping! I'm a bit lost, I think I'll follow your previous 
advice and file a jira. I'm embedding Camel and it has to work as in my 
examples. Thanks again!


-fedd

On 20.06.2023 17:45, Chirag wrote:

moved both under one gist
https://gist.github.com/chiragsanghavi/02a00f49ac7ee9a978344af571746c02

ચિરાગ/चिराग/Chirag
--
Sent from My Gmail Account

On Thu, Jun 15, 2023 at 12:06 AM Chirag  wrote:

@fyodor,


if you are familiar with camel-jbang

Try this:
Here is updated form
https://gist.github.com/chiragsanghavi/02a00f49ac7ee9a978344af571746c02

Yaml DSL:
https://gist.github.com/chiragsanghavi/8a2aee132fc626ed25f97fc0a360ead4

Try form 1 (to see the issue) and try form 2 to see it work as expected.


undertow created body as Map
jetty created body as
org.apache.camel.converter.stream.InputStreamCache resulting into
error.
No serializer found for class org.apache.camel.converter.stream.InputStreamCache


ચિરાગ/चिराग/Chirag
--
Sent from My Gmail Account

On Wed, Jun 14, 2023 at 5:32 PM Chirag  wrote:

Can you try and run it with undertow? I see test similar to your
scenario in undertow.

https://github.com/apache/camel/tree/52443a298935b2842a402cb5fff7e37abb938f8b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow

ચિરાગ/चिराग/Chirag
--
Sent from My Gmail Account

On Wed, Jun 14, 2023 at 4:37 PM Fyodor Kravchenko  wrote:

The old-fashioned standard of the Servlet API required that the request
parameters were available through the request.getParameter* methods,
including the getParameterMap(), be that GET query parameters or the
POST form data load.

Camel collects anything looking like a Map into the Camel
Message headers, mixing the HTTP request parameters, HTTP headers and
something else. It apparently continues to do so, however, somehow
clearing the HttpServletRequest.getParameter* results, but this isn't my
problem. It works the same way in Camel 2 and Camel 3.20.4 which I'm
trying to migrate to, and all inconsistencies are already worked around.

My problem is that the Message.getBody(Map.class) behaviour has changed.
Try change Camel 3 to 2 in the pom.xml of the test project and the same
code will magically work as expected.


On 14.06.2023 19:25, Chirag wrote:

if you introspect variables, the fields are not populated in
HttpServletRequest object. The variables are added to the Camel
Exchange Header. This may be something done within camel-jetty or one
of the underlying libraries.

the field are populated in the message header - but at that point,
they are intermingled with Camel Headers, HTTP Headers

Accept = 
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding = gzip, deflate, br
Accept-Language = en-US,en;q=0.9
Cache-Control = max-age=0
CamelHttpMethod = POST
CamelHttpPath =
CamelHttpQuery = null
CamelHttpServletRequest = Request(POST //localhost:8080/)@37bc1f86
CamelHttpServletResponse = HTTP/1.1 200


CamelHttpUri = /
CamelHttpUrl = http://localhost:8080/
CamelServletContextPath = /
Connection = keep-alive
Content-Length = 20
Content-Type = application/x-www-form-urlencoded
Host = localhost:8080
login = aa
Origin = http://localhost:8080
password = bb
Referer = http://localhost:8080/
sec-ch-ua = "Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114"
sec-ch-ua-mobile = ?0
sec-ch-ua-platform = "Windows"
Sec-Fetch-Dest = document
Sec-Fetch-Mode = navigate
Sec-Fetch-Site = same-origin
Sec-Fetch-User = ?1
Upgrade-Insecure-Requests = 1
User-Agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Edg/114.0.1823.43
 End  of Message Headers



I couldn't see an easy method to convert
username=something=something (that can possibly be a
workaround). I would say go ahead and open a JIRA ; to see if this is
really a bug.
I did see a slightly different behaviour when I added
disableStreamCache=true; but that did not seem to change other parts.
I did try changing it to a multi-part form and then it showed up as
multiple parts attached - but that would mean changing your approach
completely.


ચિરાગ/चिराग/Chirag
------
Sent from My Gmail Account
On Wed, Jun 14, 2023 at 3:14 AM Fyodor Kravchenko  wrote:

Hi Chirag, yeah that exactly is the question - it shouldn't be that way.

If we change Camel version in the pom.xml to Camel 2.24, it'll work as
expected: the POST payload will be parsed into java.util.Map and the
Json will be generated (instead of "null").

So the question is -- how do i fix it for camel 3.20.4?

On 13.06.2023 18:04, Chirag wrote:

Hi Fyodor,
I ran it in IntelliJ thru 3.20.4

after submitting p

Re: HttpMessage.getBody(Map.class) stopped working when migrated from Camel 2 to 3.20.4

2023-06-14 Thread Fyodor Kravchenko
The old-fashioned standard of the Servlet API required that the request 
parameters were available through the request.getParameter* methods, 
including the getParameterMap(), be that GET query parameters or the 
POST form data load.


Camel collects anything looking like a Map into the Camel 
Message headers, mixing the HTTP request parameters, HTTP headers and 
something else. It apparently continues to do so, however, somehow 
clearing the HttpServletRequest.getParameter* results, but this isn't my 
problem. It works the same way in Camel 2 and Camel 3.20.4 which I'm 
trying to migrate to, and all inconsistencies are already worked around.


My problem is that the Message.getBody(Map.class) behaviour has changed. 
Try change Camel 3 to 2 in the pom.xml of the test project and the same 
code will magically work as expected.



On 14.06.2023 19:25, Chirag wrote:

if you introspect variables, the fields are not populated in
HttpServletRequest object. The variables are added to the Camel
Exchange Header. This may be something done within camel-jetty or one
of the underlying libraries.

the field are populated in the message header - but at that point,
they are intermingled with Camel Headers, HTTP Headers

Accept = 
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding = gzip, deflate, br
Accept-Language = en-US,en;q=0.9
Cache-Control = max-age=0
CamelHttpMethod = POST
CamelHttpPath =
CamelHttpQuery = null
CamelHttpServletRequest = Request(POST //localhost:8080/)@37bc1f86
CamelHttpServletResponse = HTTP/1.1 200


CamelHttpUri = /
CamelHttpUrl = http://localhost:8080/
CamelServletContextPath = /
Connection = keep-alive
Content-Length = 20
Content-Type = application/x-www-form-urlencoded
Host = localhost:8080
login = aa
Origin = http://localhost:8080
password = bb
Referer = http://localhost:8080/
sec-ch-ua = "Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114"
sec-ch-ua-mobile = ?0
sec-ch-ua-platform = "Windows"
Sec-Fetch-Dest = document
Sec-Fetch-Mode = navigate
Sec-Fetch-Site = same-origin
Sec-Fetch-User = ?1
Upgrade-Insecure-Requests = 1
User-Agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Edg/114.0.1823.43
 End  of Message Headers



I couldn't see an easy method to convert
username=something=something (that can possibly be a
workaround). I would say go ahead and open a JIRA ; to see if this is
really a bug.
I did see a slightly different behaviour when I added
disableStreamCache=true; but that did not seem to change other parts.
I did try changing it to a multi-part form and then it showed up as
multiple parts attached - but that would mean changing your approach
completely.


ચિરાગ/चिराग/Chirag
------
Sent from My Gmail Account
On Wed, Jun 14, 2023 at 3:14 AM Fyodor Kravchenko  wrote:

Hi Chirag, yeah that exactly is the question - it shouldn't be that way.

If we change Camel version in the pom.xml to Camel 2.24, it'll work as
expected: the POST payload will be parsed into java.util.Map and the
Json will be generated (instead of "null").

So the question is -- how do i fix it for camel 3.20.4?

On 13.06.2023 18:04, Chirag wrote:

Hi Fyodor,
I ran it in IntelliJ thru 3.20.4

after submitting page - i got

json: null, and string:login=usrename=password


ચિરાગ/चिराग/Chirag
----------
Sent from My Gmail Account

On Mon, Jun 12, 2023 at 7:35 AM Fyodor Kravchenko  wrote:

Hello people,

any ideas how to fix the issue below?

-- fedd

On 09.06.2023 18:15, Fyodor Kravchenko wrote:

Hello,

I've used to rely on this function in older Camel, when I was able to
deserialize a regular web form POST stream into a generic
java.util.Map, I mean, this used to parse the form data (not
multipart, just regular) and convert into a Map:

Map map = http.getBody(Map.class);

This is my test code snippet that I compile and run on Java 19 of
GraalVM:

```

  HttpMessage http =
exchange.getIn(HttpMessage.class);
  HttpServletRequest request = http.getRequest();
  String method = request.getMethod();
  if ("POST".equals(method) ||
"PUT".equals(method)) {
  Map map = http.getBody(Map.class);
  String string = http.getBody(String.class);
  http.setHeader(Exchange.CONTENT_TYPE,
"text/plain");
  http.setBody("json: " +
mapper.writeValueAsString(map) + ", and string:" + string);
  } else {
  http.setHeader(Exchange.CONTENT_TYPE,
"text/html");
http.setBody(this.getClass().getResourceAs

Re: HttpMessage.getBody(Map.class) stopped working when migrated from Camel 2 to 3.20.4

2023-06-14 Thread Fyodor Kravchenko

Hi Chirag, yeah that exactly is the question - it shouldn't be that way.

If we change Camel version in the pom.xml to Camel 2.24, it'll work as 
expected: the POST payload will be parsed into java.util.Map and the 
Json will be generated (instead of "null").


So the question is -- how do i fix it for camel 3.20.4?

On 13.06.2023 18:04, Chirag wrote:

Hi Fyodor,
I ran it in IntelliJ thru 3.20.4

after submitting page - i got

json: null, and string:login=usrename=password


ચિરાગ/चिराग/Chirag
--
Sent from My Gmail Account

On Mon, Jun 12, 2023 at 7:35 AM Fyodor Kravchenko  wrote:

Hello people,

any ideas how to fix the issue below?

-- fedd

On 09.06.2023 18:15, Fyodor Kravchenko wrote:

Hello,

I've used to rely on this function in older Camel, when I was able to
deserialize a regular web form POST stream into a generic
java.util.Map, I mean, this used to parse the form data (not
multipart, just regular) and convert into a Map:

Map map = http.getBody(Map.class);

This is my test code snippet that I compile and run on Java 19 of
GraalVM:

```

 HttpMessage http =
exchange.getIn(HttpMessage.class);
 HttpServletRequest request = http.getRequest();
 String method = request.getMethod();
 if ("POST".equals(method) ||
"PUT".equals(method)) {
 Map map = http.getBody(Map.class);
 String string = http.getBody(String.class);
 http.setHeader(Exchange.CONTENT_TYPE,
"text/plain");
 http.setBody("json: " +
mapper.writeValueAsString(map) + ", and string:" + string);
 } else {
 http.setHeader(Exchange.CONTENT_TYPE,
"text/html");
http.setBody(this.getClass().getResourceAsStream("form.html"));
 }
```

I've created a test project to make sure it works on Camel 2.24 and
doesn't in 3.20.4:

https://github.com/fedd/cameljettyformmap/tree/main/cameljettyformmap

I had to add `javax.activation` for the 2.24 version to run, but
unfortunately that didn't fix the 3.20.4 (See the pom.xml in the
github link)

What do I have to do to make it work in 3.20.4?

$ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build
19.0.1+10-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build
19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)



Re: HttpMessage.getBody(Map.class) stopped working when migrated from Camel 2 to 3.20.4

2023-06-12 Thread Fyodor Kravchenko

Hello people,

any ideas how to fix the issue below?

-- fedd

On 09.06.2023 18:15, Fyodor Kravchenko wrote:

Hello,

I've used to rely on this function in older Camel, when I was able to 
deserialize a regular web form POST stream into a generic 
java.util.Map, I mean, this used to parse the form data (not 
multipart, just regular) and convert into a Map:


Map map = http.getBody(Map.class);

This is my test code snippet that I compile and run on Java 19 of 
GraalVM:


```

    HttpMessage http = 
exchange.getIn(HttpMessage.class);

    HttpServletRequest request = http.getRequest();
    String method = request.getMethod();
    if ("POST".equals(method) || 
"PUT".equals(method)) {

    Map map = http.getBody(Map.class);
    String string = http.getBody(String.class);
    http.setHeader(Exchange.CONTENT_TYPE, 
"text/plain");
    http.setBody("json: " + 
mapper.writeValueAsString(map) + ", and string:" + string);

    } else {
    http.setHeader(Exchange.CONTENT_TYPE, 
"text/html");

http.setBody(this.getClass().getResourceAsStream("form.html"));
    }
```

I've created a test project to make sure it works on Camel 2.24 and 
doesn't in 3.20.4:


https://github.com/fedd/cameljettyformmap/tree/main/cameljettyformmap

I had to add `javax.activation` for the 2.24 version to run, but 
unfortunately that didn't fix the 3.20.4 (See the pom.xml in the 
github link)


What do I have to do to make it work in 3.20.4?

$ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)




HttpMessage.getBody(Map.class) stopped working when migrated from Camel 2 to 3.20.4

2023-06-09 Thread Fyodor Kravchenko

Hello,

I've used to rely on this function in older Camel, when I was able to 
deserialize a regular web form POST stream into a generic java.util.Map, 
I mean, this used to parse the form data (not multipart, just regular) 
and convert into a Map:


Map map = http.getBody(Map.class);

This is my test code snippet that I compile and run on Java 19 of GraalVM:

```

    HttpMessage http = 
exchange.getIn(HttpMessage.class);

    HttpServletRequest request = http.getRequest();
    String method = request.getMethod();
    if ("POST".equals(method) || 
"PUT".equals(method)) {

    Map map = http.getBody(Map.class);
    String string = http.getBody(String.class);
    http.setHeader(Exchange.CONTENT_TYPE, 
"text/plain");
    http.setBody("json: " + 
mapper.writeValueAsString(map) + ", and string:" + string);

    } else {
    http.setHeader(Exchange.CONTENT_TYPE, 
"text/html");

http.setBody(this.getClass().getResourceAsStream("form.html"));
    }
```

I've created a test project to make sure it works on Camel 2.24 and 
doesn't in 3.20.4:


https://github.com/fedd/cameljettyformmap/tree/main/cameljettyformmap

I had to add `javax.activation` for the 2.24 version to run, but 
unfortunately that didn't fix the 3.20.4 (See the pom.xml in the github 
link)


What do I have to do to make it work in 3.20.4?

$ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)




Jetty session handler stopped working when migrating from Camel 2 to Camel 3.20.4

2023-06-06 Thread Fyodor Kravchenko
Hello, this used to work previously but not anymore, lease point on what 
I'm missing...


Java 19 from GraalVM.

Below are the code snippets, but the test project in on github, 
https://github.com/fedd/cameljettyssl (it also tests the SSL which also 
seized working. Run and try access http://localhost:8585 for non SSL - 
it doesn't print the strings on session start)


    private static final String JETTY = "jetty";
    private static final String JETTYINSECURE = "jetty-insecure";
    .
    // creating another jetty component for insecure 
access. So there are two jettys, one for http another for https
    // see 
https://stackoverflow.com/questions/67920367/create-http-and-https-endpoint-using-camel-in-the-same-server-with-jetty
    getContext().addComponent(JETTYINSECURE, new 
JettyHttpComponent9());

    .
    // Jetty style session handlers. They can't be reused 
in both components of jetty, so there are two of them

    // this one for the insecure jetty
    final SessionHandler sess = new SessionHandler();
    String sessionHandlerString = "jettySessionHandler";
getContext().getRegistry().bind(sessionHandlerString, sess); // supposed 
to make it available to the "from" uri

    // thsi one for the https jetty
    final SessionHandler sessHttps = new SessionHandler();
    String sessionHandlerHttpsString = 
"jettySessionHandlerHttps";

getContext().getRegistry().bind(sessionHandlerHttpsString, sessHttps);

    // a standard session listener that will be invoked by 
the jetty handlers (see below)

    // TODO: doesn't work
    HttpSessionListener sessionListener = new 
HttpSessionListener() {

    @Override
    public void sessionCreated(HttpSessionEvent se) {
System.out.println("---SESSIONSTARTED---");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
System.out.println("---SESSIONDESTROYED---");
    }
    };
    // this object can be used in both copies of jetty 
component

    sess.addEventListener(sessionListener);
    sessHttps.addEventListener(sessionListener);

    // a simple home grown dispatcher for the catch-all uri 
path

    Processor dispatcher = new Processor() {
    @Override
    public void process(Exchange exchange) throws 
Exception {

    ...
    }
    };

    // initialize two jettys with https and http
    // session handler doesn't get invoked (neither with 
nor without the #hash)
    from(JETTY + 
":https://0.0.0.0:8543?matchOnUriPrefix=true=true=#jettySessionHandlerHttps;)

    .process(dispatcher);

    from(JETTYINSECURE + 
":http://0.0.0.0:8585?matchOnUriPrefix=true=true=#jettySessionHandler;)

    .process(dispatcher);

Thanks!



Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-18 Thread Fyodor Kravchenko

Hi, the API seems to have changed from the 3.20.4 that I'm using.

Can I just replace the File Filter that the default Route Reloader is 
using? I've noticed it uses the Ant Matcher but deliberately ignores the 
whole path:


https://github.com/apache/camel/blob/af9e3b4b9559ef18abf7eaba382a2991998d83da/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java#L128

I would suggest to change this one line so it starts to work a little 
more as expected.


    //path = FileUtil.stripPath(path);
    path = path.substring(base.length()+1); // 
TODO: consider using nio instead of strings


Turned out it wasn't easy to replace the File Filter only, I came up 
with the following workaround. Do you think it's legit and will survive 
a couple of the next Camel upgrades?


    public static void main(String[] args) throws Exception {
    Main main = new Main();

    // could come from the properties file
main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");
    main.configure().withRoutesReloadEnabled(true);
    main.configure().withRoutesReloadDirectory("deploy");
    main.configure().withRoutesReloadDirectoryRecursive(true);
main.configure().withRoutesReloadPattern("**/PRIVATE/EXCHANGE/*.yaml");
    main.configure().withRoutesReloadRemoveAllRoutes(true);

    if (main.configure().isRoutesReloadEnabled()) { // in case 
we're loading from a properties file


    //copied from the DefaultConfigurationConfigurer
    RouteWatcherReloadStrategy reloader = new 
RouteWatcherReloadStrategy(
    main.configure().getRoutesReloadDirectory(), 
main.configure().isRoutesReloadDirectoryRecursive());

reloader.setPattern(main.configure().getRoutesReloadPattern());
reloader.setRemoveAllRoutes(main.configure().isRoutesReloadRemoveAllRoutes());

    // clear so that the DefaultConfigurationConfigurer doesn't 
mess everything up

    main.configure().withRoutesReloadEnabled(false);

    // replace with the better file filter
    //

    // copied and modified from the RouteWatcherReloadStrategy
    final String[] parts = reloader.getPattern().split(",");
    final String base = new 
File(reloader.getFolder()).getAbsolutePath();

    final AntPathMatcher matcher = new AntPathMatcher();

    reloader.setFileFilter(new FileFilter() {
    @Override
    public boolean accept(File f) {
    for (String part : parts) {
    // strip starting directory, so we have a 
relative name to the starting folder

    String path = f.getAbsolutePath();
    if (path.startsWith(base)) {
    //path = FileUtil.stripPath(path); - why 
the whole path? lets strip the base only
    path = path.substring(base.length() + 1); 
// TODO: consider using nio instead of strings

    }

    String name = FileUtil.compactPath(f.getPath());
    boolean exact = name.equals(part);
    boolean result = exact || matcher.match(part, 
path, false);
    //LOG.trace("Accepting file pattern:{} path:{} 
-> {}", part, path, result);


    if (result) {
    return true;
    }
    }
    return false;
    }
    });

    // add the reloader with the better file filter
    main.configure().addConfiguration(new CamelConfiguration() {
    @Override
    public void configure(CamelContext camelContext) throws 
Exception {

    camelContext.addService(reloader);
    }

    });
    }

    main.run();

    }

On 18.05.2023 11:03, Claus Ibsen wrote:

Hi

You can implement a custom org.apache.camel.spi.ResourceReload where you in
the onReload can program what to do.
The current defauly just do

 if (name.endsWith(".properties")) {
 onPropertiesReload(resource, true);
 } else {
 onRouteReload(List.of(resource), false);
 }

And then create an instance of FileWatcherResourceReloadStrategy which you
can configure with folder / pattern etc, and then add this as a bean to
camel context.



On Thu, May 18, 2023 at 9:39 AM Fyodor Kravchenko
wrote:


Hi,

Thank you! I'm new to the Camel 3 API, can you please point me how can I
load a route programmatically if I have a yaml or xml String (or
Stream/Reader)?

Regarding the ticket, loading the new files after the startup, renaming
the route files and deleting them would also be a useful develop

Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-18 Thread Fyodor Kravchenko

Hi,

Thank you! I'm new to the Camel 3 API, can you please point me how can I 
load a route programmatically if I have a yaml or xml String (or 
Stream/Reader)?


Regarding the ticket, loading the new files after the startup, renaming 
the route files and deleting them would also be a useful development 
feature. Currently it works independently from the initial load, so it 
does re-load all of the routes it encounters under the base directory, 
but the pattern it uses to choose which files to (re/un)load follows the 
different syntax and even the directory base is different.


A jira ticket that I would file would require a developer-friendly 
"fileReload"-true-false configuration parameter, that would try to use 
the same pattern that the "include" configuration uses, if it is a 
"file" one. I can imagine it is not a trivial development for a rarely 
used development feature and is likely to be  marked as "will not 
implement" so let's leave it as it is.


On 18.05.2023 09:06, Claus Ibsen wrote:

On Wed, May 17, 2023 at 10:59 PM Fyodor Kravchenko 
wrote:


Hi,

I'm integrating Camel into my application, or better say, application
platform, that may run different arbitrary Camel routes for integration,
and I'd like to provide an ability for a developer who makes
applications for this platform to edit the routes during the
development. I'm already monitoring the filesystem for other artifact
edits, so If there is an API to reload an individual route taken from a
file I might use that.

I've considered to use a separate Camel standalone or as a containerized
service that I've noticed the project is encouraging now, but this would
require me to develop some protocol to interact with my platform during
its lifecycle. For Camel 2 I managed to instantiate xml snippets to
custom Processors but the API has changed and this Main load-reload
function seemed to do what I want for Camel 3.



Okay so for making the reload respect only already loaded files, then we
can match the "changed file event" form the JDK
and match if it was previously loaded or not. And then skip it if not.

Then users can turn this on via some new option (maybe name it only
existing files, or some better name? ).
withRoutesReloadOnlyExistingFiles(true)


You are welcome to create a JIRA ticket for that.




On 17.05.2023 22:58, Claus Ibsen wrote:

Hi

What is your goal with this?

The reload stuff is for development and not a production app server to
"redeploy apps" or any sort of that.
The intention is that you work on a single application.

The reload is using Java APIs for "change file events" and this does not
support an ANT style way and whatnot.


On Wed, May 17, 2023 at 8:45 PM Fyodor Kravchenko 
I'm sorry please disregard my previous ramblings, moving the "deploy"
directory to the working directory of the java app did the "include"
trick. It worked without the "file:" prefix because it was looking into
the "target" directry which was the classpath.. My fault.

However, the additional question remains: how do I make it _reload_ what
it loaded previosly, without catching the extra *.yaml files that may be
located in the wrong directories?

I'm trying this,

   Main main = new Main();



main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");

   main.configure().withRoutesReloadEnabled(true);
   main.configure().withRoutesReloadDirectory("deploy");
   main.configure().withRoutesReloadDirectoryRecursive(true);
//

main.configure().withRoutesReloadPattern("**/PRIVATE/EXCHANGE/*.yaml");

// main.configure().withRoutesReloadPattern("PRIVATE/EXCHANGE/*.yaml");
   main.configure().withRoutesReloadPattern("*.yaml");
   main.configure().withRoutesReloadRemoveAllRoutes(true);
   main.run();

but this will catch and load any .yaml file under the "deploy"
directory, event those that wasn't loaded at startup, when I touch any
of the yamls.

Any tips on reloading patterns?

Thank you!

On 17.05.2023 21:06, Fyodor Kravchenko wrote:

Hi, thanks but this

.
Netbeans uses the following command to run the program:

cd /home/fedd/NetBeansProjects/camelmaintry;
JAVA_HOME=/home/fedd/Programs/graalvm-ce-java19-22.3.0
/snap/netbeans/76/netbeans/java/maven/bin/mvn -Dexec.vmArgs=
"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass}
${exec.appArgs}" -Dexec.appArgs=
-Dexec.mainClass=camelmaintry.CamelMainTry
-Dexec.executable=/home/fedd/Programs/graalvm-ce-java19-22.3.0/bin/java
org.codehaus.mojo:exec-maven-plugin:3.1.0:exec

(nothing special in the "exec.mainClass" and other placeholders there)

I can't grasp how to make it look into this pattern:

deploy/**/PRIVATE/EXCHANGE/*.yaml

Thanks!
--fedd

On 17.05.2023 20:15, Claus Ibsen wrote:

Hi

Okay 

Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-17 Thread Fyodor Kravchenko

Hi,

I'm integrating Camel into my application, or better say, application 
platform, that may run different arbitrary Camel routes for integration, 
and I'd like to provide an ability for a developer who makes 
applications for this platform to edit the routes during the 
development. I'm already monitoring the filesystem for other artifact 
edits, so If there is an API to reload an individual route taken from a 
file I might use that.


I've considered to use a separate Camel standalone or as a containerized 
service that I've noticed the project is encouraging now, but this would 
require me to develop some protocol to interact with my platform during 
its lifecycle. For Camel 2 I managed to instantiate xml snippets to 
custom Processors but the API has changed and this Main load-reload 
function seemed to do what I want for Camel 3.


On 17.05.2023 22:58, Claus Ibsen wrote:

Hi

What is your goal with this?

The reload stuff is for development and not a production app server to
"redeploy apps" or any sort of that.
The intention is that you work on a single application.

The reload is using Java APIs for "change file events" and this does not
support an ANT style way and whatnot.


On Wed, May 17, 2023 at 8:45 PM Fyodor Kravchenko 
wrote:


I'm sorry please disregard my previous ramblings, moving the "deploy"
directory to the working directory of the java app did the "include"
trick. It worked without the "file:" prefix because it was looking into
the "target" directry which was the classpath.. My fault.

However, the additional question remains: how do I make it _reload_ what
it loaded previosly, without catching the extra *.yaml files that may be
located in the wrong directories?

I'm trying this,

  Main main = new Main();

main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");
  main.configure().withRoutesReloadEnabled(true);
  main.configure().withRoutesReloadDirectory("deploy");
  main.configure().withRoutesReloadDirectoryRecursive(true);
// main.configure().withRoutesReloadPattern("**/PRIVATE/EXCHANGE/*.yaml");
// main.configure().withRoutesReloadPattern("PRIVATE/EXCHANGE/*.yaml");
  main.configure().withRoutesReloadPattern("*.yaml");
  main.configure().withRoutesReloadRemoveAllRoutes(true);
  main.run();

but this will catch and load any .yaml file under the "deploy"
directory, event those that wasn't loaded at startup, when I touch any
of the yamls.

Any tips on reloading patterns?

Thank you!

On 17.05.2023 21:06, Fyodor Kravchenko wrote:

Hi, thanks but this

.
Netbeans uses the following command to run the program:

cd /home/fedd/NetBeansProjects/camelmaintry;
JAVA_HOME=/home/fedd/Programs/graalvm-ce-java19-22.3.0
/snap/netbeans/76/netbeans/java/maven/bin/mvn -Dexec.vmArgs=
"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass}
${exec.appArgs}" -Dexec.appArgs=
-Dexec.mainClass=camelmaintry.CamelMainTry
-Dexec.executable=/home/fedd/Programs/graalvm-ce-java19-22.3.0/bin/java
org.codehaus.mojo:exec-maven-plugin:3.1.0:exec

(nothing special in the "exec.mainClass" and other placeholders there)

I can't grasp how to make it look into this pattern:

deploy/**/PRIVATE/EXCHANGE/*.yaml

Thanks!
--fedd

On 17.05.2023 20:15, Claus Ibsen wrote:

Hi

Okay for file system, you should favour prefixing with file:



main.configure().withRoutesIncludePattern("file:deploy/customer/PRIVATE/EXCHANGE/*.yaml");




On Wed, May 17, 2023 at 3:53 PM Fyodor Kravchenko

wrote:


Hi,

I'm trying to load the routes from the file system directly, it's Camel
3.20.4, and it's java 19 from the GraalVM distribution running on
Ubuntu
22.04. The fact it sees the file when no wildcard is present tells me
that I'm missing something in the wildcards and the docs.

Thank you!

--fedd

(sorry for the late response, only now I've got the rejection
notification for the html-formatted email)

On 15.05.2023 11:01, Claus Ibsen wrote:

Hi

Are you loading these files from classpath or file system directly.
And what Camel version do you use



On Sun, May 14, 2023 at 5:39 PM Fyodor Kravchenko

Hello,

in my little test I'm trying the following,


public class CamelMainTry {
public static void main(String[] args) throws Exception {
Main main = new Main();
//this works but I need to catch more
//



main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");


//these don't work:'
//



main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml");

main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml");


main.run();
}
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIV

Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-17 Thread Fyodor Kravchenko
I'm sorry please disregard my previous ramblings, moving the "deploy" 
directory to the working directory of the java app did the "include" 
trick. It worked without the "file:" prefix because it was looking into 
the "target" directry which was the classpath.. My fault.


However, the additional question remains: how do I make it _reload_ what 
it loaded previosly, without catching the extra *.yaml files that may be 
located in the wrong directories?


I'm trying this,

    Main main = new Main();
main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");
    main.configure().withRoutesReloadEnabled(true);
    main.configure().withRoutesReloadDirectory("deploy");
    main.configure().withRoutesReloadDirectoryRecursive(true);
// main.configure().withRoutesReloadPattern("**/PRIVATE/EXCHANGE/*.yaml");
// main.configure().withRoutesReloadPattern("PRIVATE/EXCHANGE/*.yaml");
    main.configure().withRoutesReloadPattern("*.yaml");
    main.configure().withRoutesReloadRemoveAllRoutes(true);
    main.run();

but this will catch and load any .yaml file under the "deploy" 
directory, event those that wasn't loaded at startup, when I touch any 
of the yamls.


Any tips on reloading patterns?

Thank you!

On 17.05.2023 21:06, Fyodor Kravchenko wrote:

Hi, thanks but this

.



Netbeans uses the following command to run the program:

cd /home/fedd/NetBeansProjects/camelmaintry; 
JAVA_HOME=/home/fedd/Programs/graalvm-ce-java19-22.3.0 
/snap/netbeans/76/netbeans/java/maven/bin/mvn -Dexec.vmArgs= 
"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} 
${exec.appArgs}" -Dexec.appArgs= 
-Dexec.mainClass=camelmaintry.CamelMainTry 
-Dexec.executable=/home/fedd/Programs/graalvm-ce-java19-22.3.0/bin/java 
org.codehaus.mojo:exec-maven-plugin:3.1.0:exec


(nothing special in the "exec.mainClass" and other placeholders there)

I can't grasp how to make it look into this pattern:

deploy/**/PRIVATE/EXCHANGE/*.yaml

Thanks!
--fedd

On 17.05.2023 20:15, Claus Ibsen wrote:

Hi

Okay for file system, you should favour prefixing with file:

main.configure().withRoutesIncludePattern("file:deploy/customer/PRIVATE/EXCHANGE/*.yaml"); 




On Wed, May 17, 2023 at 3:53 PM Fyodor Kravchenko 


wrote:


Hi,

I'm trying to load the routes from the file system directly, it's Camel
3.20.4, and it's java 19 from the GraalVM distribution running on 
Ubuntu

22.04. The fact it sees the file when no wildcard is present tells me
that I'm missing something in the wildcards and the docs.

Thank you!

--fedd

(sorry for the late response, only now I've got the rejection
notification for the html-formatted email)

On 15.05.2023 11:01, Claus Ibsen wrote:

Hi

Are you loading these files from classpath or file system directly.
And what Camel version do you use



On Sun, May 14, 2023 at 5:39 PM Fyodor Kravchenko 


wrote:


Hello,

in my little test I'm trying the following,


public class CamelMainTry {
   public static void main(String[] args) throws Exception {
   Main main = new Main();
//    this works but I need to catch more
//


main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml"); 


//    these don't work:'
//


main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml"); 



main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml"); 


   main.run();
   }
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

So there could be more directories in the middle; however it doesn't
substitute even one.

The Ant-style (or what I'm thinking the Ant style) pattern doesn't 
seem
to catch multiple directories. If I specify the directory 
explicitly it

works, but I need it to locate the routes in dozens of directories.

How do I fix it?

(While we're at it I would also like to make it reload on the fly for
the testing purposes, not all of the .yaml files but restricting 
it to

my directory structure)

Thanks!

--fedd







Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-17 Thread Fyodor Kravchenko

Hi, thanks but this

main.configure().withRoutesIncludePattern("file:deploy/customer/PRIVATE/EXCHANGE/*.yaml");

doesn't work saying "java.nio.file.NoSuchFileException: 
deploy/customer/PRIVATE/EXCHANGE"


Like I've said previously, without the double asterisks, it does work 
_without_ the "file:" prefix:


main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");

The above works but catches only one route.

However, I actually need to catch this pattern, with double asterisks:

main.configure().withRoutesIncludePattern("file:deploy/**/PRIVATE/EXCHANGE/*.yaml");

This fails with "java.nio.file.NoSuchFileException: deploy"

My routes are located at

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

and there be more routes in such a folder structure with the variable 
middle part. Actual file locations are:


/home/fedd/NetBeansProjects/camelmaintry/src/main/resources/deploy/customer/PRIVATE/EXCHANGE/cust.yaml

/home/fedd/NetBeansProjects/camelmaintry/src/main/resources/deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

and in the generated target:

/home/fedd/NetBeansProjects/camelmaintry/target/classes/deploy/customer/PRIVATE/EXCHANGE/cust.yaml

/home/fedd/NetBeansProjects/camelmaintry/target/classes/deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml


Netbeans uses the following command to run the program:

cd /home/fedd/NetBeansProjects/camelmaintry; 
JAVA_HOME=/home/fedd/Programs/graalvm-ce-java19-22.3.0 
/snap/netbeans/76/netbeans/java/maven/bin/mvn -Dexec.vmArgs= 
"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} 
${exec.appArgs}" -Dexec.appArgs= 
-Dexec.mainClass=camelmaintry.CamelMainTry 
-Dexec.executable=/home/fedd/Programs/graalvm-ce-java19-22.3.0/bin/java 
org.codehaus.mojo:exec-maven-plugin:3.1.0:exec


(nothing special in the "exec.mainClass" and other placeholders there)

I can't grasp how to make it look into this pattern:

deploy/**/PRIVATE/EXCHANGE/*.yaml

Thanks!
--fedd

On 17.05.2023 20:15, Claus Ibsen wrote:

Hi

Okay for file system, you should favour prefixing with file:

main.configure().withRoutesIncludePattern("file:deploy/customer/PRIVATE/EXCHANGE/*.yaml");


On Wed, May 17, 2023 at 3:53 PM Fyodor Kravchenko 
wrote:


Hi,

I'm trying to load the routes from the file system directly, it's Camel
3.20.4, and it's java 19 from the GraalVM distribution running on Ubuntu
22.04. The fact it sees the file when no wildcard is present tells me
that I'm missing something in the wildcards and the docs.

Thank you!

--fedd

(sorry for the late response, only now I've got the rejection
notification for the html-formatted email)

On 15.05.2023 11:01, Claus Ibsen wrote:

Hi

Are you loading these files from classpath or file system directly.
And what Camel version do you use



On Sun, May 14, 2023 at 5:39 PM Fyodor Kravchenko 
Hello,

in my little test I'm trying the following,


public class CamelMainTry {
   public static void main(String[] args) throws Exception {
   Main main = new Main();
//this works but I need to catch more
//



main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");

//these don't work:'
//



main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml");



main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml");

   main.run();
   }
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

So there could be more directories in the middle; however it doesn't
substitute even one.

The Ant-style (or what I'm thinking the Ant style) pattern doesn't seem
to catch multiple directories. If I specify the directory explicitly it
works, but I need it to locate the routes in dozens of directories.

How do I fix it?

(While we're at it I would also like to make it reload on the fly for
the testing purposes, not all of the .yaml files but restricting it to
my directory structure)

Thanks!

--fedd







Re: Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-17 Thread Fyodor Kravchenko

Hi,

I'm trying to load the routes from the file system directly, it's Camel 
3.20.4, and it's java 19 from the GraalVM distribution running on Ubuntu 
22.04. The fact it sees the file when no wildcard is present tells me 
that I'm missing something in the wildcards and the docs.


Thank you!

--fedd

(sorry for the late response, only now I've got the rejection 
notification for the html-formatted email)


On 15.05.2023 11:01, Claus Ibsen wrote:

Hi

Are you loading these files from classpath or file system directly.
And what Camel version do you use



On Sun, May 14, 2023 at 5:39 PM Fyodor Kravchenko 
wrote:


Hello,

in my little test I'm trying the following,


public class CamelMainTry {
  public static void main(String[] args) throws Exception {
  Main main = new Main();
//this works but I need to catch more
//

main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");
//these don't work:'
//

main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml");

main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml");
  main.run();
  }
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

So there could be more directories in the middle; however it doesn't
substitute even one.

The Ant-style (or what I'm thinking the Ant style) pattern doesn't seem
to catch multiple directories. If I specify the directory explicitly it
works, but I need it to locate the routes in dozens of directories.

How do I fix it?

(While we're at it I would also like to make it reload on the fly for
the testing purposes, not all of the .yaml files but restricting it to
my directory structure)

Thanks!

--fedd





Camel Main: RoutesIncludePattern doesn't seem to respect asterisks as a directory placeholder

2023-05-14 Thread Fyodor Kravchenko

Hello,

in my little test I'm trying the following,


public class CamelMainTry {
    public static void main(String[] args) throws Exception {
    Main main = new Main();
//    this works but I need to catch more
// 
main.configure().withRoutesIncludePattern("deploy/customer/PRIVATE/EXCHANGE/*.yaml");

//    these don't work:'
// 
main.configure().withRoutesIncludePattern("deploy/**/PRIVATE/EXCHANGE/*.yaml");

main.configure().withRoutesIncludePattern("deploy/*/PRIVATE/EXCHANGE/*.yaml");
    main.run();
    }
}

my files are located:

deploy/customer/PRIVATE/EXCHANGE/cust.yaml

deploy/register/bank/PRIVATE/EXCHANGE/reg.yaml

So there could be more directories in the middle; however it doesn't 
substitute even one.


The Ant-style (or what I'm thinking the Ant style) pattern doesn't seem 
to catch multiple directories. If I specify the directory explicitly it 
works, but I need it to locate the routes in dozens of directories.


How do I fix it?

(While we're at it I would also like to make it reload on the fly for 
the testing purposes, not all of the .yaml files but restricting it to 
my directory structure)


Thanks!

--fedd




camel examples main yaml doesn't work for me

2023-05-11 Thread Fyodor Kravchenko
I have cloned the repository and tried to run the 
camel-examples/examples/main-yaml executable as stated in the readme 
(mvn compile, mvn capel:run), but it didn't seem to work. I just didn't 
print anything. I've also tried to downgrade Camel in the project to the 
latest Camel 3 which compiled but still didn't work.


All it prints is

mvn camel:run
[INFO] Scanning for projects...
[INFO]
[INFO] --< org.apache.camel.example:camel-example-main-yaml 
>--

[INFO] Building Camel :: Example :: Main :: YAML 4.0.0-SNAPSHOT
[INFO] [ jar 
]-

[INFO]
[INFO] --- camel-maven-plugin:3.20.4:run (default-cli) @ 
camel-example-main-yaml ---
[INFO] You can skip tests from the command line using: mvn camel:run 
-Dmaven.test.skip=true
[INFO] Using custom org.apache.camel.example.MyApplication to initiate a 
CamelContext

[INFO] Starting Camel ...

and that's it. I tried to modify the my-route.yaml for it to detect the 
new route but to no avail.


(I am trying this because I'm failing to make my own little test 
project, but actually the official example works worse than my own 
attempt. It doesn't load the route at statrup but works okay when I 
modify the yaml. To reiterate, the example does neither of this: neither 
it loads the route at startup nor at the yaml modification)


I may have java problems. In the environment I try the example:

java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 
19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)


JAVA_HOME=/xxx/graalvm-ce-java19-22.3.0

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/xxx/graalvm-ce-java19-22.3.0/bin

I have also Java 8 installed somewhere but I tried to make sure the 
modern java is used.


What am I doing wrong?

--fedd