Open cesarjv opened 4 days ago
/cc @radcortez (config)
This is almost certainly not a Quarkus issue, but either a misuse of Camel Quarkus or a bug with that project.
cc @ppalaga
The injection does not work if you call new UserProfileProcessorQueryParamReq()
directly. You have to let the CDI container to create the bean:
@ApplicationScoped
@Inject UserProfileProcessorUserIdParamReq processor;
to your route builder.process(processor)
@ppalaga Thank you for your response, could you apply the example of what you tell me in the code to try to replicate it on my side?
Ups, sorry, I thought, my suggestion was clear enough. Which part requires more details so that you can do the 3 changes yourself?
@ppalaga I go point by point, to see if I understood:
Does it mean adding the @ApplicationScoped annotation to my ReaRoute class? It has the same one, just don't put the complete code:
@ApplicationScoped
public class ResRoute extends RouteBuilder {
/*code */
from("direct:usersQueryParam")
/*.removeHeaders("CamelHttp*") */
.doTry()
.process(new UserProfileProcessorQueryParamReq()
.choice()
.when(simple("${exchangeProperty[isSearchByQueryParamIdDocumentValueAndIdDocumentType]} == 'true'"))
.to(DIRECT_PIPELINE)
.otherwise()
.log(DATE_LOG+"Identity: ${exchangeProperty[identityQueryParam]}")
.log(DATE_LOG+"IdentityType: ${exchangeProperty[identityTypeQueryParam]}")
.process(new FindCustomerDocumentBySubscriberIdReq())
.log(DATE_LOG+"Entrada Microservicio FindCustomerDocumentBySubscriberId: ${exchangeProperty[findCustomerDocumentBySubscriberIdRequest]}")
.to(configureSsl.setupSSLContext(getCamelContext(), findCustomerDocumentBySubscriberId))
.process(new FindCustomerDocumentBySubscriberIdRes(encryptionKey))
.log(DATE_LOG+"Salida FindCustomerDocumentBySubscriberId: ${exchangeProperty[findCustomerDocumentBySubscriberIdResponseStatus]}")
.log(DATE_LOG+"User ID Mediante QueryParam: ${exchangeProperty[userId]}")
.to(DIRECT_PIPELINE)
.endDoTry()
/*.to(DIRECT_PIPELINE) */
.doCatch(EmptyDataExceptionQueryParam.class)
.process(new UserProfileEmptyDataSubscriberQueryParam())
.log(DATE_LOG+MSG_EXCEPTION)
.log(DATE_LOG+SALIDA_BSS_EXCEPTION);
/* code /*
What does this mean? How can I do it? In the previous point I show how my processor is called, I don't know if I have to modify the way of defining it
I also have a doubt regarding this point, I lack more details on how to apply it because it is not clear to me.
Thanks in advance and sorry if it's not clear to me.
@ppalaga I go point by point, to see if I understood:
Make your RouteBuilder @ApplicationScoped:
Does it mean adding the @ApplicationScoped annotation to my ReaRoute class? It has the same one, just don't put the complete code:
Exactly
Add @Inject UserProfileProcessorUserIdParamReq processor; to your route builder
What does this mean? How can I do it? In the previous point I show how my processor is called, I don't know if I have to modify the way of defining it
You need to add the following code to your ResRoute
class or any other class where you want to use the UserProfileProcessorUserIdParamReq:
@Inject
UserProfileProcessorUserIdParamReq processor;
Change the route definition: .process(processor)
I also have a doubt regarding this point, I lack more details on how to apply it because it is not clear to me.
Hm... reading your code again, it actually does not show any usage of UserProfileProcessorUserIdParamReq. Where do you use it then? I originally thought, there is .process(new UserProfileProcessorUserIdParamReq())
somewhere in ResRoute
, but there are only invocations of other processors like .process(new UserProfileProcessorQueryParamReq())
, `.process(new FindCustomerDocumentBySubscriberIdReq())
etc.
So if you had .process(new UserProfileProcessorUserIdParamReq())
somewhere in your route builder, you would have to replace it with .process(processor)
and the NPE should disappear.
Good morning, I am currently working with Quarkus and Apache Camel and I am using a variable from the application.properties in a processor, I try to bring it in using the @ConfigProperty annotation, but it is giving me a null error, this is how I have it configured:
The variable is called encryptionKey
UserProfileProcessorUserIdParamReq
And this is the error it gives:
14:52:44 INFO traceId=2a0a8e8cd93ddb947e2ab7206ef4f25d, parentId=, spanId=394c6d08dec8d551, sampled=true [route23] (vert.x-worker-thread-0) [2024-07-01 14:52:44.0] Descripcion de la Exception: Cannot invoke "String.getBytes()" because "key" is null
This is how it is in my application.properties:
aes.encrypt.key=${AES_ENCRYPT_KEY:xxxxxxxxxxxx}
Like from ResRoute call to processor without constructor:
How can I do here so that it takes the value of the @ConfigProperty?