use of org.apache.cxf.ws.rm.v200702.CloseSequenceType in project cxf by apache.
the class ServantTest method createTestCloseSequenceMessage.
private static Message createTestCloseSequenceMessage(String sidstr) {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(message);
message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
AddressingProperties maps = new AddressingProperties();
String msgId = "urn:uuid:12345-" + Math.random();
AttributedURIType id = ContextUtils.getAttributedURI(msgId);
maps.setMessageID(id);
maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
CloseSequenceType cs = new CloseSequenceType();
org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
sid.setValue(sidstr);
cs.setIdentifier(sid);
MessageContentsList contents = new MessageContentsList();
contents.add(cs);
message.setContent(List.class, contents);
RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);
return message;
}
use of org.apache.cxf.ws.rm.v200702.CloseSequenceType in project cxf by apache.
the class EncoderDecoder10AImpl method decodeSequenceTypeCloseSequence.
public CloseSequenceType decodeSequenceTypeCloseSequence(Element elem) throws JAXBException {
Unmarshaller unmarshaller = getContext().createUnmarshaller();
JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502wsa15.SequenceType.class);
org.apache.cxf.ws.rm.v200502wsa15.SequenceType seq = jaxbElement.getValue();
if (seq.isSetLastMessage()) {
CloseSequenceType close = new CloseSequenceType();
close.setIdentifier(VersionTransformer.convert(seq.getIdentifier()));
close.setLastMsgNumber(seq.getMessageNumber());
return close;
}
return null;
}
use of org.apache.cxf.ws.rm.v200702.CloseSequenceType in project cxf by apache.
the class EncoderDecoder10Impl method decodeSequenceTypeCloseSequence.
public CloseSequenceType decodeSequenceTypeCloseSequence(Element elem) throws JAXBException {
Unmarshaller unmarshaller = getContext().createUnmarshaller();
JAXBElement<org.apache.cxf.ws.rm.v200502.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502.SequenceType.class);
org.apache.cxf.ws.rm.v200502.SequenceType seq = jaxbElement.getValue();
if (seq.isSetLastMessage()) {
CloseSequenceType close = new CloseSequenceType();
close.setIdentifier(VersionTransformer.convert(seq.getIdentifier()));
close.setLastMsgNumber(seq.getMessageNumber());
return close;
}
return null;
}
use of org.apache.cxf.ws.rm.v200702.CloseSequenceType in project cxf by apache.
the class Proxy method lastMessage.
void lastMessage(SourceSequence s) throws RMException {
final ProtocolVariation protocol = s.getProtocol();
EndpointReferenceType target = s.getTarget();
AttributedURIType uri = null;
if (null != target) {
uri = target.getAddress();
}
String addr = null;
if (null != uri) {
addr = uri.getValue();
}
if (addr == null) {
LOG.log(Level.WARNING, "STANDALONE_CLOSE_SEQUENCE_NO_TARGET_MSG");
return;
}
if (RMUtils.getAddressingConstants().getAnonymousURI().equals(addr)) {
LOG.log(Level.WARNING, "STANDALONE_CLOSE_SEQUENCE_ANON_TARGET_MSG");
return;
}
RMConstants constants = protocol.getConstants();
OperationInfo oi = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface().getOperation(constants.getCloseSequenceOperationName());
// pass reference to source sequence in invocation context
Map<String, Object> context = new HashMap<>(Collections.singletonMap(SourceSequence.class.getName(), (Object) s));
context.put(FaultListener.class.getName(), new FaultListener() {
public boolean faultOccurred(Exception exception, String description, Message message) {
if (exception.getCause() instanceof IOException) {
// for close messages, the server may be gone and nothing we can do so don't pollute the logs
LOG.log(Level.WARNING, "Could not send CloseSequence message: " + exception.getCause().getMessage());
return false;
}
return true;
}
});
try {
if (constants instanceof RM11Constants) {
CloseSequenceType csr = new CloseSequenceType();
csr.setIdentifier(s.getIdentifier());
csr.setLastMsgNumber(s.getCurrentMessageNr());
invoke(oi, protocol, new Object[] { csr }, context, Level.FINER);
} else {
invoke(oi, protocol, new Object[] {}, context, Level.FINER);
}
} catch (Fault f) {
throw new RMException(f);
}
}
use of org.apache.cxf.ws.rm.v200702.CloseSequenceType in project cxf by apache.
the class RMManager method recoverSourceSequence.
private void recoverSourceSequence(Endpoint endpoint, Conduit conduit, Source s, SourceSequence ss) {
Collection<RMMessage> ms = store.getMessages(ss.getIdentifier(), true);
if (null == ms || 0 == ms.size()) {
store.removeSourceSequence(ss.getIdentifier());
return;
}
LOG.log(Level.FINE, "Number of messages in sequence: {0}", ms.size());
// only recover the sequence if there are pending messages
s.addSequence(ss, false);
// choosing an arbitrary valid source sequence as the current source sequence
if (s.getAssociatedSequence(null) == null && !ss.isExpired() && !ss.isLastMessage()) {
s.setCurrent(ss);
}
// make sure this is associated with the offering id
s.setCurrent(ss.getOfferingSequenceIdentifier(), ss);
for (RMMessage m : ms) {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.setOutMessage(message);
if (null != conduit) {
exchange.setConduit(conduit);
message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
}
exchange.put(Endpoint.class, endpoint);
exchange.put(Service.class, endpoint.getService());
exchange.put(Binding.class, endpoint.getBinding());
exchange.put(Bus.class, bus);
SequenceType st = new SequenceType();
st.setIdentifier(ss.getIdentifier());
st.setMessageNumber(m.getMessageNumber());
RMProperties rmps = new RMProperties();
rmps.setSequence(st);
rmps.setCreatedTime(m.getCreatedTime());
rmps.exposeAs(ss.getProtocol().getWSRMNamespace());
if (ss.isLastMessage() && ss.getCurrentMessageNr() == m.getMessageNumber()) {
CloseSequenceType close = new CloseSequenceType();
close.setIdentifier(ss.getIdentifier());
rmps.setCloseSequence(close);
}
RMContextUtils.storeRMProperties(message, rmps, true);
if (null == conduit) {
String to = m.getTo();
AddressingProperties maps = new AddressingProperties();
maps.setTo(RMUtils.createReference(to));
RMContextUtils.storeMAPs(maps, message, true, false);
}
try {
// RMMessage is stored in a serialized way, therefore
// RMMessage content must be splitted into soap root message
// and attachments
PersistenceUtils.decodeRMContent(m, message);
RMContextUtils.setProtocolVariation(message, ss.getProtocol());
retransmissionQueue.addUnacknowledged(message);
} catch (IOException e) {
LOG.log(Level.SEVERE, "Error reading persisted message data", e);
}
}
}
Aggregations