Our currently implemented JCA TCP/IP adapter needs to be re-evaluated and a new but important requirement got passed to me by project leads.
It is required to add new TCP connections and start them without restarting the server. ( Additionally modifying existing ones ) Currently it is only possible with adding a new property to the standalone.xml and this requires a restart/reload of the server.
I'm looking at a lot of blog posts and "tutorials" of implementing JCA with MDB's and I think I get the hang of it but I don't see a way to dynamically, and preferrably by code, create new connections.
I thought for a second I can use the ActivationSpec in combination with the ResourceAdapter class but I can't find out how that would be possible.
EDIT: Our Resource Adapter is by all means implemented very incorrectly but I would still declare it as bidirectional. It can either listen for connections or open a connection and also receive and send messages.
The resource adapter is added to the wildfly modules system as an unzipped .rar with an module.xml inside of
C:\wildfly-10.0.0.Final\modules\com\company\server\TcpConnectorServerModule\5.1.0.0
Content of module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.company.server.TcpConnectorServerModule"
slot="5.1.0.0">
<resources>
<resource-root path="." />
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.resource.api"/>
</dependencies>
</module>
Content in standalone.xml:
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<global-modules>
<module name="org.infinispan.cdi.embedded" slot="ispn-8.2"/>
<module name="org.jgroups" slot="ispn-8.2"/>
<module name="com.company.server.TcpConnectorServerModule" slot="5.1.0.0" meta-inf="true"/>
</global-modules>
TL;DR:
Is it possible to design an JCA Resource adapter in a way to dynamically (and hopefully by code) create and modify connections without restarting the server?
If it is not possible without restarting in JCA, I would appreciate alternatives to enable TCP/IP connections in Wildfly to external devices ( printers, scanners, scales and much more ). We need to be able to interact with these devices in our business logic.
I found out that while it isn't possible with CLI to add a new connection, since I could only restart the whole server and not subsystems, it is possible with JMX.
I can add new connections with JMX and "restart" the subsystem via the operation "activate". The operation acts like a restart, if the subsystem is already active.
Afterwards I can get the new connection just like before with the
InitialConext.listBindings()
function in my application.Here is an example JMX script with Groovy: