Reputation: 229
I am trying to dynamically set the url for my outbound-gateway element, and it is not working for some reason. Everything worked fine before I tried to set it dynamically.
Here is the relevant part of the xml:
<int-http:outbound-gateway
request-channel="sumTicketChannelOutput"
url="{ticketsSum}"
http-method="POST"
uri-variables-expression="@uriVariableBean.populateTicketSumUrl(payload)"
extract-request-payload="true"
expected-response-type="mypackage.dto.bet.SlipAddTransactionsResultWrapper">
</int-http:outbound-gateway>
Note that I am using uriVariableBean in another gateway that has been defined in the same file, and that gateway works, so its definitely not a problem with importing that bean, I just have not pasted the code.
Here is the relevant code from the bean:
@Value("${vfl.tickets.sum}")
private String defaultVirtualTicketsAddress;
@Value("${vfl.tickets.sum.ba}")
private String specialVirtualTicketsAddress;
public Map<String, ?> populateTicketSumUrl(Object payload) {
Map<String, Object> variables = new HashMap<String, Object>();
if (payload instanceof SlipDataRequest) {
BetSlipDataRequest dataRequest = (SlipDataRequest) payload;
Integer lcMemberId = dataRequest.getLcMemberId() != null ? dataRequest.getLcMemberId().intValue() : null;
if (webUserService.isSpecial(lcMemberId)) {
variables.put("ticketsSum", specialVirtualTicketsAddress);
} else {
variables.put("ticketsSum", defaultVirtualTicketsAddress);
}
} else {
variables.put("ticketsSum", EXPRESSION_PARSER.parseExpression("headers.ticketsSum"));
}
return variables;
}
The error I get when invoking an operation using the gateway is the following:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Field or property 'ticketsSum' cannot be found on object of type 'org.springframework.integration.MessageHeaders'
Any insight on why this could be happening would be greatly appreciated, as I have went through the documentation and all the online posts I could find and still have absolutely no idea why this is happening.
Upvotes: 0
Views: 933
Reputation: 174769
It means the message being sent doesn't have that header. DEBUG logging is always your fried.
When accessing headers, it's generally better to use the map accessor headers['ticketsSum']
rather than the property accessor headers.ticketsSum
because the former will resolve to null
for a missing header, whereas the latter will throw the exception you observe.
Upvotes: 1