Usage of constructor for my custom processor as bean #1245
Replies: 2 comments 2 replies
-
you can name the processor whatever you like name: myProcessor1 name: myProcessor2 name: myProcessor3 |
Beta Was this translation helpful? Give feedback.
1 reply
-
@davsclaus could you please provide your inputs for the Dheeraj Query?? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Ask a question
I have a processor on karavan 'Singlexmltojsonrequestprocessor'. It has this construtor
Code of my processor
public class Singlexmltojsonrequestprocessor extends Xmlrequestprocessor implements Processor {
private final Logger logger = LogManager.getLogger(getClass());
public Singlexmltojsonrequestprocessor(int seqIndex, boolean parseResponse,
String propertyKey) {
super();
this.setSeqIndex(seqIndex);
this.setParseResponse(parseResponse);
this.setPropertyKey(propertyKey);
}
@OverRide
public void process(Exchange exchange) throws Exception {
//rest of the logic
}
}
I have many route classes which call this constructor of the above processor with different values in the arguments as shown below.
For example,
from("rest:post:/LoanAccountDetails").log("${body}").process(new Singlexmltojsonrequestprocessor(0, false, null))
from("rest:post:/LoanVerification").log("${body}").process(new Singlexmltojsonrequestprocessor(1, true, null))
In my java(spring boot) code, I can do this comfortably as I have different classes and constructor is invoked dynamically with values.
How do I do it on Karavan?
Since, there is no empty constructor, I had to define a bean and add constructor like below hardcoding the argument values.
But, this restricts me from the using same processor(it's constructor) from other routes. Can some one suggest me a solution here as I can't use the same bean(with the values Singlexmltojsonrequestprocessor already) used for for other routes?
'0': '0'
'1': 'false'
'2': null
name: Singlexmltojsonrequestprocessor
type: org.camel.karavan.demo.il.lc.Singlexmltojsonrequestprocessor
Variant
Web Application
Container Management (if applicable)
Docker
Operating System (if applicable)
Windows
Version
4.4.0
Beta Was this translation helpful? Give feedback.
All reactions