jboss - Wildfly to Wildfly EJB client without remote-outbound-connections -
i'd able have 2 wildfly (or jboss 7) instances 1 of servers talks ejbs on other server. tricky part according documentation, remote-outbound-connections outbound-socket-bindings need created. big hassle our operations team, when want scale out.
is there way wildfly instance call ejb's on wildfly instance programmatically specifying remote host?
i've been able have tomcat 7 invoke wildfly ejb's. added maven dependency on org.jboss.as:jboss-as-ejb-client-bom:7.5.0.final-redhat-21 , set connection settings according this documentation.
thanks!
edit
when try same code worked in tomcat 7 (which uses jboss-ejb-client library), error ejbclient000021: ejb client context selector may not changed
when code tries ejbclientcontext.setselector( selector )
. setting remote connection host , port programmatically instead of using jboss-ejb-client.properties.
jgitter's answer got me of way there. here's ended with:
/** * @return reference ejb * @throws ejblookupexception */ @notnull public t lookup () throws ejblookupexception { string path = createjndipath(); context initialcontext = null; try { initialcontext = createinitialcontext(); //noinspection unchecked final t ejb = (t)initialcontext.lookup( path ); if( m_apiversion != null ) { ( (remoteapi)ejb ).validateclientcompatibility( m_apiversion ); } return ejb; } catch( namingexception | runtimeexception e ) { throw new ejblookupexception( "unable find jboss ejb @ " + path, e ); } { if( initialcontext != null ) { //noinspection throwableresultofmethodcallignored closer.close( initialcontext ); } } } /** * there lot of ways jboss 7 / wildfly ejb lookups. using method, don't have create * outbound socket bindings whenever want use remote ejb. * * @throws namingexception */ @notnull private context createinitialcontext () throws namingexception { properties properties = new properties(); properties.put( context.url_pkg_prefixes, "org.jboss.ejb.client.naming" ); properties.put( "org.jboss.ejb.client.scoped.context", "true" ); properties.put( "remote.connectionprovider.create.options.org.xnio.options.ssl_enabled", "false" ); properties.put( "remote.connection.default.connect.options.org.xnio.options.sasl_policy_noanonymous", "false" ); properties.put( "remote.connections", "default" ); properties.put( "remote.connection.default.host", m_host ); properties.put( "remote.connection.default.port", string.valueof( m_port ) ); if( m_username != null ) { properties.put( "remote.connection.default.username", m_username ); } if( m_password != null ) { properties.put( "remote.connection.default.password", m_password ); } return new initialcontext( properties ); } public static class ejblookupexception extends exception { ejblookupexception ( @notnull string message, @notnull throwable cause ) { super( message, cause ); } }
i'm not sure if need scoped context, , may not closing connection properly. i'll update answer based on find out.
Comments
Post a Comment