Re: elegant error handling with temporary replyTo ?

2023-01-06 Thread Claus Ibsen
You can send a PR to tweak the log to not output the stacktrace. We could
potentially log including stacktrace in DEBUG mode so end users can turn on
that logging level in case the stacktrace is needed during troubleshooting

On Fri, Jan 6, 2023 at 12:22 PM Mark Webb  wrote:

> Sure, I could tweak the logger.  I was hoping to not have the stack trace
> get logged, but a more user-friendly log generated.
>
> On Fri, Jan 6, 2023 at 12:56 AM Claus Ibsen  wrote:
>
> > Hi
> >
> > Do you want that WARN to not be logged - or the logging to NOT include
> the
> > stacktrace?
> > The log is hardcoded and it can happened when using temporary reply
> queues.
> >
> > You can tweak the logger to set logging level to ERROR
> > for TemporaryQueueReplyManager etc
> >
> >
> > On Thu, Jan 5, 2023 at 8:51 PM Mark Webb  wrote:
> >
> > > I'm starting up a project that will use the request/response with
> > ActiveMQ
> > > AMQP.  When I try to send a message that I expect a response to and
> > > ActiveMQ is down, I can't seem to catch or prevent the stack trace from
> > > getting logged for the TemporaryQueueReplyManager.  The error is:
> > >
> > > Exception inside the DMLC for Temporary ReplyTo Queue for destination
> > ,
> > > refreshing ReplyTo destination
> > >
> > > How can I go about handling this error in the temporary response
> > > processing?  Any help would be appreciated.
> > >
> > > Thanks,
> > > Mark
> > >
> >
> >
> > --
> > Claus Ibsen
> > -
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>


-- 
Claus Ibsen
-
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: elegant error handling with temporary replyTo ?

2023-01-06 Thread Mark Webb
Sure, I could tweak the logger.  I was hoping to not have the stack trace
get logged, but a more user-friendly log generated.

On Fri, Jan 6, 2023 at 12:56 AM Claus Ibsen  wrote:

> Hi
>
> Do you want that WARN to not be logged - or the logging to NOT include the
> stacktrace?
> The log is hardcoded and it can happened when using temporary reply queues.
>
> You can tweak the logger to set logging level to ERROR
> for TemporaryQueueReplyManager etc
>
>
> On Thu, Jan 5, 2023 at 8:51 PM Mark Webb  wrote:
>
> > I'm starting up a project that will use the request/response with
> ActiveMQ
> > AMQP.  When I try to send a message that I expect a response to and
> > ActiveMQ is down, I can't seem to catch or prevent the stack trace from
> > getting logged for the TemporaryQueueReplyManager.  The error is:
> >
> > Exception inside the DMLC for Temporary ReplyTo Queue for destination
> ,
> > refreshing ReplyTo destination
> >
> > How can I go about handling this error in the temporary response
> > processing?  Any help would be appreciated.
> >
> > Thanks,
> > Mark
> >
>
>
> --
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


Re: Objects not propagated to Camel Kafka 3.18.4

2023-01-06 Thread Claus Ibsen
You can also use string uri instead of endpoint dsl, then you can refer to
the via kafka:?additionalProperties=#myMapBeanId

So we may need for endpoint dsl to include a fluent builder for Map that is
a string value to use for bean reference lookup

On Fri, Jan 6, 2023 at 9:31 AM Claus Ibsen  wrote:

