public static void HandleTransform(XElement step, Route routeObj, Exchange exchange) { try { var transformXml = step.Elements().First(); var opName = transformXml.Name.ToString(); switch (opName) { case "simple": ProcessSimple(transformXml, routeObj, exchange); break; case "xpath": break; } } catch (AggregateException aggregateException) { } catch (Exception exception) { } }
/// <summary> /// /// </summary> /// <param name="step"></param> /// <param name="exchange"></param> /// <param name="routeObj"></param> public static void Enrich(XElement step, Exchange exchange, Route routeObj) { try { var uri = step.Attribute("uri"); var strategyref = step.Attribute("strategyref"); if (uri == null || strategyref == null) return; var uriInfo = UriDescriptor.Parse(uri.Value, exchange); var clonedExchange = exchange.CloneExchange(); EndPointBuilder.HandleTo(uriInfo, clonedExchange, routeObj); //fetch strategy var stragegyObj = Camel.Registry[strategyref.Value] as AggregationStrategy; if (stragegyObj != null) { stragegyObj.Aggregate(exchange, clonedExchange); } } catch (Exception exc) { } }
/// <summary> /// Execute /// </summary> /// <param name="loopTag"></param> /// <param name="exchange"></param> /// <param name="route"></param> public static void Execute(XElement loopTag, Exchange exchange, Route route) { Camel.TryLog(exchange, "processor", "loop"); var expressionTag = loopTag.Elements().FirstOrDefault(); if (expressionTag == null || (expressionTag.Name != "count")) return; var xpression = expressionTag.Value; var count = SimpleExpression.ResolveSpecifiedUriPart(xpression, exchange); var mCount = Convert.ToInt32(count); for (var i = 0; i < mCount; i++) { var data = loopTag.Elements().Skip(1); foreach (var dataItem in data) { try { RouteStep.ProcessStep(dataItem, route, exchange); } catch (Exception exception) { } } } }
/// <summary> /// ProcessRouteInformation Now. /// </summary> /// <param name="route"></param> /// <param name="autoExec"></param> /// <param name="logProvider"></param> /// <param name="bundleDescriptorObject"></param> public static void ProcessRouteInformation(XElement route, bool autoExec = false, ISystemLogProvider logProvider = null, BundleDescriptorObject bundleDescriptorObject = null) { if (route == null) throw new AppCoreException("error loading route-config: route cannot be null"); var xmlRouteDesc = route.Attribute("description"); var routeDesc = xmlRouteDesc != null ? xmlRouteDesc.Value : ""; var steps = route.Elements(); var newRoute = new Route { LogProvider = logProvider, Description = routeDesc, BundleInfo = bundleDescriptorObject }; RouteStep nextRouteStepProcessorToLink = null; foreach (var step in steps) { if (newRoute.CurrentRouteStep == null) { newRoute.CurrentRouteStep = new RouteStep(step, newRoute); nextRouteStepProcessorToLink = newRoute.CurrentRouteStep; } else { var nextStep = new RouteStep(step, newRoute); if (nextRouteStepProcessorToLink == null) continue; nextRouteStepProcessorToLink.NextTag = nextStep; nextRouteStepProcessorToLink = nextRouteStepProcessorToLink.NextTag; } } Camel.SetRoute(newRoute); if (autoExec) newRoute.CurrentRouteStep.ProcessChannel(); }
/// <summary> /// ProcessRouteInformation From Method /// </summary> /// <param name="leafDescriptor"></param> /// <param name="route"></param> public static void HandleFrom(UriDescriptor leafDescriptor, Route route, Exchange exchangeData = null) { try { //init endpoint DefaultEndpoint endPoint; if (Camel.EnPointCollection.TryGetValue(leafDescriptor.FullUri, out endPoint)) { } else { var execAssembly = Assembly.GetExecutingAssembly(); var types = execAssembly.GetTypes(); foreach (var namespaceToCheck in PermissibleNamespaces) { var typeData = types.FirstOrDefault( c => c.FullName.Equals( string.Format("{0}.{1}.{2}", namespaceToCheck, leafDescriptor.ComponentName, leafDescriptor.ComponentName), StringComparison.InvariantCultureIgnoreCase) || c.FullName.Equals( string.Format("{0}.{1}.{2}EndPoint", namespaceToCheck, leafDescriptor.ComponentName, leafDescriptor.ComponentName), StringComparison.InvariantCultureIgnoreCase)); if (typeData == null) continue; endPoint = (DefaultEndpoint) Activator.CreateInstance(typeData, leafDescriptor.FullUri, route); Camel.EnPointCollection.TryAdd(leafDescriptor.FullUri, endPoint); break; } } if (endPoint != null) { if (exchangeData == null) endPoint.Start(); else { endPoint.StartWithExistingExchange(exchangeData); } } else throw new AppCoreException("end-point not found: " + leafDescriptor.ComponentName); } catch (AggregateException exception) { } catch (Exception exception) { throw new AppCoreException("error handling [from-tag] :" + exception.Message, exception); } }
public Exchange(Route route) { Route = route; ExchangeId = Guid.NewGuid(); CamelCreatedTimestamp = DateTime.Now; _lastAccessTime = DateTime.Now; PropertyCollection = new ConcurrentDictionary<string, string>(); }
private static void Tap(Exchange exchange, string path, Route route) { try { var leafNodeParts = UriDescriptor.Parse(path, exchange); EndPointBuilder.HandleTo(leafNodeParts, exchange, route); } catch(Exception exception) { Console.WriteLine(exception.Message); } }
public FileProducer(UriDescriptor uriInformation, Route route) : base(uriInformation, route) { }
public MinaProcessor(UriDescriptor uriInformation, Route route) : base(uriInformation, route) { }
public XmlToJsonProducer(UriDescriptor uriInformation, Route route) : base(uriInformation, route) { }
public RouteStep(XElement currentStepXml, Route route) { _currentStepXml = currentStepXml; Route = route; CheckIfRouteNameOverrideRequired(); }
private static void HandleProcessor(XElement step, Route routeObj, Exchange exchange) { try { var attr = step.Attribute("ref"); var reference = attr.Value; var bean = Camel.Registry[reference] as ProcessorBase; if (bean != null) bean.Process(exchange); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
private static void HandleLoop(XElement step, Route routeObj, Exchange exchange) { LoopTag.Execute(step, exchange, routeObj); }
private static void HandleFilter(XElement step, Route routeObj, Exchange exchange) { throw new NotImplementedException(); }
private static void HandleDelay(XElement step, Route routeObj, Exchange exchange) { var delay = step.Attribute("value").Value; DelayTag.Execute(delay, exchange, null); }
private static void HandleConvertBodyTo(XElement step, Route routeObj, Exchange exchange) { try { var toType = step.Attribute("type").Value; var finalType = Type.GetType(toType); if (finalType != null) exchange.InMessage.Body = Convert.ChangeType(exchange.InMessage.Body, finalType); } catch { } }
public static void Execute(string uri, Exchange exchange, Route route) { var leafNodeParts = UriDescriptor.Parse(uri, exchange); EndPointBuilder.HandleTo(leafNodeParts, exchange, route); }
private static void HandleProperty(XElement step, Route routeObj, Exchange exchange) { var propertyName = step.Attribute("name").Value; var value = step.Attribute("value").Value; value = SimpleExpression.ResolveSpecifiedUriPart(value, exchange); exchange.SetProperty(propertyName, value); }
public DirectEndpoint(string uri, Route route) : base(uri, route) { }
private static void HandleRemoveHeader(XElement step, Route routeObj, Exchange exchange) { var headerName = step.Attribute("headerName").Value; object removedValue; exchange.InMessage.HeaderCollection.TryRemove(headerName, out removedValue); }
public DefaultProducer(UriDescriptor uriInformation, Route route) { _uriInformation = uriInformation; _route = route; }
private static void HandleSetHeader(XElement step, Route routeObj, Exchange exchange) { var headerName = step.Attribute("name").Value; var value = step.Attribute("value").Value; value = SimpleExpression.ResolveSpecifiedUriPart(value, exchange); exchange.InMessage.SetHeader(headerName, value); }
public HttpEndpoint(string uri, Route route) : base(uri, route) { }
private static void HandleToProcessor(XElement step, Route routeObj, Exchange exchange) { var uri = step.Attribute("uri").Value; ToTag.Execute(uri, exchange, routeObj); }
public static void Execute(Exchange exchange, string path, Route route) { Task.Factory.StartNew(() => Tap(exchange, path, route)); }
private static void HandleTransform(XElement step, Route routeObj, Exchange exchange) { Transform.HandleTransform(step, routeObj, exchange); }
public NormalizerEndPoint(string uri, Route route) : base(uri, route) { }
private static void HandleWireTap(XElement step, Route routeObj, Exchange exchange) { try { var fullUri = step.Attribute("uri").Value; WireTapPattern.Execute(exchange, fullUri, routeObj); } catch (Exception) { } }
public OpenWeatherProducer(UriDescriptor uriInformation, Route route) : base(uriInformation, route) { }
/// <summary> /// Read and handle step. /// </summary> /// <param name="step"></param> /// <param name="routeObj"></param> /// <param name="exchange"></param> public static void ProcessStep(XElement step, Route routeObj, Exchange exchange) { try { var stepname = step.Name.ToString().ToLower(); switch (stepname) { case "from": HandleFromProcessor(step, routeObj, exchange); break; case "to": HandleToProcessor(step, routeObj, exchange); break; case "enrich": HandleToEnricher(step, routeObj, exchange); break; case "split": HandleSplit(step, exchange); break; case "multicast": HandleMulticast(step, exchange); break; case "process": HandleProcessor(step, routeObj, exchange); break; case "bean": HandleBean(step, routeObj, exchange); break; case "convertbodyto": HandleConvertBodyTo(step, routeObj, exchange); break; case "setheader": HandleSetHeader(step, routeObj, exchange); break; case "removeheader": HandleRemoveHeader(step, routeObj, exchange); break; case "setproperty": HandleProperty(step, routeObj, exchange); break; case "choice": HandleChoice(step, routeObj, exchange); break; case "loop": HandleLoop(step, routeObj, exchange); break; case "delay": HandleDelay(step, routeObj, exchange); break; case "wiretap": HandleWireTap(step, routeObj, exchange); break; case "transform": HandleTransform(step, routeObj, exchange); break; case "filter": HandleFilter(step, routeObj, exchange); break; } } catch (Exception exception) { } }