How to connect XASession of Solace JMS API with Weblogic Database XAConnection?

Richa
Richa Member Posts: 13 ✭✭

Hi Team, Am looking for a way to connect solace XASession with database XA connection (my datasource is on weblogic server) so that if the query execution fails, solace transaction should be rollback when db transaction.rollback is called; and same with commit statement. Or vice-versa - if solace transaction is rolled back, db transaction should also be rolled back.

TIA!

Answers

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 529 admin

    Hey @Richa - not an expert on transactions, but here are some thoughts. One approach you can take is by configuring a global transaction using the Transaction Manager that both the Solace and the Weblogic transactions can participate in. This way, you ensure that the Solace session and the database connection are part of the same global transaction. Take a look at this resource in the docs for more details https://docs.solace.com/API/Solace-JMS-API/Using-XA-Transactions.htm#

    Basically, you will use SolXAConnectionFactory to create an XA session and make sure to disable direct transport to ensure that only Guaranteed messages are published or received (which is a requirement for transactions).

    For Weblogic, make sure that the XA transaction data source participates in the same global transaction as the Solace session. Read more about configuring global transactions here. https://docs.oracle.com/cd/E50629_01/wls/WLACH/taskhelp/jdbc/jdbc_datasources/ConfigureTransactionOptionsForADataSource.html

    This way, if a part of the transaction fails, the Transaction Manager handles the roll back the entire global transaction which should have XAResource objects obtained from each resource (in this case, Solace and Weblogic).

    Hopefully this helps! Feel free to respond back here with your results and observations.

  • Richa
    Richa Member Posts: 13 ✭✭
    edited July 10 #3

    Hi @Tamimi, thanks for your reply.

    Due to my requirement constrain, I cannot use "SolXAConnectionFactory" for direct connection to solace.

    Currently, am using solace resource adapter for solace connection via weblogic ( with XA Transaction only). Now to get the connection, am using weblogic initial context factory "weblogic.jndi.WLInitialContextFactory".

    PFB ss of java code used for solace connection.

    Now, I want post execution of "send" method, when am doing any DB transaction and it get failed, then message send on solace should also be rollback when db transaction.rollback is called.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 529 admin

    Hmm, I wonder if you can programatically create connection factory and XA Connection Factory Objects for your solution. check more details here

    https://docs.solace.com/API/Solace-JMS-API/Establishing-Connections.htm#establishing_connections_577400906_337783

    This way even if you are using solace resource adapter for solace connection via weblogic you can still have access to the SolXAConnectionFactory object