Error retrieving connections in jboss to multiple databases even though there is no transaction

后端 未结 2 1591
天涯浪人
天涯浪人 2021-01-01 21:45

We are in the process of upgrading from JBoss 6 to JBoss 7. The nature of our application has a separate database instance per customer, as well as a core configuration data

相关标签:
2条回答
  • 2021-01-01 21:57

    Two suggestions:

    1. Consider updating the datasources to their XA equivalents. This will solve all your problems. I suspect you are hindered here?
    2. Consider setting com.arjuna.ats.arjuna.allowMultipleLastResources to true in the server conf. This will allow the behaviour you want, but unfortunately for the whole app, not just the method.

    Update:

    I don't recommend enabling multiple one-phase resources since it weakens the transactional properties of you app substantially. But if you want to do this in JBoss 7 you need to modify standalone.xml and add:

    <system-properties>
            <property name="com.arjuna.ats.arjuna.allowMultipleLastResources" value="true"/>
    </system-properties>
    

    You now have a system which is not far away from one without transactions. What it will still do though, is to warn you if you get heuristic outcomes.

    My recommendation is still to use XA datasources if you can.

    Update 2:

    Oh, and if someone comes along to read this I want to add that if you can divide your code into different methods, unlike the OP, I would recommend restructuring your code and use @TransactionAttribute(REQUIRES_NEW) to create parallel transactions. This is better than turning on multiple 1PC, albeit not as good as turning on XA.

    0 讨论(0)
  • 2021-01-01 22:00

    OK, it turns out that unlike JBoss6, a NOT_SUPPORTED transaction is still a transaction as far as the validation logic for retrieving data sources is concerned.

    The way to work around this is to make the whole EJB a bean managed transaction:

    @TransactionManagement(TransactionManagementType.BEAN)
    

    This unfortunately limits some flexibility in that some times you would rather control this method-by-method, but it isn't too painful a workaround.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题