@Override public ServiceReference getConsumer() { return getExchange().getConsumer(); }
@Override public ServiceReference getConsumer() { return getExchange().getConsumer(); }
@Override public synchronized void handleMessage(Exchange exchange) throws HandlerException { if (_responseQueue == null) { CommonCommonLogger.ROOT_LOGGER.replyArrivedAfterTimeout(exchange.getConsumer().getName().toString()); } else { try { _responseQueue.put(exchange); } catch (InterruptedException e) { throw new HandlerException(e); } } }
@Override public synchronized void handleMessage(Exchange exchange) throws HandlerException { if (_responseQueue == null) { CommonCommonLogger.ROOT_LOGGER.replyArrivedAfterTimeout(exchange.getConsumer().getName().toString()); } else { try { _responseQueue.put(exchange); } catch (InterruptedException e) { throw new HandlerException(e); } } }
@Override public synchronized void handleFault(Exchange exchange) { if (_responseQueue == null) { CommonCommonLogger.ROOT_LOGGER.faultArrivedAfterTimeout(exchange.getConsumer().getName().toString()); } else { try { _responseQueue.put(exchange); } catch (InterruptedException e) { throw CommonCommonMessages.MESSAGES.unexpectedInterruptException(e); } } } }
@Override public synchronized void handleFault(Exchange exchange) { if (_responseQueue == null) { CommonCommonLogger.ROOT_LOGGER.faultArrivedAfterTimeout(exchange.getConsumer().getName().toString()); } else { try { _responseQueue.put(exchange); } catch (InterruptedException e) { throw CommonCommonMessages.MESSAGES.unexpectedInterruptException(e); } } } }
private static String formatHeaders(Exchange exchange) { StringBuilder headers = new StringBuilder() .append(indent(0) + "Consumer -> " + exchange.getConsumer().getName()) .append(indent(0) + "Provider -> " + ((exchange.getProvider() == null) ? "[unassigned]" : exchange.getProvider().getName())) .append(indent(0) + "Operation -> " + exchange.getContract().getConsumerOperation().getName()) .append(indent(0) + "MEP -> " + ((exchange.getContract().getConsumerOperation().getExchangePattern() == null) ? "[unassigned]" : exchange.getContract().getConsumerOperation().getExchangePattern())) .append(indent(0) + "Phase -> " + exchange.getPhase()) .append(indent(0) + "State -> " + exchange.getState()); // Add context properties headers.append(indent(0) + "Exchange Context -> "); dumpContext(headers, exchange.getContext().getProperties(Scope.EXCHANGE)); headers.append(indent(0) + "Message Context -> "); dumpContext(headers, exchange.getContext().getProperties(Scope.MESSAGE)); return headers.toString(); }
private static String formatHeaders(Exchange exchange) { StringBuilder headers = new StringBuilder() .append(indent(0) + "Consumer -> " + exchange.getConsumer().getName()) .append(indent(0) + "Provider -> " + ((exchange.getProvider() == null) ? "[unassigned]" : exchange.getProvider().getName())) .append(indent(0) + "Operation -> " + exchange.getContract().getConsumerOperation().getName()) .append(indent(0) + "MEP -> " + ((exchange.getContract().getConsumerOperation().getExchangePattern() == null) ? "[unassigned]" : exchange.getContract().getConsumerOperation().getExchangePattern())) .append(indent(0) + "Phase -> " + exchange.getPhase()) .append(indent(0) + "State -> " + exchange.getState()); // Add context properties headers.append(indent(0) + "Exchange Context -> "); dumpContext(headers, exchange.getContext().getProperties(Scope.EXCHANGE)); headers.append(indent(0) + "Message Context -> "); dumpContext(headers, exchange.getContext().getProperties(Scope.MESSAGE)); return headers.toString(); }
List<Service> services = _domain.getServices(exchange.getConsumer().getTargetServiceName()); if (services == null || services.isEmpty()) { throw RuntimeMessages.MESSAGES.noRegisteredService(exchange.getConsumer().getName().toString());
List<Service> services = _domain.getServices(exchange.getConsumer().getTargetServiceName()); if (services == null || services.isEmpty()) { throw RuntimeMessages.MESSAGES.noRegisteredService(exchange.getConsumer().getName().toString());
QName referenceName = ComponentNames.unqualify(exchange.getConsumer().getName()); for (Service service : _switchYard.getServices()) { if (service.getName().equals(serviceName)) {
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }
@Override public void dispatch(final Exchange exchange) { // We can only send Camel exchanges through the camel bus if (!CamelExchange.class.isInstance(exchange)) { throw BusMessages.MESSAGES.onlyCamelExchanges(); } CamelExchange camelEx = (CamelExchange)exchange; // For camel exchanges, the only phase we care about is IN. The dispatch method can also // be called on the OUT path, but that should be handled by the IN_OUT filter in the Camel // bus route. if (!exchange.getPhase().equals(ExchangePhase.IN)) { return; } Throttling throttling = _reference.getServiceMetadata().getThrottling(); if (throttling != null && throttling.getMaxRequests() > 0) { exchange.getMessage().getContext().setProperty( Throttling.MAX_REQUESTS, throttling.getMaxRequests()) .addLabels(BehaviorLabel.TRANSIENT.label()); } _producer.send("direct:" + exchange.getConsumer().getName(), camelEx.getExchange()); }
@Override public void dispatch(final Exchange exchange) { // We can only send Camel exchanges through the camel bus if (!CamelExchange.class.isInstance(exchange)) { throw BusMessages.MESSAGES.onlyCamelExchanges(); } CamelExchange camelEx = (CamelExchange)exchange; // For camel exchanges, the only phase we care about is IN. The dispatch method can also // be called on the OUT path, but that should be handled by the IN_OUT filter in the Camel // bus route. if (!exchange.getPhase().equals(ExchangePhase.IN)) { return; } Throttling throttling = _reference.getServiceMetadata().getThrottling(); if (throttling != null && throttling.getMaxRequests() > 0) { exchange.getMessage().getContext().setProperty( Throttling.MAX_REQUESTS, throttling.getMaxRequests()) .addLabels(BehaviorLabel.TRANSIENT.label()); } String uri = "direct:" + exchange.getConsumer().getName(); DirectEndpoint ep = _context.getEndpoint(uri, DirectEndpoint.class); if (ep.getConsumer() == null) { throw BusMessages.MESSAGES.consumerForinternalCamelRouteNotFound(uri); } _producer.send(ep, camelEx.getExchange()); }
RemoteMessage createReplyMessage(Exchange exchange) { RemoteMessage reply = new RemoteMessage(); reply.setDomain(exchange.getProvider().getDomain().getName()) .setOperation(exchange.getContract().getConsumerOperation().getName()) .setService(exchange.getConsumer().getName()); exchange.getContext().mergeInto(reply.getContext()); if (exchange.getMessage() != null) { reply.setContent(exchange.getMessage().getContent()); } if (exchange.getState().equals(ExchangeState.FAULT)) { reply.setFault(true); } return reply; }
RemoteMessage createReplyMessage(Exchange exchange) { RemoteMessage reply = new RemoteMessage(); reply.setDomain(exchange.getProvider().getDomain().getName()) .setOperation(exchange.getContract().getConsumerOperation().getName()) .setService(exchange.getConsumer().getName()); exchange.getContext().mergeInto(reply.getContext()); if (exchange.getMessage() != null) { reply.setContent(exchange.getMessage().getContent()); } if (exchange.getState().equals(ExchangeState.FAULT)) { reply.setFault(true); } return reply; }