Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetOriginalMessageProcessor - removed casting situations and added logs #275

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,28 @@ public void process(Exchange exchange) throws Exception {

switch (originalHttpMessageMethod) {
case GET:
log.info(" > GET OriginalHttpMessage");
// load the original http message into the current exchange from the camel global variable

// load retry attempts
Object retryAttempts = exchange.getMessage().getHeader(DOVETAIL_RETRY_ATTEMPTS_HEADER);
int retryAttemptsInt = (Integer)retryAttempts + 1;
Integer retryAttempts = exchange.getMessage().getHeader(DOVETAIL_RETRY_ATTEMPTS_HEADER, Integer.class);
retryAttempts++;

// load original http message variable id
variableId = (String) exchange.getMessage().getHeader(DOVETAIL_ORIGINAL_HTTP_MESSAGE_VARIABLE_ID_HEADER);
variableId = exchange.getMessage().getHeader(DOVETAIL_ORIGINAL_HTTP_MESSAGE_VARIABLE_ID_HEADER, String.class);

// load original http message from global variable
Message originalHttpMessage = (Message) exchange.getVariable(CAMEL_GLOBAL_VARIABLE_PREFIX + variableId);
Message originalHttpMessage = exchange.getVariable(CAMEL_GLOBAL_VARIABLE_PREFIX + variableId, Message.class);

// set retry attempts
originalHttpMessage.setHeader(DOVETAIL_RETRY_ATTEMPTS_HEADER, retryAttemptsInt);
originalHttpMessage.setHeader(DOVETAIL_RETRY_ATTEMPTS_HEADER, retryAttempts);

// load original http message into exchange
exchange.setMessage(originalHttpMessage);
break;

case SET:
log.info(" > SET OriginalHttpMessage");
// set the current exchange message as the original http message in the camel global variable

// set retry attempts to 1
Expand All @@ -62,8 +64,9 @@ public void process(Exchange exchange) throws Exception {
break;

case DEL:
log.info(" > DEL OriginalHttpMessage");
// delete the original http message from the camel global variables
variableId = (String) exchange.getMessage().getHeader(DOVETAIL_ORIGINAL_HTTP_MESSAGE_VARIABLE_ID_HEADER);
variableId = exchange.getMessage().getHeader(DOVETAIL_ORIGINAL_HTTP_MESSAGE_VARIABLE_ID_HEADER, String.class);
exchange.removeVariable(CAMEL_GLOBAL_VARIABLE_PREFIX + variableId);
break;

Expand Down