//"-dispatch/connection/plugin/socket/localPort", "8888"
};
glob.init(args);
*/
ConnectQos connectQos = new ConnectQos(glob);
ClientQueueProperty prop = new ClientQueueProperty(glob, null);
prop.setMaxEntries(10000); // Client side queue up to 10000 entries if not connected
Address address = new Address(glob);
address.setDelay(4000L); // retry connecting every 4 sec
address.setRetries(-1); // -1 == forever
address.setPingInterval(2000L); // ping every 2 sec
// Example how to hardcode a XmlRpc server:
//address.setType("XMLRPC"); // force XmlRpc protocol
//address.setRawAddress("http://noty:9456/"); // Address to find the server
// Example how to hardcode a SOCKET server:
//address.setType("SOCKET"); // force SOCKET protocol
//address.setRawAddress("socket://noty:9988"); // Address to find the server
prop.setAddress(address);
connectQos.addClientQueueProperty(prop);
CallbackAddress cbAddress = new CallbackAddress(glob);
cbAddress.setDelay(4000L); // retry connecting every 4 sec
cbAddress.setRetries(-1); // -1 == forever
cbAddress.setPingInterval(4000L); // ping every 4 seconds
//cbAddress.setDispatcherActive(false);
// Example how to hardcode a SOCKET server:
//cbAddress.setType("SOCKET"); // force SOCKET protocol for callback
connectQos.addCallbackAddress(cbAddress);
// We want to be notified about connection states:
con.registerConnectionListener(new I_ConnectionStateListener() {
public void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
conRetQos = connection.getConnectReturnQos();
log.info("I_ConnectionStateListener: We were lucky, connected to " + glob.getId() + " as " + conRetQos.getSessionName());
// we can access the queue via connectionHandler and for example erase the entries ...
}
public void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
log.warning("I_ConnectionStateListener: No connection to " + glob.getId() + ", we are polling ...");
}
public void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
log.warning("I_ConnectionStateListener: Connection to " + glob.getId() + " is DEAD -> Good bye");
System.exit(1);
}
public void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
}
});
// We connect to xmlBlaster and register the callback handle:
this.conRetQos = con.connect(connectQos, new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
if (log.isLoggable(Level.FINEST)) log.finest("UpdateKey.toString()=" + updateKey.toString());
if (updateKey.isInternal()) {
log.severe("Receiving unexpected asynchronous internal message '" + updateKey.getOid() +
"' in default handler");
return "";
}
if (updateQos.isErased()) {
log.info("Message '" + updateKey.getOid() + "' is erased");
return "";
}
if (updateKey.getOid().equals("Banking"))
log.info("Receiving asynchronous message '" + updateKey.getOid() +
"' state=" + updateQos.getState() + " in default handler");
else
log.severe("Receiving unexpected asynchronous message '" + updateKey.getOid() +
"' in default handler");
return "";
}
}); // Login to xmlBlaster, default handler for updates
if (con.isAlive())
log.info("Connected as " + connectQos.getUserId() + " to xmlBlaster: " + this.conRetQos.getSessionName());
else
log.info("Not connected to xmlBlaster, proceeding in fail save mode ...");
SubscribeKey sk = new SubscribeKey(glob, "Banking");