use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RMTxStore method getSourceSequence.
public SourceSequence getSourceSequence(Identifier sid) {
if (LOG.isLoggable(Level.FINE)) {
LOG.info("Getting source sequences for id: " + sid);
}
Connection con = verifyConnection();
PreparedStatement stmt = null;
SQLException conex = null;
ResultSet res = null;
try {
stmt = getStatement(con, SELECT_SRC_SEQUENCE_STMT_STR);
stmt.setString(1, sid.getValue());
res = stmt.executeQuery();
if (res.next()) {
long cmn = res.getLong(1);
boolean lm = res.getBoolean(2);
long lval = res.getLong(3);
Date expiry = 0 == lval ? null : new Date(lval);
String oidValue = res.getString(4);
Identifier oi = null;
if (null != oidValue) {
oi = RMUtils.getWSRMFactory().createIdentifier();
oi.setValue(oidValue);
}
ProtocolVariation pv = decodeProtocolVersion(res.getString(5));
return new SourceSequence(sid, expiry, oi, cmn, lm, pv);
}
} catch (SQLException ex) {
conex = ex;
// ignore
LOG.log(Level.WARNING, new Message("SELECT_SRC_SEQ_FAILED_MSG", LOG).toString(), ex);
} finally {
releaseResources(stmt, res);
updateConnectionState(con, conex);
}
return null;
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class RMTxStore method getSourceSequences.
public Collection<SourceSequence> getSourceSequences(String endpointIdentifier) {
if (LOG.isLoggable(Level.FINE)) {
LOG.info("Getting source sequences for endpoint: " + endpointIdentifier);
}
Connection con = verifyConnection();
PreparedStatement stmt = null;
SQLException conex = null;
Collection<SourceSequence> seqs = new ArrayList<>();
ResultSet res = null;
try {
stmt = getStatement(con, SELECT_SRC_SEQUENCES_STMT_STR);
stmt.setString(1, endpointIdentifier);
res = stmt.executeQuery();
while (res.next()) {
Identifier sid = new Identifier();
sid.setValue(res.getString(1));
long cmn = res.getLong(2);
boolean lm = res.getBoolean(3);
long lval = res.getLong(4);
Date expiry = 0 == lval ? null : new Date(lval);
String oidValue = res.getString(5);
Identifier oi = null;
if (null != oidValue) {
oi = new Identifier();
oi.setValue(oidValue);
}
ProtocolVariation pv = decodeProtocolVersion(res.getString(6));
SourceSequence seq = new SourceSequence(sid, expiry, oi, cmn, lm, pv);
seqs.add(seq);
}
} catch (SQLException ex) {
conex = ex;
// ignore
LOG.log(Level.WARNING, new Message("SELECT_SRC_SEQ_FAILED_MSG", LOG).toString(), ex);
} finally {
releaseResources(stmt, res);
updateConnectionState(con, conex);
}
return seqs;
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class AbstractClientPersistenceTest method verifyRecovery.
void verifyRecovery() throws Exception {
RMManager manager = bus.getExtension(RMManager.class);
assertNotNull(manager);
RMStore store = manager.getStore();
assertNotNull(store);
Client client = ClientProxy.getClient(greeter);
String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
Collection<DestinationSequence> dss = store.getDestinationSequences(id);
assertEquals(1, dss.size());
Collection<SourceSequence> sss = store.getSourceSequences(id);
assertEquals(1, sss.size());
int i = 0;
while (store.getMessages(sss.iterator().next().getIdentifier(), true).size() > 0 && i < 10) {
Thread.sleep(200);
i++;
}
assertEquals(0, store.getMessages(sss.iterator().next().getIdentifier(), true).size());
assertEquals(0, store.getMessages(sss.iterator().next().getIdentifier(), false).size());
}
use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.
the class AbstractClientPersistenceTest method verifyStorePopulation.
void verifyStorePopulation() {
RMManager manager = bus.getExtension(RMManager.class);
assertNotNull(manager);
RMStore store = manager.getStore();
assertNotNull(store);
Client client = ClientProxy.getClient(greeter);
String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
Collection<DestinationSequence> dss = store.getDestinationSequences(id);
assertEquals(1, dss.size());
Collection<SourceSequence> sss = store.getSourceSequences(id);
assertEquals(1, sss.size());
Collection<RMMessage> msgs = store.getMessages(sss.iterator().next().getIdentifier(), true);
assertEquals(2, msgs.size());
msgs = store.getMessages(sss.iterator().next().getIdentifier(), false);
assertEquals(0, msgs.size());
}
Aggregations