[jira] [Commented] (CAMEL-19346) Builder.simple expression is not thread safe

2023-09-01 Thread Max (Jira)


[ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17761318#comment-17761318
 ] 

Max commented on CAMEL-19346:
-

yes, looks like it solved the issue.

my concurrency test which was failing with 3.20.5 passes with 3.21.0

> Builder.simple expression is not thread safe
> 
>
> Key: CAMEL-19346
> URL: https://issues.apache.org/jira/browse/CAMEL-19346
> Project: Camel
>  Issue Type: Bug
>  Components: came-core
>Affects Versions: 3.20.2, 3.20.3, 3.20.4
>Reporter: Max
>Priority: Major
>
> First of all I have to apologize, cannot provide demo project to reproduce 
> the error. So, this is the issue:
> using route something like this:
> {code:java}
> from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
> {code}
> {code:java|title=application.yaml}
> foo.base.url: http://foo.bar/foo
> {code}
> {code:java}
> import org.apache.camel.builder.SimpleBuilder;
> import static org.apache.camel.builder.Builder.simple;
> public class MyBean { 
> public static final String PART1 = "{{foo.base.url}}";
> public static final String PART2 = "$simple{header.fooId}"
> public static final String FULL_URL = PART1 + "/" + PART2;
> @Handler
> public void process(Exchange exchange) {
> var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
> var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
> String.class);
> var part1 = simple(PART1).evaluate(exchange, String.class);
> var part2 = simple(PART2).evaluate(exchange, String.class);
> var builtFromParts1 = part1 + "/" + message.getHeader("myId");
> var builtFromParts2 = part1 + "/" + part2;
> message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
> }{code}
> The issue:
> When {{MyBean}} is used in a single thread (1 queue consumer) everything 
> works fine. 
> When {{MyBean}} is used with multiple queue consumers after some time (about 
> 50 messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 
> So instead of always having url like 
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/2
> ...
> http://foo.bar/foo/1024
> {code}
> we start getting weird results such as
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/http://foo.bar/foo/1
> http://foo.bar/foo/11
> {code}
> After experimenting I suspect that the {{Builder.simple}} expression is not 
> thread safe  or has some internal caching which causes the 
> {}expression{} to collide with $simple\{header.foo} when used 
> together in the same string.
> So it takes the result of {}expression{} sets to some internal cache 
> then takes that value and adds the same value + result of 
> ${simple\{header.foo}
> When the expressions are evaluated separately Builder.simple() produces 
> correct result.
> Tried to use deprecated SimpleBuilder.simple() expression and hit the same 
> issue.
> So even though {{allInOne}} and {{allInOneWithSB were}} broken, other values 
> such as {{{}builtFromParts1{}}}, {{builtFromParts2}} at the same time were 
> allways correct no matter how often and how many concurrent consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (CAMEL-19346) Builder.simple expression is not thread safe

2023-09-01 Thread Max (Jira)


[ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17761007#comment-17761007
 ] 

Max edited comment on CAMEL-19346 at 9/1/23 1:53 PM:
-

may be 
[CAMEL-19014|https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-19014] 
solves the issue 


was (Author: mustermann):
may 
[CAMEL-19014|https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-19014] 
solves the issue 

> Builder.simple expression is not thread safe
> 
>
> Key: CAMEL-19346
> URL: https://issues.apache.org/jira/browse/CAMEL-19346
> Project: Camel
>  Issue Type: Bug
>  Components: came-core
>Affects Versions: 3.20.2, 3.20.3, 3.20.4
>Reporter: Max
>Priority: Major
>
> First of all I have to apologize, cannot provide demo project to reproduce 
> the error. So, this is the issue:
> using route something like this:
> {code:java}
> from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
> {code}
> {code:java|title=application.yaml}
> foo.base.url: http://foo.bar/foo
> {code}
> {code:java}
> import org.apache.camel.builder.SimpleBuilder;
> import static org.apache.camel.builder.Builder.simple;
> public class MyBean { 
> public static final String PART1 = "{{foo.base.url}}";
> public static final String PART2 = "$simple{header.fooId}"
> public static final String FULL_URL = PART1 + "/" + PART2;
> @Handler
> public void process(Exchange exchange) {
> var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
> var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
> String.class);
> var part1 = simple(PART1).evaluate(exchange, String.class);
> var part2 = simple(PART2).evaluate(exchange, String.class);
> var builtFromParts1 = part1 + "/" + message.getHeader("myId");
> var builtFromParts2 = part1 + "/" + part2;
> message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
> }{code}
> The issue:
> When {{MyBean}} is used in a single thread (1 queue consumer) everything 
> works fine. 
> When {{MyBean}} is used with multiple queue consumers after some time (about 
> 50 messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 
> So instead of always having url like 
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/2
> ...
> http://foo.bar/foo/1024
> {code}
> we start getting weird results such as
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/http://foo.bar/foo/1
> http://foo.bar/foo/11
> {code}
> After experimenting I suspect that the {{Builder.simple}} expression is not 
> thread safe  or has some internal caching which causes the 
> {}expression{} to collide with $simple\{header.foo} when used 
> together in the same string.
> So it takes the result of {}expression{} sets to some internal cache 
> then takes that value and adds the same value + result of 
> ${simple\{header.foo}
> When the expressions are evaluated separately Builder.simple() produces 
> correct result.
> Tried to use deprecated SimpleBuilder.simple() expression and hit the same 
> issue.
> So even though {{allInOne}} and {{allInOneWithSB were}} broken, other values 
> such as {{{}builtFromParts1{}}}, {{builtFromParts2}} at the same time were 
> allways correct no matter how often and how many concurrent consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CAMEL-19346) Builder.simple expression is not thread safe

2023-08-31 Thread Max (Jira)


[ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17761007#comment-17761007
 ] 

Max commented on CAMEL-19346:
-

may 
[CAMEL-19014|https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-19014] 
solves the issue 

> Builder.simple expression is not thread safe
> 
>
> Key: CAMEL-19346
> URL: https://issues.apache.org/jira/browse/CAMEL-19346
> Project: Camel
>  Issue Type: Bug
>  Components: came-core
>Affects Versions: 3.20.2, 3.20.3, 3.20.4
>Reporter: Max
>Priority: Major
>
> First of all I have to apologize, cannot provide demo project to reproduce 
> the error. So, this is the issue:
> using route something like this:
> {code:java}
> from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
> {code}
> {code:java|title=application.yaml}
> foo.base.url: http://foo.bar/foo
> {code}
> {code:java}
> import org.apache.camel.builder.SimpleBuilder;
> import static org.apache.camel.builder.Builder.simple;
> public class MyBean { 
> public static final String PART1 = "{{foo.base.url}}";
> public static final String PART2 = "$simple{header.fooId}"
> public static final String FULL_URL = PART1 + "/" + PART2;
> @Handler
> public void process(Exchange exchange) {
> var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
> var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
> String.class);
> var part1 = simple(PART1).evaluate(exchange, String.class);
> var part2 = simple(PART2).evaluate(exchange, String.class);
> var builtFromParts1 = part1 + "/" + message.getHeader("myId");
> var builtFromParts2 = part1 + "/" + part2;
> message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
> }{code}
> The issue:
> When {{MyBean}} is used in a single thread (1 queue consumer) everything 
> works fine. 
> When {{MyBean}} is used with multiple queue consumers after some time (about 
> 50 messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 
> So instead of always having url like 
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/2
> ...
> http://foo.bar/foo/1024
> {code}
> we start getting weird results such as
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/http://foo.bar/foo/1
> http://foo.bar/foo/11
> {code}
> After experimenting I suspect that the {{Builder.simple}} expression is not 
> thread safe  or has some internal caching which causes the 
> {}expression{} to collide with $simple\{header.foo} when used 
> together in the same string.
> So it takes the result of {}expression{} sets to some internal cache 
> then takes that value and adds the same value + result of 
> ${simple\{header.foo}
> When the expressions are evaluated separately Builder.simple() produces 
> correct result.
> Tried to use deprecated SimpleBuilder.simple() expression and hit the same 
> issue.
> So even though {{allInOne}} and {{allInOneWithSB were}} broken, other values 
> such as {{{}builtFromParts1{}}}, {{builtFromParts2}} at the same time were 
> allways correct no matter how often and how many concurrent consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (CAMEL-19346) Builder.simple expression is not thread safe

2023-05-12 Thread Max (Jira)


 [ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Max updated CAMEL-19346:

Description: 
First of all I have to apologize, cannot provide demo project to reproduce the 
error. So, this is the issue:

using route something like this:
{code:java}
from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
{code}
{code:java|title=application.yaml}
foo.base.url: http://foo.bar/foo
{code}
{code:java}
import org.apache.camel.builder.SimpleBuilder;
import static org.apache.camel.builder.Builder.simple;

public class MyBean { 

public static final String PART1 = "{{foo.base.url}}";
public static final String PART2 = "$simple{header.fooId}"
public static final String FULL_URL = PART1 + "/" + PART2;

@Handler
public void process(Exchange exchange) {
var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
String.class);

var part1 = simple(PART1).evaluate(exchange, String.class);
var part2 = simple(PART2).evaluate(exchange, String.class);
var builtFromParts1 = part1 + "/" + message.getHeader("myId");
var builtFromParts2 = part1 + "/" + part2;

message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // sometimes broken
message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
}{code}
The issue:

When {{MyBean}} is used in a single thread (1 queue consumer) everything works 
fine. 

When {{MyBean}} is used with multiple queue consumers after some time (about 50 
messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 

So instead of always having url like 
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/2
...
http://foo.bar/foo/1024
{code}
we start getting weird results such as
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/http://foo.bar/foo/1
http://foo.bar/foo/11
{code}
After experimenting I suspect that the {{Builder.simple}} expression is not 
thread safe  or has some internal caching which causes the 
{}expression{} to collide with $simple\{header.foo} when used together 
in the same string.

So it takes the result of {}expression{} sets to some internal cache 
then takes that value and adds the same value + result of ${simple\{header.foo}

When the expressions are evaluated separately Builder.simple() produces correct 
result.

Tried to use deprecated SimpleBuilder.simple() expression and hit the same 
issue.

So even though {{allInOne}} and {{allInOneWithSB were}} broken, other values 
such as {{{}builtFromParts1{}}}, {{builtFromParts2}} at the same time were 
allways correct no matter how often and how many concurrent consumers I used.

  was:
First of all I have to apologize, cannot provide demo project to reproduce the 
error. So, this is the issue:

using route something like this:
{code:java}
from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
{code}
{code:java|title=application.yaml}
foo.base.url: http://foo.bar/foo
{code}
{code:java}
import org.apache.camel.builder.SimpleBuilder;
import static org.apache.camel.builder.Builder.simple;

public class MyBean { 

public static final String PART1 = "{{foo.base.url}}";
public static final String PART2 = "$simple{header.fooId}"
public static final String FULL_URL = PART1 + "/" + PART2;

@Handler
public void process(Exchange exchange) {
var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
String.class);
var part1 = simple(PART1).evaluate(exchange, String.class);
var part2 = simple(PART2).evaluate(exchange, String.class);
var builtFromParts1 = part1 + "/" + message.getHeader("myId");
var builtFromParts2 = part1 + "/" + part2;

// at the same moment when allInOne is broken, other ones look good
message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
}{code}
The issue:

When {{MyBean}} is used in a single thread (1 queue consumer) everything works 
fine. 

When {{MyBean}} is used with multiple queue consumers after some time (about 50 
messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 

So instead of always having url like 
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/2
...
http://foo.bar/foo/1024
{code}
we start getting weird results such as
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/http://foo.bar/foo/1
http://foo.bar/foo/11
{code}
After experimenting I suspect that the {{Builder.simple}} expression is not 
th

[jira] [Updated] (CAMEL-19346) Builder.simple expression is not thread safe

2023-05-12 Thread Max (Jira)


 [ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Max updated CAMEL-19346:

Description: 
First of all I have to apologize, cannot provide demo project to reproduce the 
error. So, this is the issue:

using route something like this:
{code:java}
from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
{code}
{code:java|title=application.yaml}
foo.base.url: http://foo.bar/foo
{code}
{code:java}
import org.apache.camel.builder.SimpleBuilder;
import static org.apache.camel.builder.Builder.simple;

public class MyBean { 

public static final String PART1 = "{{foo.base.url}}";
public static final String PART2 = "$simple{header.fooId}"
public static final String FULL_URL = PART1 + "/" + PART2;

@Handler
public void process(Exchange exchange) {
var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
String.class);
var part1 = simple(PART1).evaluate(exchange, String.class);
var part2 = simple(PART2).evaluate(exchange, String.class);
var builtFromParts1 = part1 + "/" + message.getHeader("myId");
var builtFromParts2 = part1 + "/" + part2;

// at the same moment when allInOne is broken, other ones look good
message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
}{code}
The issue:

When {{MyBean}} is used in a single thread (1 queue consumer) everything works 
fine. 

When {{MyBean}} is used with multiple queue consumers after some time (about 50 
messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 

So instead of always having url like 
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/2
...
http://foo.bar/foo/1024
{code}
we start getting weird results such as
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/http://foo.bar/foo/1
http://foo.bar/foo/11
{code}
After experimenting I suspect that the {{Builder.simple}} expression is not 
thread safe  or has some internal caching which causes the 
{}expression{} to collide with $simple\{header.foo} when used together 
in the same string.

So it takes the result of {}expression{} sets to some internal cache 
then takes that value and adds the same value + result of ${simple\{header.foo}

When the expressions are evaluated separately Builder.simple() produces correct 
result.

However, this issue never happened with deprecated SimpleBuilder.simple() 
expression.

So even though {{allInOne}} was broken, other values such as 
{{{}allInOneWithSB{}}}, {{{}builtFromParts1{}}}, {{builtFromParts2}} at the 
same time were allways correct no matter how often and how many concurrent 
consumers I used.

 

Update:

switched to \{{SimpleBuilder.simple}} and the same issue hit again. But calling 
{{simple(expression).evaluate(exchange, String.class)}} twice seems to solve 
the issue.

 

  was:
First of all I have to apologize, cannot provide demo project to reproduce the 
error. So, this is the issue:

using route something like this:
{code:java}
from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
{code}
{code:java|title=application.yaml}
foo.base.url: http://foo.bar/foo
{code}
{code:java}
import org.apache.camel.builder.SimpleBuilder;
import static org.apache.camel.builder.Builder.simple;

public class MyBean { 

public static final String PART1 = "{{foo.base.url}}";
public static final String PART2 = "$simple{header.fooId}"
public static final String FULL_URL = PART1 + "/" + PART2;

@Handler
public void process(Exchange exchange) {
var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
String.class);
var part1 = simple(PART1).evaluate(exchange, String.class);
var part2 = simple(PART2).evaluate(exchange, String.class);
var builtFromParts1 = part1 + "/" + message.getHeader("myId");
var builtFromParts2 = part1 + "/" + part2;

// at the same moment when allInOne is broken, other ones look good
message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
}{code}
The issue:

When {{MyBean}} is used in a single thread (1 queue consumer) everything works 
fine. 

When {{MyBean}} is used with multiple queue consumers after some time (about 50 
messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 

So instead of always having url like 
{code:java}
http://foo.bar/foo/1
http://foo.bar/f

[jira] [Updated] (CAMEL-19346) Builder.simple expression is not thread safe

2023-05-12 Thread Max (Jira)


 [ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Max updated CAMEL-19346:

Summary: Builder.simple expression is not thread safe  (was: 
Builder.simple(). evaluator not thread safe)

> Builder.simple expression is not thread safe
> 
>
> Key: CAMEL-19346
> URL: https://issues.apache.org/jira/browse/CAMEL-19346
> Project: Camel
>  Issue Type: Bug
>  Components: came-core
>Affects Versions: 3.20.2, 3.20.3, 3.20.4
>Reporter: Max
>Priority: Major
>
> First of all I have to apologize, cannot provide demo project to reproduce 
> the error. So, this is the issue:
> using route something like this:
> {code:java}
> from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
> {code}
> {code:java|title=application.yaml}
> foo.base.url: http://foo.bar/foo
> {code}
> {code:java}
> import org.apache.camel.builder.SimpleBuilder;
> import static org.apache.camel.builder.Builder.simple;
> public class MyBean { 
> public static final String PART1 = "{{foo.base.url}}";
> public static final String PART2 = "$simple{header.fooId}"
> public static final String FULL_URL = PART1 + "/" + PART2;
> @Handler
> public void process(Exchange exchange) {
> var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
> var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
> String.class);
> var part1 = simple(PART1).evaluate(exchange, String.class);
> var part2 = simple(PART2).evaluate(exchange, String.class);
> var builtFromParts1 = part1 + "/" + message.getHeader("myId");
> var builtFromParts2 = part1 + "/" + part2;
> // at the same moment when allInOne is broken, other ones look good
> message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
> }{code}
> The issue:
> When {{MyBean}} is used in a single thread (1 queue consumer) everything 
> works fine. 
> When {{MyBean}} is used with multiple queue consumers after some time (about 
> 50 messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 
> So instead of always having url like 
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/2
> ...
> http://foo.bar/foo/1024
> {code}
> we start getting weird results such as
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/http://foo.bar/foo/1
> http://foo.bar/foo/11
> {code}
> After experimenting I suspect that the {{Builder.simple}} expression is not 
> thread safe  or has some internal caching which causes the 
> {{\{\{expression\}\}}} to collide with $simple\{header.foo} when used 
> together in the same string.
> So it takes the result of {{\{\{expression\}\}}} sets to some internal cache 
> then takes that value and adds the same value + result of 
> ${simple\{header.foo}
> When the expressions are evaluated separately Builder.simple() produces 
> correct result.
> However, this issue never happened with deprecated SimpleBuilder.simple() 
> expression.
> So even though {{allInOne}} was broken, other values such as 
> {{{}allInOneWithSB{}}}, {{{}builtFromParts1{}}}, {{builtFromParts2}} at the 
> same time were allways correct no matter how often and how many concurrent 
> consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (CAMEL-19346) Builder.simple(). evaluator not thread safe

2023-05-12 Thread Max (Jira)


 [ 
https://issues.apache.org/jira/browse/CAMEL-19346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Max updated CAMEL-19346:

Summary: Builder.simple(). evaluator not thread safe  (was: simple 
evaluator not thread safe)

> Builder.simple(). evaluator not thread safe
> ---
>
> Key: CAMEL-19346
> URL: https://issues.apache.org/jira/browse/CAMEL-19346
> Project: Camel
>  Issue Type: Bug
>  Components: came-core
>Affects Versions: 3.20.2, 3.20.3, 3.20.4
>Reporter: Max
>Priority: Major
>
> First of all I have to apologize, cannot provide demo project to reproduce 
> the error. So, this is the issue:
> using route something like this:
> {code:java}
> from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
> {code}
> {code:java|title=application.yaml}
> foo.base.url: http://foo.bar/foo
> {code}
> {code:java}
> import org.apache.camel.builder.SimpleBuilder;
> import static org.apache.camel.builder.Builder.simple;
> public class MyBean { 
> public static final String PART1 = "{{foo.base.url}}";
> public static final String PART2 = "$simple{header.fooId}"
> public static final String FULL_URL = PART1 + "/" + PART2;
> @Handler
> public void process(Exchange exchange) {
> var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
> var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
> String.class);
> var part1 = simple(PART1).evaluate(exchange, String.class);
> var part2 = simple(PART2).evaluate(exchange, String.class);
> var builtFromParts1 = part1 + "/" + message.getHeader("myId");
> var builtFromParts2 = part1 + "/" + part2;
> // at the same moment when allInOne is broken, other ones look good
> message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
> message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
> message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
> }{code}
> The issue:
> When {{MyBean}} is used in a single thread (1 queue consumer) everything 
> works fine. 
> When {{MyBean}} is used with multiple queue consumers after some time (about 
> 50 messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 
> So instead of always having url like 
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/2
> ...
> http://foo.bar/foo/1024
> {code}
> we start getting weird results such as
> {code:java}
> http://foo.bar/foo/1
> http://foo.bar/foo/http://foo.bar/foo/1
> http://foo.bar/foo/11
> {code}
> After experimenting I suspect that the {{Builder.simple}} expression is not 
> thread safe  or has some internal caching which causes the 
> {{\{\{expression\}\}}} to collide with $simple\{header.foo} when used 
> together in the same string.
> So it takes the result of {{\{\{expression\}\}}} sets to some internal cache 
> then takes that value and adds the same value + result of 
> ${simple\{header.foo}
> When the expressions are evaluated separately Builder.simple() produces 
> correct result.
> However, this issue never happened with deprecated SimpleBuilder.simple() 
> expression.
> So even though {{allInOne}} was broken, other values such as 
> {{{}allInOneWithSB{}}}, {{{}builtFromParts1{}}}, {{builtFromParts2}} at the 
> same time were allways correct no matter how often and how many concurrent 
> consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (CAMEL-19346) simple evaluator not thread safe

2023-05-12 Thread Max (Jira)
Max created CAMEL-19346:
---

 Summary: simple evaluator not thread safe
 Key: CAMEL-19346
 URL: https://issues.apache.org/jira/browse/CAMEL-19346
 Project: Camel
  Issue Type: Bug
  Components: came-core
Affects Versions: 3.20.4, 3.20.3, 3.20.2
Reporter: Max


First of all I have to apologize, cannot provide demo project to reproduce the 
error. So, this is the issue:

using route something like this:
{code:java}
from(activemq..?consumerCount=5).bean(MyBean.class).to("http:foo.bar/url") 
{code}
{code:java|title=application.yaml}
foo.base.url: http://foo.bar/foo
{code}
{code:java}
import org.apache.camel.builder.SimpleBuilder;
import static org.apache.camel.builder.Builder.simple;

public class MyBean { 

public static final String PART1 = "{{foo.base.url}}";
public static final String PART2 = "$simple{header.fooId}"
public static final String FULL_URL = PART1 + "/" + PART2;

@Handler
public void process(Exchange exchange) {
var allInOne = simple(FULL_URL).evaluate(exchange, String.class);
var allInOneWithSB = SimpleBuilder.simple(FULL_URL).evaluate(exchange,   
String.class);
var part1 = simple(PART1).evaluate(exchange, String.class);
var part2 = simple(PART2).evaluate(exchange, String.class);
var builtFromParts1 = part1 + "/" + message.getHeader("myId");
var builtFromParts2 = part1 + "/" + part2;

// at the same moment when allInOne is broken, other ones look good
message.setHeader(Exchange.HTTP_URI, allInOne); // sometimes broken
message.setHeader(Exchange.HTTP_URI, allInOneWithSB); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts1); // always correct
message.setHeader(Exchange.HTTP_URI, builtFromParts2); // always correct
}{code}
The issue:

When {{MyBean}} is used in a single thread (1 queue consumer) everything works 
fine. 

When {{MyBean}} is used with multiple queue consumers after some time (about 50 
messages with 5 consumers) starts messing up the Exchange.HTTP_URI value. 

So instead of always having url like 
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/2
...
http://foo.bar/foo/1024
{code}
we start getting weird results such as
{code:java}
http://foo.bar/foo/1
http://foo.bar/foo/http://foo.bar/foo/1
http://foo.bar/foo/11
{code}
After experimenting I suspect that the {{Builder.simple}} expression is not 
thread safe  or has some internal caching which causes the 
{{\{\{expression\}\}}} to collide with $simple\{header.foo} when used together 
in the same string.

So it takes the result of {{\{\{expression\}\}}} sets to some internal cache 
then takes that value and adds the same value + result of ${simple\{header.foo}

When the expressions are evaluated separately Builder.simple() produces correct 
result.

However, this issue never happened with deprecated SimpleBuilder.simple() 
expression.

So even though {{allInOne}} was broken, other values such as 
{{{}allInOneWithSB{}}}, {{{}builtFromParts1{}}}, {{builtFromParts2}} at the 
same time were allways correct no matter how often and how many concurrent 
consumers I used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (CAMEL-19136) Too many tags created by micrometer WebMvcTagsProvider

2023-03-12 Thread Max (Jira)
Max created CAMEL-19136:
---

 Summary: Too many tags created by micrometer WebMvcTagsProvider
 Key: CAMEL-19136
 URL: https://issues.apache.org/jira/browse/CAMEL-19136
 Project: Camel
  Issue Type: Bug
  Components: camel-micrometer
Affects Versions: 3.20.2, 3.20.1, 3.20.0
Reporter: Max


>From discussion  in zulip 
>[https://camel.zulipchat.com/#narrow/stream/257298-camel/topic/springboot.20micrometer.20http.20metrics.20issue/near/340948367]

in https://issues.apache.org/jira/browse/CAMEL-18754 
https://github.com/apache/camel-spring-boot/commit/ac318f0418e55c56d0fb426607c67a5ceb1f6742
 new configuration has been introduced {{MicrometerTagsAutoConfiguration}}.

Request {{uri}} with placeholders in the metrics tag is replaced with actual 
value e.g.
{code}
 @RequestMapping(value = "/users/{id}" method = RequestMethod.GET)
{code}
instead of 
{code}
http_server_requests_seconds_bucket{application="my-app",exception="None",method="GET",outcome="SUCCESS",status="200",uri="/users/{id}",le="0.894784851",}
 .0
{code}

is reported as 

{code}
http_server_requests_seconds_bucket{application="my-app",exception="None",method="GET",outcome="SUCCESS",status="200",uri="/users/1",le="0.894784851",}
 1.0
http_server_requests_seconds_bucket{application="my-app",exception="None",method="GET",outcome="SUCCESS",status="200",uri="/users/2",le="0.894784851",}
 1.0
http_server_requests_seconds_bucket{application="my-app",exception="None",method="GET",outcome="SUCCESS",status="200",uri="/users/3",le="0.894784851",}
 1.0
http_server_requests_seconds_bucket{application="my-app",exception="None",method="GET",outcome="SUCCESS",status="200",uri="/users/99",le="0.894784851",}
 1.0
{code}
and of course will end up a lot of tags which is bad for prometheus.

and spring reports warning
{code}
logger_name 
org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDenyMeterFilter
message Reached the maximum number of URI tags for 'http.server.requests'.
How can we preserve original uri tag? We combine camel with spring boot, so 
rest api layer is provided by spring boot but integration layer (messaging, 
http client etc.. ) is done by camel, so would love to keep camel route stats 
but keep spring boot reported metrics
{code}

basically
{code}
@Bean
WebMvcTagsProvider webMvcTagsProvider() {

return Tags.concat(
super.getTags(request, response, handler, exception),
Tags.of(Tag.of("uri", uri))
);
{code}
makes out of {{/users/\{id\}}} -> {{/users/1}}
by excluding 
{code}
@SpringBootApplication(exclude = {MicrometerTagsAutoConfiguration.class}) 
{code}

we get the original behavior. But the risk is that if future versions add more 
beans into MicrometerTagsAutoConfiguration they will be ignored

How can we preserve original uri tag or make it configurable?
may be regex/whitelist/blacklist on which it should apply? 




 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (CAMEL-12177) Dns Routing Policy to start/stop routes based on dns changes.

2018-01-22 Thread Max (JIRA)
Max created CAMEL-12177:
---

 Summary: Dns Routing Policy to start/stop routes based on dns 
changes.
 Key: CAMEL-12177
 URL: https://issues.apache.org/jira/browse/CAMEL-12177
 Project: Camel
  Issue Type: New Feature
  Components: camel-dns
Affects Versions: 2.21.0
Reporter: Max


Dns Routing Policy to start/stop routes based on dns changes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)