private void checkHasMyNode(final WonMessage message, URI ownNode) { if (!ownNode.equals(message.getSenderNodeURI()) && !ownNode.equals(message.getReceiverNodeURI())) { throw new UriNodePathException("neither sender nor receiver is " + ownNode); } }
@Override public void process(Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); //prepare the message to pass to the remote node URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); //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 //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); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
@Override public void process(Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); //prepare the message to pass to the remote node URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); //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 //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); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
private static URI getParentUriFromReceiverProperties(WonMessage message) { URI parentURI; parentURI = message.getReceiverURI(); if (parentURI == null) { parentURI = message.getReceiverNeedURI(); } if (parentURI == null) { parentURI = message.getReceiverNodeURI(); } return parentURI; }
@Override public void hint(URI needURI, URI otherNeed, double score, URI originator, Model content, WonMessage wonMessage) throws Exception { logger.info("need-facing: HINT called for needURI {} and otherNeed {} " + "with score {} from originator {}.", new Object[]{needURI, otherNeed, score, originator}); CamelConfiguration camelConfiguration = matcherProtocolCommunicationService.configureCamelEndpoint(wonMessage .getReceiverNodeURI(), startingEndpoint); String endpoint = camelConfiguration.getEndpoint(); Map<String, String> headerMap = new HashMap<>(); headerMap.put("needURI",needURI.toString()); headerMap.put("otherNeedURI", otherNeed.toString()); headerMap.put("score",String.valueOf(score)); headerMap.put("originator",originator.toString()); headerMap.put("content",RdfUtils.toString(content)); headerMap.put("remoteBrokerEndpoint", endpoint); headerMap.put("methodName","hint"); messagingService.sendInOnlyMessage(null, headerMap, WonMessageEncoder.encode(wonMessage, Lang.TRIG),startingEndpoint ); }
@Override public void process(Exchange exchange) throws Exception { logger.debug("processing message for sending to remote node"); WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); if (wonMessage.getSenderNeedURI() != null && wonMessage.getSenderNodeURI().equals(wonMessage.getReceiverNodeURI ())){ //sending locally, directly put message into the incoming need protocol messageService.sendInOnlyMessage(null, null, RdfUtils .writeDatasetToString(wonMessage.getCompleteDataset(), WonCamelConstants.RDF_LANGUAGE_FOR_MESSAGE), "activemq:queue:NeedProtocol.in"); return; } //add a camel endpoint for the remote won node needProtocolCommunicationService.configureCamelEndpoint(wonMessage.getReceiverNodeURI()); //send the message to that endpoint String ep = needProtocolCommunicationService.getProtocolCamelConfigurator().getEndpoint(wonMessage .getReceiverNodeURI()); //messageService.sendInOnlyMessage(null, null, wonMessage, wonMessage.getReceiverNodeURI().toString()); String msgBody = RdfUtils.writeDatasetToString(wonMessage.getCompleteDataset(), WonCamelConstants.RDF_LANGUAGE_FOR_MESSAGE); messageService.sendInOnlyMessage(null, null, msgBody, ep); }
private void checkDirection(final WonMessage message, final URI ownNode) { WonMessageDirection direction = message.getEnvelopeType(); URI receiverNode = message.getReceiverNodeURI(); URI senderNode = message.getSenderNodeURI(); URI node; switch (direction) { case FROM_EXTERNAL: // my node should be a receiver node if (!ownNode.equals(receiverNode)) { throw new UriNodePathException(receiverNode + " is expected to be " + ownNode); } break; case FROM_OWNER: // my node should be a sender node if (!ownNode.equals(senderNode)) { throw new UriNodePathException(senderNode + " is expected to be " + ownNode); } break; case FROM_SYSTEM: // my node should be a sender node if (!ownNode.equals(senderNode)) { throw new UriNodePathException(senderNode + " is expected to be " + ownNode); } break; } }
URI receiverNode = message.getReceiverNodeURI(); WonNodeInfo senderNodeInfo = null; WonNodeInfo receiverNodeInfo = null;
private WonMessage createMessageToSendToRemoteNode(WonMessage wonMessage, Connection con) { //create the message to send to the remote node return WonMessageBuilder .setPropertiesForPassingMessageToRemoteNode( wonMessage, wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI())) .setSenderURI(con.getConnectionURI()) .build(); }
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); }
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 } }
.generateEventURI(wonMessage.getReceiverNodeURI());
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; }
if (con == null) { URI connectionUri = wonNodeInformationService.generateConnectionURI(wonMessage.getReceiverNodeURI()); con = dataService.createConnection(connectionUri, wonMessage.getReceiverNeedURI(), wonMessage.getSenderNeedURI(), wonMessage.getSenderURI(), facet,
URI wonNodeUriFromWonMessage = wonMessage.getReceiverNodeURI(); URI remoteNeedUri = wonMessage.getSenderNeedURI(); URI remoteConnectionUri = wonMessage.getSenderURI();
.generateEventURI(wonMessage.getReceiverNodeURI());
equalsOrBothNull(processedMessage.getSenderNodeURI(), message.getSenderNodeURI()) && equalsOrBothNull(processedMessage.getReceiverNodeURI(), message.getReceiverNodeURI())
/** * 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; }
.setSenderNodeURI(originalMessage.getReceiverNodeURI()) .setSenderNeedURI(originalMessage.getReceiverNeedURI()) .setSenderURI(originalMessage.getReceiverURI())