Yashasvi Raj Pant
Yashasvi Raj Pant

Reputation: 1424

Concurrency Issue in ISORequestListener

I am using jpos library for transaction management(Spring boot project). I am implementing ISORequestListener as below.

@Component
public class MyRequestListner implements ISORequestListener, Configurable {

    protected String var1;
    protected String var2;

    @Override
    public void setConfiguration(Configuration cfg) throws ConfigurationException {
        var1 = cfg.get("var1");
        var2 = cfg.get("var2");
    }

    @Override
    public boolean process(ISOSource source, ISOMsg m) {
        Context ctx = new Context();
        ctx.put("ctx1", var1);
        ctx.put("ctx2", var2);
        return true;
    }
}

On running SonarQube (code analyzing tool), I got the error message as:

Annotate global variables with "@Autowired", "@Resource", "@Inject", or "@Value", or don’t use on Spring @Component, @Controller, @Service, and @Repository classes.

Spring @Component, @Controller, @Service, and @Repository classes are singletons by default, meaning only one instance of the class is ever instantiated in the application.

Such a class might have a few static members, such as a logger, but all non-static members should be managed by Spring. That is, they should have one of these annotations: @Resource, @Inject, @Autowired or @Value.

Does this cause any concurrency issue(or thread issue) or internally handled by jpos? What could be the correct implementation if it really causes the problem?

Upvotes: 0

Views: 190

Answers (1)

apr
apr

Reputation: 1343

Not a problem if you run jPOS within its own Q2 micro-kernel. If that's not the case, I'm afraid you're mostly on your own. Running inside Q2 is extremely simple, it's a one liner: new Q2().start(); that you can run from any other framework, and then let Q2 configure your jPOS components.

Upvotes: 1

Related Questions