Pooled Connection Factories and Remote HornetQ servers
vlari Sep 19, 2011 2:07 AMHi all,
I am trying to post to a remote (standalone) HornetQ (2.2.7) server from an app running in AS 7.0.1 (standalone-preview).
Here is the code:
{code}
@Resource(mappedName="java:/JmsXA")
private QueueConnectionFactory qcf;
public void send(String message) throws Exception {
QueueConnection queueCon = null;
try {
queueCon = this.qcf.createQueueConnection("guest","guest");
QueueSession queueSession = queueCon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = new HornetQQueue("magicQueue");
QueueSender sender = queueSession.createSender(queue);
Message msg = queueSession.createTextMessage(message);
sender.send(msg);
} finally {
if (queueCon != null) {
queueCon.close();
}
}
}
{code}
This code works fine on Glassfish - therefore, I know that the HQ server is properly configured and that the HQ Resource Adapter works fine.
My question is how should I wire the pooled connection factory in standalone-preview.xml?
Here is what I've done:
1) Create a Netty connector configured to talk to the remote HQ server:
{code:xml}
<connectors>
[...]
<netty-connector name="netty-remote" socket-binding="messaging">
<!-- host/port of the remote HQ server -->
<param key="host" value="192.168.0.3"/>
<param key="port" value="8000"/>
</netty-connector>
[...]
</connectors>
{code}
2) inject it in a pooled connection factory:
{code:xml}
<pooled-connection-factory name="hornetq-ra">
<connectors>
<connector-ref connector-name="netty-remote"/>
</connectors>
<entries>
<entry name="java:/JmsXA"/>
</entries>
<transaction mode="xa"/>
</pooled-connection-factory>
{code}
The problem is that the connection the factory creates is the embedded HQ server (localhost), not to the remote one (192.168.0.3).
Obviously, specifying the port and host on <netty-connector> has no effect.
So, I tried to use the socket bindings. I defined:
{code:xml}
<interface name="remoteHQ">
<inet-address value="192.168.0.3"/>
</interface>
<socket-binding-group name="standard-sockets" default-interface="public">
[...]
<socket-binding name="messagingRemote" port="8000" interface="remoteHQ"/>
[...]
</socket-binding-group>
{code}
And I use this binding in to configure the netty connector:
{code:xml}<netty-connector name="netty-remote" socket-binding="messagingRemote"/>{code}
which produces this exception:
{code}
MSC00001: Failed to start service jboss.network.remoteHQ: org.jboss.msc.service.StartException in service jboss.network.remoteHQ: failed to resolve interface remoteHQ
at org.jboss.as.server.services.net.NetworkInterfaceService.start(NetworkInterfaceService.java:96)
{code}
Suggestions would be greatly apreciated.
Thanks,
vlari.