public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); Connection con = connectionRepository.findOneByConnectionURIForUpdate(wonMessage.getSenderURI()); logger.debug("HINT_FEEDBACK received from the owner side for connection {}", wonMessage.getSenderURI()); processFeedbackMessage(con, wonMessage); }
@Override public URI getConnectionURI() { return getWonMessage().getSenderURI(); }
@Override public boolean matches(Exchange exchange) { WonMessage message = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.ORIGINAL_MESSAGE_HEADER); if (message == null) return false; if (message.getEnvelopeType() != WonMessageDirection.FROM_SYSTEM) return false; if (message.getSenderURI() != null) { return message.getSenderURI().equals(message.getReceiverURI()); } else { if (message.getSenderNeedURI() == null) return false; return message.getSenderNeedURI().equals(message.getReceiverNeedURI()); } } }
private static URI getParentUriFromSenderProperties(WonMessage message) { URI parentURI; parentURI = message.getSenderURI(); if (parentURI == null) { parentURI = message.getSenderNeedURI(); } if (parentURI == null) { parentURI = message.getSenderNodeURI(); } return parentURI; }
private void checkSenders(final WonNodeInfo senderNodeInfo, final WonMessage message) { checkNodeConformance(senderNodeInfo, message.getSenderNeedURI(), message.getSenderURI(), null); }
@Override public void onSuccessResponse(final Exchange exchange) throws Exception { WonMessage responseMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); MessageEventPlaceholder mep = this.messageEventRepository.findOneByCorrespondingRemoteMessageURI( responseMessage .getIsResponseToMessageURI()); //update the connection database: set the remote connection URI just obtained from the response Connection con = this.connectionRepository.findOneByConnectionURIForUpdate(mep.getSenderURI()); con.setRemoteConnectionURI(responseMessage.getSenderURI()); this.connectionRepository.save(con); }
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); logger.debug("CLOSE received from the owner side for connection {}", wonMessage.getSenderURI()); Connection con = connectionRepository.findOneByConnectionURIForUpdate(wonMessage.getSenderURI()); ConnectionState originalState = con.getState(); con = dataService.nextConnectionState(con, ConnectionEventType.OWNER_CLOSE); //if the connection was in suggested state, don't send a close message to the remote need if (originalState != ConnectionState.SUGGESTED) { //prepare the message to pass to the remote node //create the message to send to the remote node URI remoteMessageURI = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); OutboundMessageCreator outboundMessageCreator = new OutboundMessageCreator(remoteMessageURI); //put it into the 'outbound message' header (so the persister doesn't pick up the wrong one). message.setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageCreator); //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.SENDER_PROPERTY, con.getConnectionURI()); //add the information about the corresponding message to the local one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageURI); //the persister will pick it up later from the header } }
WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); logger.debug("OPEN received from the owner side for connection {}", wonMessage.getSenderURI()); Connection con = dataService.nextConnectionState(wonMessage.getSenderURI(), ConnectionEventType.OWNER_OPEN); Objects.requireNonNull(con); Objects.requireNonNull(con.getRemoteNeedURI()); if (!con.getConnectionURI().equals(wonMessage.getSenderURI())) throw new IllegalStateException("connection uri must be equal to sender uri"); if (wonMessage.getReceiverURI() != null) { if (!wonMessage.getReceiverURI().equals(con.getRemoteConnectionURI()))
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); logger.debug("CLOSE received from the system side for connection {}", wonMessage.getSenderURI()); Connection con = connectionRepository.findOneByConnectionURIForUpdate(wonMessage.getSenderURI()); ConnectionState originalState = con.getState(); //TODO: we could introduce SYSTEM_CLOSE here con = dataService.nextConnectionState(con, ConnectionEventType.OWNER_CLOSE); //if we know the remote connection, send a close message to the remote connection if (con.getRemoteConnectionURI() != null) { URI remoteNodeURI = wonNodeInformationService.getWonNodeUri(con.getRemoteConnectionURI()); URI remoteMessageUri = wonNodeInformationService.generateEventURI(remoteNodeURI); //put the factory into the outbound message factory header. It will be used to generate the outbound message //after the wonMessage has been processed and saved, to make sure that the outbound message contains //all the data that we also store locally OutboundMessageFactory outboundMessageFactory = new OutboundMessageFactory(remoteMessageUri, con); message.setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.SENDER_PROPERTY, con.getConnectionURI()); //add the information about the corresponding message to the local one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageUri); //the persister will pick it up later } //because the FromSystem message is now in the message header, it will be //picked up by the routing system and delivered to the owner. //the message for the remote connection is in the outbound message header and will be // sent to the remote connection. }
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionUri = wonMessage.getSenderURI(); if (connectionUri == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_PROPERTY.toString())); } Connection con = connectionRepository.findOneByConnectionURIForUpdate(connectionUri); if (con.getState() != ConnectionState.CONNECTED) { throw new IllegalMessageForConnectionStateException(connectionUri, "CONNECTION_MESSAGE", con.getState()); } URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); if (wonMessage.getReceiverURI() == null){ //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.RECEIVER_PROPERTY, con.getRemoteConnectionURI()); } //add the information about the remote message to the locally stored one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageUri); //the persister will pick it up later //put the factory into the outbound message factory header. It will be used to generate the outbound message //after the wonMessage has been processed and saved, to make sure that the outbound message contains //all the data that we also store locally OutboundMessageFactory outboundMessageFactory = new OutboundMessageFactory(remoteMessageUri, con); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionUri = wonMessage.getSenderURI(); if (connectionUri == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_PROPERTY.toString())); } Connection con = connectionRepository.findOneByConnectionURIForUpdate(connectionUri); if (con.getState() != ConnectionState.CONNECTED) { throw new IllegalMessageForConnectionStateException(connectionUri, "CONNECTION_MESSAGE", con.getState()); } URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); if (wonMessage.getReceiverURI() == null){ //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.RECEIVER_PROPERTY, con.getRemoteConnectionURI()); } //add the information about the remote message to the locally stored one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageUri); //the persister will pick it up later //put the factory into the outbound message factory header. It will be used to generate the outbound message //after the wonMessage has been processed and saved, to make sure that the outbound message contains //all the data that we also store locally OutboundMessageFactory outboundMessageFactory = new OutboundMessageFactory(remoteMessageUri, con); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
wonMessage.getSenderURI(), facet, ConnectionState.REQUEST_RECEIVED, ConnectionEventType.PARTNER_OPEN); if (con.getRemoteNeedURI() == null) throw new IllegalStateException("remote need uri must not be null"); if (!con.getRemoteNeedURI().equals(wonMessage.getSenderNeedURI())) throw new IllegalStateException("the remote need uri of the connection must be equal to the sender need uri of the message"); if (wonMessage.getSenderURI() == null) throw new IllegalStateException("the sender uri must not be null"); con.setRemoteConnectionURI(wonMessage.getSenderURI()); if (!con.getRemoteConnectionURI().equals(wonMessage.getSenderURI())) throw new IllegalStateException("the sender uri of the message must be equal to the remote connection uri"); con.setState(con.getState().transit(ConnectionEventType.PARTNER_OPEN)); connectionRepository.save(con);
public MessageEventPlaceholder(URI parentURI, WonMessage wonMessage, EventContainer eventContainer) { this.parentURI = parentURI; this.messageURI = wonMessage.getMessageURI(); this.messageType = wonMessage.getMessageType(); this.senderURI = wonMessage.getSenderURI(); this.senderNeedURI = wonMessage.getSenderNeedURI(); this.senderNodeURI = wonMessage.getSenderNodeURI(); this.receiverURI = wonMessage.getReceiverURI(); this.receiverNeedURI = wonMessage.getReceiverNeedURI(); this.receiverNodeURI = wonMessage.getReceiverNodeURI(); this.creationDate = new Date(); this.correspondingRemoteMessageURI = wonMessage.getCorrespondingRemoteMessageURI(); this.referencedByOtherMessage = false; this.innermostMessageURI = wonMessage.getInnermostMessageURI(); this.eventContainer = eventContainer; }
URI wonNodeUriFromWonMessage = wonMessage.getReceiverNodeURI(); URI remoteNeedUri = wonMessage.getSenderNeedURI(); URI remoteConnectionUri = wonMessage.getSenderURI(); URI facetURI = WonRdfUtils.FacetUtils.getFacet(wonMessage);
URI receiverNeedURI = wonMessage.getReceiverNeedURI(); URI facetURI = WonRdfUtils.FacetUtils.getFacet(wonMessage); URI connectionURI = wonMessage.getSenderURI(); //if the uri is known already, we can load the connection! Connection con = null; if (connectionURI != null) {
.setSenderNodeURI(originalMessage.getSenderNodeURI()) .setSenderNeedURI(originalMessage.getSenderNeedURI()) .setSenderURI(originalMessage.getSenderURI()); .setReceiverURI(originalMessage.getSenderURI()) .setIsResponseToMessageURI(originalMessage.getMessageURI()) .setIsResponseToMessageType(originalMessage.getMessageType())
/** * Copies the envelope properties from the specified message to this message. * * Note that this does not copy the original envelope graph, only the * standard envelope properties. * * @param wonMessage * @return */ public static WonMessageBuilder copyEnvelopeFromWonMessage(final WonMessage wonMessage) { WonMessageBuilder builder = new WonMessageBuilder(wonMessage.getMessageURI()) .setWonMessageType(wonMessage.getMessageType()) .setReceiverURI(wonMessage.getReceiverURI()) .setReceiverNeedURI(wonMessage.getReceiverNeedURI()) .setReceiverNodeURI(wonMessage.getReceiverNodeURI()) .setSenderURI(wonMessage.getSenderURI()) .setSenderNeedURI(wonMessage.getSenderNeedURI()) .setSenderNodeURI(wonMessage.getSenderNodeURI()); if (wonMessage.getIsResponseToMessageType() != null){ builder.setIsResponseToMessageType(wonMessage.getIsResponseToMessageType()); } if (wonMessage.getIsResponseToMessageURI() != null){ builder.setIsResponseToMessageURI(wonMessage.getIsResponseToMessageURI()); } if (wonMessage.getIsRemoteResponseToMessageURI() != null){ builder.setIsRemoteResponseToMessageURI(wonMessage.getIsRemoteResponseToMessageURI()); } return builder; }