use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.
the class RMManagerTest method testInitialisation.
@Test
public void testInitialisation() {
manager = new RMManager();
assertNull("sourcePolicy is set.", manager.getSourcePolicy());
assertNull("destinationPolicy is set.", manager.getDestinationPolicy());
manager.initialise();
RMConfiguration cfg = manager.getConfiguration();
assertNotNull("RMConfiguration is not set.", cfg);
assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
assertNotNull("deliveryAssirance is not set.", cfg.getDeliveryAssurance());
assertTrue(cfg.isExponentialBackoff());
assertEquals(3000L, cfg.getBaseRetransmissionInterval().longValue());
assertNull(cfg.getAcknowledgementInterval());
assertNull(cfg.getInactivityTimeout());
SourcePolicyType sp = manager.getSourcePolicy();
assertEquals(0L, sp.getSequenceExpiration().getTimeInMillis(new Date()));
assertEquals(0L, sp.getOfferedSequenceExpiration().getTimeInMillis(new Date()));
assertNull(sp.getAcksTo());
assertTrue(sp.isIncludeOffer());
SequenceTerminationPolicyType stp = sp.getSequenceTerminationPolicy();
assertEquals(0, stp.getMaxRanges());
assertEquals(0, stp.getMaxUnacknowledged());
assertTrue(stp.isTerminateOnShutdown());
assertEquals(0, stp.getMaxLength());
DestinationPolicyType dp = manager.getDestinationPolicy();
assertNotNull(dp.getAcksPolicy());
assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(), 10);
}
use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.
the class RMEndpoint method shutdown.
void shutdown() {
for (DestinationSequence ds : getDestination().getAllSequences()) {
ds.cancelDeferredAcknowledgments();
ds.cancelTermination();
}
// try terminating sequences
SourcePolicyType sp = manager.getSourcePolicy();
SequenceTerminationPolicyType stp = null;
if (null != sp) {
stp = sp.getSequenceTerminationPolicy();
}
if (null != stp && stp.isTerminateOnShutdown()) {
Collection<SourceSequence> seqs = source.getAllUnacknowledgedSequences();
LOG.log(Level.FINE, "Trying to terminate {0} sequences", seqs.size());
for (SourceSequence seq : seqs) {
try {
// sequence acknowledgement
if (seq.isLastMessage()) {
// REVISIT: this may be non-standard
// getProxy().ackRequested(seq);
} else {
getProxy().lastMessage(seq);
}
} catch (RMException ex) {
// already logged
}
}
}
for (SourceSequence ss : getSource().getAllSequences()) {
manager.getRetransmissionQueue().stop(ss);
}
for (DestinationSequence ds : getDestination().getAllSequences()) {
manager.getRedeliveryQueue().stop(ds);
}
// unregistering of this managed bean from the server is done by the bus itself
}
use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.
the class RMOutInterceptor method addAckRequest.
/**
* Add AcknowledgementRequested to message if needed. The AckRequest mode set either in the message
* properties or in the source policy is used to determine whether AcknowledgementRequested is always
* added, never added, or added only when we're waiting for the acknowledgement to a previously-sent
* message.
*
* @param msg
* @param rmpsIn
* @param seq
* @param sequence
*/
protected void addAckRequest(Message msg, RMProperties rmpsIn, SourceSequence seq, SequenceType sequence) {
AckRequestModeType mode = (AckRequestModeType) msg.get(RMMessageConstants.ACK_REQUEST_MODE);
if (mode == null) {
mode = AckRequestModeType.PENDING;
SourcePolicyType policy = getManager().getSourcePolicy();
if (policy.isSetAckRequestMode()) {
mode = policy.getAckRequestMode();
}
}
if (AckRequestModeType.ALWAYS == mode || (mode == AckRequestModeType.PENDING && seq.needAcknowledge(rmpsIn.getMessageNumber()))) {
Collection<AckRequestedType> reqs = rmpsIn.getAcksRequested();
if (reqs == null) {
reqs = new ArrayList<>();
}
Identifier identifier = new Identifier();
identifier.setValue(sequence.getIdentifier().getValue());
AckRequestedType ackRequest = new AckRequestedType();
ackRequest.setIdentifier(identifier);
reqs.add(ackRequest);
rmpsIn.setAcksRequested(reqs);
}
}
use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.
the class RetransmissionQueueImplTest method setupRetryPolicy.
private void setupRetryPolicy(Message message) {
SourcePolicyType spt = control.createMock(SourcePolicyType.class);
EasyMock.expect(manager.getSourcePolicy()).andReturn(spt).anyTimes();
RetryPolicyType rpt = control.createMock(RetryPolicyType.class);
EasyMock.expect(spt.getRetryPolicy()).andReturn(rpt);
EasyMock.expect(rpt.getMaxRetries()).andReturn(3);
}
use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.
the class Proxy method createSequence.
public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
this.sequenceContext = context;
SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
CreateSequenceType create = new CreateSequenceType();
String address = sp.getAcksTo();
EndpointReferenceType acksTo = null;
if (null != address) {
acksTo = RMUtils.createReference(address);
} else {
acksTo = defaultAcksTo;
}
create.setAcksTo(acksTo);
Duration d = sp.getSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
create.setExpires(expires);
}
if (sp.isIncludeOffer()) {
OfferType offer = new OfferType();
d = sp.getOfferedSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
offer.setExpires(expires);
}
offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
offer.setEndpoint(acksTo);
create.setOffer(offer);
setOfferedIdentifier(offer);
}
InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
EncoderDecoder codec = protocol.getCodec();
RMConstants constants = codec.getConstants();
final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
final Object send = codec.convertToSend(create);
if (isServer) {
LOG.fine("sending CreateSequenceRequest from server side");
Runnable r = new Runnable() {
public void run() {
try {
invoke(oi, protocol, new Object[] { send }, null, exchange);
} catch (RMException ex) {
// already logged
}
}
};
Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
if (ex == null) {
ex = SynchronousExecutor.getInstance();
}
ex.execute(r);
return null;
}
Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
return codec.convertReceivedCreateSequenceResponse(resp);
}
Aggregations