>
>
> On Fri, Jan 6, 2023 at 9:17 AM Martin Pelikán  wrote:
>
>> Hi Claus,
>>
>> I tested your approach but wasn't successful. Reference is stored in
>> Properties as text. I confirmed bean is registered in Spring context
>> with the proper BeanID.
>>
>> @Bean(name = "tokenCredential")
>> public TokenCredential tokenCredential() {...create an instance}
>>
>> in debugger (simplified) ->
>> camelContext.registry.lookupByName("tokenCredential") -> returns valid
>> object
>> .
>> .additionalProperties("schema.registry.credential", "#tokenCredential")
>>
>> results into
>> "schema.registry.credential" = "#tokenCredential"
>>
>> I guess the hash reference notation works only for Camel-specific fields,
>> like
>> .headerDeserializer("#customKafkaHeaderDeserializer") or
>> .headerFilterStrategy("#customHeaderFilterStrategy")   // verified, works
>>
>> Any ideas?
>>
>
> Okay so we should make this possible for additional properties as well.
> You are welcome to create a JIRA.
>
>
>
>>
>> čt 5. 1. 2023 v 18:22 odesílatel Claus Ibsen 
>> napsal:
>> >
>> > You cannot use complex object types, only string literal, numbers,
>> booleans
>> > etc.
>> >
>> > So what you need to do is to create those objects with some bean id
>> (spring
>> > boot @Bean stuff) and then refer to them via their bean id.
>> >
>> > Something ala
>> >
>> >
>> > .additionallProperties("xxx", "#myBeanId")
>> >
>> >
>> >
>> >
>> > On Thu, Jan 5, 2023 at 6:10 PM Martin Pelikán 
>> wrote:
>> >
>> > > My case is related to connecting to Azure EventHubs Avro Schema
>> Registry.
>> > >
>> > > TokenCredential cred = new
>> > >
>> > >
>> ClientSecretCredentialBuilder().tenantId("xxx").clientId("xxx").clientSecret("xx").build();
>> > > props.put("schema.registry.credential", cred);
>> > >
>> > > Another case that comes to my mind is with OAUTHBEARER authentication.
>> > > Users could supply instantiated AuthenticateCallbackHandler class to
>> > > the  sasl.login.callback.handler.class property.
>> > >
>> > > TokenCredential as part of Properties works with
>> > > org.apache.kafka.clients.consumer.KafkaConsumer.
>> > >
>> > > čt 5. 1. 2023 v 17:59 odesílatel Claus Ibsen 
>> > > napsal:
>> > > >
>> > > > Whats the real world use-case for additional properties as Object
>> or Map.
>> > > > What would kafka understand and use these for?
>> > > >
>> > > > On Thu, Jan 5, 2023 at 5:12 PM Martin Pelikán 
>> > > wrote:
>> > > >
>> > > > > Hi Camel experts,
>> > > > >
>> > > > > I am struggling with a Kafka component and passing in parameters
>> via
>> > > > > additionalProperties. I am not able to propagate an Object. I
>> tested
>> > > > > only Endpoint DSL. According to the Camel docs and APIs, I am
>> allowed
>> > > > > to pass in an instance of Map
>> > > > >
>> > > > >  Camel version: 3.18.4
>> > > > >
>> > > > > Pseudocode-
>> > > > >
>> > > > > @Configuration
>> > > > > Class SpringConfig
>> > > > >
>> > > > > @Bean(name = "autowiredMap")
>> > > > > public Map autowiredMap() {
>> > > > > var map = new HashMap();
>> > > > > map.put("testStringKey3", "testStringValue3");
>> > > > > map.put("testObjectKey3", new Object());
>> > > > > }
>> > > > >
>> > > > > ---
>> > > > >
>> > > > > Class MainRoute extends RouteBuilder()
>> > > > >
>> > > > > @Autowired
>> > > > > @Qualifier("autowiredMap")
>> > > > > Map autowiredMap;
>> > > > >
>> > > > > var map = new HashMap();
>> > > > > map.put("testStringKey1", "testStringValue1");
>> > > > > map.put("testObjectKey1", new Object());
>> > > > >
>> > > > > from(kafka(…basic configuration works)
>> > > > > .schemaRegistryURL(http://original.com)
>> > > > > .additionalProperties(map)
>> > > > > .additionalProperties("testStringKey2", "testStringValue2")
>> > > > > .additionalProperties("testObjectKey1", new Object())
>> > > > > .additionalProperties("schema.registry.url",
>> > > http://overwritten.com)
>> > > > > .additionalProperties(autowiredMap)...
>> > > > >
>> > > > > Expected:
>> > > > >
>> > > > > All properties from all additionalProperties methods are
>> propagated to
>> > > > > the Kafka Properties configuration object.
>> > > > >
>> > > > > In reality, Properties will contain the following:
>> > > > > schema.registry.url=http://overwritten.com
>> > > > > testStringKey1=testStringValue1
>> > > > > testStringKey2=testStringValue2
>> > > > >
>> > > > > Non-string values are not propagated at all. Values from
>> autowired Map
>> > > > > are not propagated at all. Autowired map is treated as
>> > > > > additionalProperties.autowiredMap=HashMap@123456
>> > > > >
>> > > > > I can see those String values being added to the Kafka Endpoint
>> URI:
>> > > > >
>> > > > >
>> 

Re: Objects not propagated to Camel Kafka 3.18.4

2023-01-06 Thread Claus Ibsen
On Fri, Jan 6, 2023 at 9:17 AM Martin Pelikán  wrote:

> Hi Claus,
>
> I tested your approach but wasn't successful. Reference is stored in
> Properties as text. I confirmed bean is registered in Spring context
> with the proper BeanID.
>
> @Bean(name = "tokenCredential")
> public TokenCredential tokenCredential() {...create an instance}
>
> in debugger (simplified) ->
> camelContext.registry.lookupByName("tokenCredential") -> returns valid
> object
> .
> .additionalProperties("schema.registry.credential", "#tokenCredential")
>
> results into
> "schema.registry.credential" = "#tokenCredential"
>
> I guess the hash reference notation works only for Camel-specific fields,
> like
> .headerDeserializer("#customKafkaHeaderDeserializer") or
> .headerFilterStrategy("#customHeaderFilterStrategy")   // verified, works
>
> Any ideas?
>

Okay so we should make this possible for additional properties as well. You
are welcome to create a JIRA.



>
> čt 5. 1. 2023 v 18:22 odesílatel Claus Ibsen 
> napsal:
> >
> > You cannot use complex object types, only string literal, numbers,
> booleans
> > etc.
> >
> > So what you need to do is to create those objects with some bean id
> (spring
> > boot @Bean stuff) and then refer to them via their bean id.
> >
> > Something ala
> >
> >
> > .additionallProperties("xxx", "#myBeanId")
> >
> >
> >
> >
> > On Thu, Jan 5, 2023 at 6:10 PM Martin Pelikán 
> wrote:
> >
> > > My case is related to connecting to Azure EventHubs Avro Schema
> Registry.
> > >
> > > TokenCredential cred = new
> > >
> > >
> ClientSecretCredentialBuilder().tenantId("xxx").clientId("xxx").clientSecret("xx").build();
> > > props.put("schema.registry.credential", cred);
> > >
> > > Another case that comes to my mind is with OAUTHBEARER authentication.
> > > Users could supply instantiated AuthenticateCallbackHandler class to
> > > the  sasl.login.callback.handler.class property.
> > >
> > > TokenCredential as part of Properties works with
> > > org.apache.kafka.clients.consumer.KafkaConsumer.
> > >
> > > čt 5. 1. 2023 v 17:59 odesílatel Claus Ibsen 
> > > napsal:
> > > >
> > > > Whats the real world use-case for additional properties as Object or
> Map.
> > > > What would kafka understand and use these for?
> > > >
> > > > On Thu, Jan 5, 2023 at 5:12 PM Martin Pelikán 
> > > wrote:
> > > >
> > > > > Hi Camel experts,
> > > > >
> > > > > I am struggling with a Kafka component and passing in parameters
> via
> > > > > additionalProperties. I am not able to propagate an Object. I
> tested
> > > > > only Endpoint DSL. According to the Camel docs and APIs, I am
> allowed
> > > > > to pass in an instance of Map
> > > > >
> > > > >  Camel version: 3.18.4
> > > > >
> > > > > Pseudocode-
> > > > >
> > > > > @Configuration
> > > > > Class SpringConfig
> > > > >
> > > > > @Bean(name = "autowiredMap")
> > > > > public Map autowiredMap() {
> > > > > var map = new HashMap();
> > > > > map.put("testStringKey3", "testStringValue3");
> > > > > map.put("testObjectKey3", new Object());
> > > > > }
> > > > >
> > > > > ---
> > > > >
> > > > > Class MainRoute extends RouteBuilder()
> > > > >
> > > > > @Autowired
> > > > > @Qualifier("autowiredMap")
> > > > > Map autowiredMap;
> > > > >
> > > > > var map = new HashMap();
> > > > > map.put("testStringKey1", "testStringValue1");
> > > > > map.put("testObjectKey1", new Object());
> > > > >
> > > > > from(kafka(…basic configuration works)
> > > > > .schemaRegistryURL(http://original.com)
> > > > > .additionalProperties(map)
> > > > > .additionalProperties("testStringKey2", "testStringValue2")
> > > > > .additionalProperties("testObjectKey1", new Object())
> > > > > .additionalProperties("schema.registry.url",
> > > http://overwritten.com)
> > > > > .additionalProperties(autowiredMap)...
> > > > >
> > > > > Expected:
> > > > >
> > > > > All properties from all additionalProperties methods are
> propagated to
> > > > > the Kafka Properties configuration object.
> > > > >
> > > > > In reality, Properties will contain the following:
> > > > > schema.registry.url=http://overwritten.com
> > > > > testStringKey1=testStringValue1
> > > > > testStringKey2=testStringValue2
> > > > >
> > > > > Non-string values are not propagated at all. Values from autowired
> Map
> > > > > are not propagated at all. Autowired map is treated as
> > > > > additionalProperties.autowiredMap=HashMap@123456
> > > > >
> > > > > I can see those String values being added to the Kafka Endpoint
> URI:
> > > > >
> > > > >
> > >
> kafka://additionalProperties.testStringKey1=xxx=xxx=xxx..
> > > > >
> > > > > Is it a bug in Camel or did I understand the documentation wrong? I
> > > > > can prepare a test case later
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Martin
> > > > >
> > > >
> > > >
> > > > --
> > > > Claus Ibsen
> > > > -
> > > > @davsclaus
> > > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> >
> >
> > --
> > Claus Ibsen
> > 

Re: Objects not propagated to Camel Kafka 3.18.4

2023-01-06 Thread Martin Pelikán
Hi Claus,

I tested your approach but wasn't successful. Reference is stored in
Properties as text. I confirmed bean is registered in Spring context
with the proper BeanID.

@Bean(name = "tokenCredential")
public TokenCredential tokenCredential() {...create an instance}

in debugger (simplified) ->
camelContext.registry.lookupByName("tokenCredential") -> returns valid
object
.
.additionalProperties("schema.registry.credential", "#tokenCredential")

results into
"schema.registry.credential" = "#tokenCredential"

I guess the hash reference notation works only for Camel-specific fields, like
.headerDeserializer("#customKafkaHeaderDeserializer") or
.headerFilterStrategy("#customHeaderFilterStrategy")   // verified, works

Any ideas?

čt 5. 1. 2023 v 18:22 odesílatel Claus Ibsen  napsal:
>
> You cannot use complex object types, only string literal, numbers, booleans
> etc.
>
> So what you need to do is to create those objects with some bean id (spring
> boot @Bean stuff) and then refer to them via their bean id.
>
> Something ala
>
>
> .additionallProperties("xxx", "#myBeanId")
>
>
>
>
> On Thu, Jan 5, 2023 at 6:10 PM Martin Pelikán  wrote:
>
> > My case is related to connecting to Azure EventHubs Avro Schema Registry.
> >
> > TokenCredential cred = new
> >
> > ClientSecretCredentialBuilder().tenantId("xxx").clientId("xxx").clientSecret("xx").build();
> > props.put("schema.registry.credential", cred);
> >
> > Another case that comes to my mind is with OAUTHBEARER authentication.
> > Users could supply instantiated AuthenticateCallbackHandler class to
> > the  sasl.login.callback.handler.class property.
> >
> > TokenCredential as part of Properties works with
> > org.apache.kafka.clients.consumer.KafkaConsumer.
> >
> > čt 5. 1. 2023 v 17:59 odesílatel Claus Ibsen 
> > napsal:
> > >
> > > Whats the real world use-case for additional properties as Object or Map.
> > > What would kafka understand and use these for?
> > >
> > > On Thu, Jan 5, 2023 at 5:12 PM Martin Pelikán 
> > wrote:
> > >
> > > > Hi Camel experts,
> > > >
> > > > I am struggling with a Kafka component and passing in parameters via
> > > > additionalProperties. I am not able to propagate an Object. I tested
> > > > only Endpoint DSL. According to the Camel docs and APIs, I am allowed
> > > > to pass in an instance of Map
> > > >
> > > >  Camel version: 3.18.4
> > > >
> > > > Pseudocode-
> > > >
> > > > @Configuration
> > > > Class SpringConfig
> > > >
> > > > @Bean(name = "autowiredMap")
> > > > public Map autowiredMap() {
> > > > var map = new HashMap();
> > > > map.put("testStringKey3", "testStringValue3");
> > > > map.put("testObjectKey3", new Object());
> > > > }
> > > >
> > > > ---
> > > >
> > > > Class MainRoute extends RouteBuilder()
> > > >
> > > > @Autowired
> > > > @Qualifier("autowiredMap")
> > > > Map autowiredMap;
> > > >
> > > > var map = new HashMap();
> > > > map.put("testStringKey1", "testStringValue1");
> > > > map.put("testObjectKey1", new Object());
> > > >
> > > > from(kafka(…basic configuration works)
> > > > .schemaRegistryURL(http://original.com)
> > > > .additionalProperties(map)
> > > > .additionalProperties("testStringKey2", "testStringValue2")
> > > > .additionalProperties("testObjectKey1", new Object())
> > > > .additionalProperties("schema.registry.url",
> > http://overwritten.com)
> > > > .additionalProperties(autowiredMap)...
> > > >
> > > > Expected:
> > > >
> > > > All properties from all additionalProperties methods are propagated to
> > > > the Kafka Properties configuration object.
> > > >
> > > > In reality, Properties will contain the following:
> > > > schema.registry.url=http://overwritten.com
> > > > testStringKey1=testStringValue1
> > > > testStringKey2=testStringValue2
> > > >
> > > > Non-string values are not propagated at all. Values from autowired Map
> > > > are not propagated at all. Autowired map is treated as
> > > > additionalProperties.autowiredMap=HashMap@123456
> > > >
> > > > I can see those String values being added to the Kafka Endpoint URI:
> > > >
> > > >
> > kafka://additionalProperties.testStringKey1=xxx=xxx=xxx..
> > > >
> > > > Is it a bug in Camel or did I understand the documentation wrong? I
> > > > can prepare a test case later
> > > >
> > > > Best regards,
> > > >
> > > > Martin
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -
> > > @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2