use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class RetransmissionQueueImpl method cacheUnacknowledged.
/**
* Accepts a new resend candidate.
*
* @param message the message object.
* @return ResendCandidate
*/
protected ResendCandidate cacheUnacknowledged(Message message) {
RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
SequenceType st = rmps.getSequence();
Identifier sid = st.getIdentifier();
String key = sid.getValue();
final ResendCandidate candidate;
synchronized (this) {
List<ResendCandidate> sequenceCandidates = getSequenceCandidates(key);
if (null == sequenceCandidates) {
sequenceCandidates = new ArrayList<>();
candidates.put(key, sequenceCandidates);
}
candidate = createResendCandidate(message);
if (isSequenceSuspended(key)) {
candidate.suspend();
}
sequenceCandidates.add(candidate);
unacknowledgedCount++;
}
LOG.fine("Cached unacknowledged message.");
try {
RMEndpoint rme = manager.getReliableEndpoint(message);
rme.handleAccept(key, st.getMessageNumber(), message);
} catch (RMException e) {
LOG.log(Level.WARNING, "Could not find reliable endpoint for message");
}
return candidate;
}
use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class RedeliveryQueueImpl method cacheUndelivered.
/**
* Accepts a new resend candidate.
*
* @param message the message.
* @return ResendCandidate
*/
protected RedeliverCandidate cacheUndelivered(Message message) {
RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
SequenceType st = rmps.getSequence();
Identifier sid = st.getIdentifier();
String key = sid.getValue();
RedeliverCandidate candidate;
synchronized (this) {
List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
if (null == sequenceCandidates) {
sequenceCandidates = new ArrayList<>();
candidates.put(key, sequenceCandidates);
}
candidate = getRedeliverCandidate(st, sequenceCandidates);
if (candidate == null) {
candidate = new RedeliverCandidate(message);
if (isSequenceSuspended(key)) {
candidate.suspend();
}
sequenceCandidates.add(candidate);
undeliveredCount++;
}
}
LOG.fine("Cached undelivered message.");
return candidate;
}
use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class RedeliveryQueueImpl method purgeDelivered.
protected void purgeDelivered(RedeliverCandidate candidate) {
RMProperties rmps = RMContextUtils.retrieveRMProperties(candidate.getMessage(), false);
SequenceType st = rmps.getSequence();
Identifier sid = st.getIdentifier();
String key = sid.getValue();
synchronized (this) {
List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
if (null != sequenceCandidates) {
// TODO use a constant op instead of this inefficient linear op
sequenceCandidates.remove(candidate);
undeliveredCount--;
}
if (sequenceCandidates.isEmpty()) {
candidates.remove(sid.getValue());
}
}
LOG.fine("Purged delivered message.");
}
use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class RMEndpointTest method testShutdown.
@Test
public void testShutdown() {
DestinationSequence ds = control.createMock(DestinationSequence.class);
Identifier did = control.createMock(Identifier.class);
EasyMock.expect(ds.getIdentifier()).andReturn(did).anyTimes();
EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
String d = "d";
EasyMock.expect(did.getValue()).andReturn(d).anyTimes();
SourceSequence ss = control.createMock(SourceSequence.class);
Identifier sid = control.createMock(Identifier.class);
EasyMock.expect(ss.getIdentifier()).andReturn(sid).anyTimes();
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
String s = "s";
EasyMock.expect(sid.getValue()).andReturn(s).anyTimes();
ds.cancelDeferredAcknowledgments();
EasyMock.expectLastCall().anyTimes();
ds.cancelTermination();
EasyMock.expectLastCall().anyTimes();
RetransmissionQueue queue = control.createMock(RetransmissionQueue.class);
EasyMock.expect(manager.getRetransmissionQueue()).andReturn(queue).anyTimes();
queue.stop(ss);
EasyMock.expectLastCall().anyTimes();
RedeliveryQueue dqueue = control.createMock(RedeliveryQueue.class);
EasyMock.expect(manager.getRedeliveryQueue()).andReturn(dqueue).anyTimes();
dqueue.stop(ds);
EasyMock.expectLastCall().anyTimes();
control.replay();
rme.getDestination().addSequence(ds, false);
rme.getSource().addSequence(ss, false);
rme.shutdown();
}
use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class RMOutInterceptorTest method testHandleApplicationMessage.
@Test
public void testHandleApplicationMessage() throws NoSuchMethodException, SequenceFault, RMException {
AddressingProperties maps = createMAPs("greetMe", "localhost:9000/GreeterPort", org.apache.cxf.ws.addressing.Names.WSA_NONE_ADDRESS);
Method[] mocked = new Method[] { AbstractRMInterceptor.class.getDeclaredMethod("getManager", new Class[] {}), RMOutInterceptor.class.getDeclaredMethod("isRuntimeFault", new Class[] { Message.class }), RMOutInterceptor.class.getDeclaredMethod("addAcknowledgements", new Class[] { Destination.class, RMProperties.class, Identifier.class, AttributedURIType.class }) };
RMOutInterceptor interceptor = EasyMock.createMockBuilder(RMOutInterceptor.class).addMockedMethods(mocked).createMock(control);
RMManager manager = control.createMock(RMManager.class);
EasyMock.expect(interceptor.getManager()).andReturn(manager).anyTimes();
Message message = control.createMock(Message.class);
EasyMock.expect(interceptor.isRuntimeFault(message)).andReturn(false).anyTimes();
Exchange ex = control.createMock(Exchange.class);
EasyMock.expect(message.getExchange()).andReturn(ex).anyTimes();
EasyMock.expect(ex.getOutMessage()).andReturn(message).anyTimes();
EasyMock.expect(ex.put("defer.uncorrelated.message.abort", Boolean.TRUE)).andReturn(null).anyTimes();
EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND)).andReturn(maps).anyTimes();
RMProperties rmpsOut = new RMProperties();
EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).andReturn(rmpsOut).anyTimes();
InterceptorChain chain = control.createMock(InterceptorChain.class);
EasyMock.expect(message.getInterceptorChain()).andReturn(chain).anyTimes();
EasyMock.expectLastCall();
RMEndpoint rme = control.createMock(RMEndpoint.class);
RMConfiguration config = new RMConfiguration();
config.setRMNamespace(RM10Constants.NAMESPACE_URI);
config.setRM10AddressingNamespace(Names200408.WSA_NAMESPACE_NAME);
EasyMock.expect(rme.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(config).anyTimes();
Source source = control.createMock(Source.class);
EasyMock.expect(source.getReliableEndpoint()).andReturn(rme).anyTimes();
EasyMock.expect(manager.getSource(message)).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(manager.getDestination(message)).andReturn(destination).anyTimes();
SourceSequence sseq = control.createMock(SourceSequence.class);
EasyMock.expect(sseq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(manager.getSequence((Identifier) EasyMock.isNull(), EasyMock.same(message), EasyMock.same(maps))).andReturn(sseq).anyTimes();
EasyMock.expect(sseq.nextMessageNumber((Identifier) EasyMock.isNull(), (Long) EasyMock.eq(0L), EasyMock.eq(false))).andReturn(Long.valueOf(10)).anyTimes();
EasyMock.expect(sseq.isLastMessage()).andReturn(false).anyTimes();
interceptor.addAcknowledgements(EasyMock.same(destination), EasyMock.same(rmpsOut), (Identifier) EasyMock.isNull(), EasyMock.isA(AttributedURIType.class));
EasyMock.expectLastCall();
Identifier sid = control.createMock(Identifier.class);
EasyMock.expect(sseq.getIdentifier()).andReturn(sid).anyTimes();
EasyMock.expect(sseq.getCurrentMessageNr()).andReturn(Long.valueOf(10)).anyTimes();
control.replay();
interceptor.handle(message);
control.verify();
}
Aggregations