1

I am using Spring-integration for listening to queues, and am now faced with a quite silly bug. It turns out that the name of a message paramter was misspelled, leading to runtime errors. To fix it, I have to rebuild the java-class, since the name of the message attribute is a hardcoded String. I would like to resolve such errors easier in the future, by making the name of the message attributes configurable through a properties-file, but I can't seem to find a way to do it. Is it at all possible?

public void someListenerMethod(@Header("someAttribute")
                               final Long someAttribute) {

I would here like to make the parameter to @Header configurable..

2
  • 1
    Instead of making the whole world configurable, you should integration tester application imho. Trying to make it configurable introduces more complexity and thus more things that can go wrong. More complexity, more code leads to even more bugs (that is statistically proved). Keep it simple and write a good test harness. Commented Jul 1, 2015 at 13:48
  • The message is sent from module and read by another, and I don't have any base for making integration tests across modules. This should of course have been discovered in some part of the test regime, but as it slipped through it would be nice to have some way of dealing with the situation that doesn't involve a new build, delivery, etc. I don't see how pulling string constants out into properties adds enough complexity for it to become a problem. Commented Jul 1, 2015 at 13:54

1 Answer 1

1

I'll answer myself as I found one way of doing this (although I'm not sure it's optimal..)

@Value("${my.header.property.name}")
private String myHeaderPropertyName;

public void someListenerMethod(@Headers
                               final Map<String, Object> headerAttributes) {
    final Long myHeaderAttribute = (Long) headerAttributes.get(myHeaderPropertyName));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.