-
1. Re: Wildfly 12 - Problem invoking subsequent (A->B->C) remote EJBs (server-to-server) in the same transaction. With a new transaction works.
andey Apr 26, 2018 6:50 AM (in response to dbdbdb)1 of 1 people found this helpfulThere are two possible scenarios.
1.the client invokes an EJB in two different JBoss servers (or JEE servers from different vendors);
2.the client invokes an EJB in a JBoss server and also performs some local work;
In cases 1 and 2 where the client wishes to enlist other servers or local resources with the transaction
These Scenario is supported by the JBoss application server but requires a distributed transaction manager (TM). JBossTS is the default TM supported by the AS and comes in two flavors: JTA only (which is the default TM shipped with the AS); and a JTS version
-
2. Re: Wildfly 12 - Problem invoking subsequent (A->B->C) remote EJBs (server-to-server) in the same transaction. With a new transaction works.
dbdbdb Apr 27, 2018 3:12 AM (in response to andey)Thank you for your response, andey !
Our apps already use distributed transaction through JTA and works fine.
The problem we are facing now is to perform two remote EJB invocations targeting different servers in the same distributed transaction.
Once the app performs the first remote ejb call, it seems it is "caching" this target server and at the second ejb call to other server, Wildfly tries to lookup this second ejb but targeting at the first server, which is wrong. It should targeting at the second server as declared in remote-ejb-receiver.
But, if I change the code in order to create a new transaction before the second call, Wildfly correctly targeting the second server.
The problem is that I can't change all the remote invocations to REQUIRES_NEW because I don't want to lose the atomicity of the whole transaction.
Am I missing something?
Thanks!
-
3. Re: Wildfly 12 - Problem invoking subsequent (A->B->C) remote EJBs (server-to-server) in the same transaction. With a new transaction works.
dbdbdb Apr 27, 2018 6:19 PM (in response to andey)Follow the code and configurations:
jboss-ejb-client.xml (inside WEB-INF directory):
<?xml version="1.0" encoding="UTF-8"?> <jboss-ejb-client xmlns="urn:jboss:ejb-client:1.3"> <client-context> <profile name="profile-my-app" /> </client-context> </jboss-ejb-client>
domain.xml:
<subsystem xmlns="urn:jboss:domain:ejb3:5.0"> ... ... <remote connector-ref="http-remoting-connector" thread-pool-name="default"> <channel-creation-options> <option name="READ_TIMEOUT" value="${prop.remoting-connector.read.timeout:20}" type="xnio"/> <option name="MAX_OUTBOUND_MESSAGES" value="1234" type="remoting"/> </channel-creation-options> <profiles> <profile name="profile-my-app"> <remoting-ejb-receiver name="rer-i-1" outbound-connection-ref="other-app-outbound-connection-1"/> <remoting-ejb-receiver name="rer-i-2" outbound-connection-ref="other-app-outbound-connection-2"/> </profile> </profiles> ... </remote> ... </subsystem> ... ... <subsystem xmlns="urn:jboss:domain:remoting:4.0"> <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm" sasl-authentication-factory="application-sasl-authentication"/> <outbound-connections> <remote-outbound-connection name="other-app-outbound-connection-1" outbound-socket-binding-ref="other-app-outbound-1" authentication-context="ejb-outbound-context"/> <remote-outbound-connection name="other-app-outbound-connection-2" outbound-socket-binding-ref="other-app-outbound-2" authentication-context="ejb-outbound-context"/> </outbound-connections> </subsystem> ... ... <socket-binding-group name="consensus-full-ha-sockets" default-interface="public"> ... ... <outbound-socket-binding name="my-app-outbound-1"> <remote-destination host="10.0.108.184" port="8080"/> </outbound-socket-binding> <outbound-socket-binding name="my-app-outbound-2"> <remote-destination host="10.0.108.102" port="8080"/> </outbound-socket-binding> </socket-binding-group>
wildfly-config.xml (the servers startup with "wildfly.config.url" system property pointing to this config file):
<configuration> <authentication-client xmlns="urn:elytron:1.0"> <authentication-rules> <rule use-configuration="default"/> </authentication-rules> <authentication-configurations> <configuration name="default"> <set-user-name name="ejb"/> <credentials> <clear-password password="ejbejb"/> </credentials> <sasl-mechanism-selector selector="DIGEST-MD5"/> <providers> <use-service-loader /> </providers> </configuration> </authentication-configurations> </authentication-client> </configuration>
Code (inject, lookups and invocations):
@Produces public ParameterRemote produceParameter() throws Exception { ParameterRemote remote = (ParameterRemote) new InitialContext().lookup("ejb:/oneApp/ParameterBean!com.mycompany.client.service.interfaces.ParameterRemote"); return remote; } @Produces public IndexerRemote produceIndex() throws Exception { IndexerRemote remote = (IndexerRemote) new InitialContext().lookup("ejb:/secondApp/IndexerBean!com.mycompany.client.service.interfaces.IndexerRemote"); return remote; } @Stateless public class SomeBusinessObject { //App-1 @Inject private IndexerRemote indexerRemote; public void performIndex() { ... ... indexerRemote.performIndex(); //this works fine. Wildfly corretly lookup the first server } } //Deployed at server 1 @Stateless public class IndexerBean implements IndexerRemote { //IndexerRemote has the @Remote annotation (App-2) @Inject private ParameterRemote parametersRemote; //deployed at server 2 (App-3) public void performIndex() { ... ... Parameter parameter = parameterRemote.getParameter(group, key); //this fails. Wildfly tris to lookup the parameterRemote targeting the first server again but this EJB is in other server } }
Thanks