You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2024/07/10 16:05:14 UTC
(camel-karavan) branch main updated: Route Config in Topology
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new c37d2935 Route Config in Topology
c37d2935 is described below
commit c37d2935b090978a62b7f13500b92a61a493f370
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Wed Jul 10 12:05:06 2024 -0400
Route Config in Topology
---
.../src/main/webui/src/topology/TopologyApi.tsx | 27 +++-
.../src/main/webui/src/topology/TopologyStore.ts | 2 +-
karavan-core/src/core/api/TopologyUtils.ts | 13 +-
karavan-designer/public/example/demo.camel.yaml | 151 ++++++++++++++-------
karavan-designer/src/App.tsx | 2 +-
karavan-designer/src/topology/TopologyApi.tsx | 25 +++-
karavan-space/src/topology/TopologyApi.tsx | 27 +++-
karavan-space/src/topology/TopologyStore.ts | 2 +-
8 files changed, 185 insertions(+), 64 deletions(-)
diff --git a/karavan-app/src/main/webui/src/topology/TopologyApi.tsx b/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
index 26d5c40c..174ad6a6 100644
--- a/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
+++ b/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
@@ -234,11 +234,13 @@ export function getRestEdges(rest: TopologyRestNode[], tins: TopologyIncomingNod
export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyIncomingNode[]): EdgeModel[] {
const result: EdgeModel[] = [];
tons.filter(ton => ton.type === 'internal').forEach((ton, index) => {
- const uri: string = (ton.step as any).uri;
- if (uri.startsWith("direct") || uri.startsWith("seda")) {
- const name = (ton.step as any).parameters.name;
+ const step = (ton.step as any);
+ if (step?.dslName === 'DeadLetterChannelDefinition') {
+ const parts = step.deadLetterUri?.split(":");
+ const uri: string = parts[0];
+ const name: string = parts[1];
const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
- const node: EdgeModel = {
+ const node: EdgeModel = {
id: 'internal-' + ton.id + '-' + index,
type: 'edge',
source: 'route-' + ton.routeId,
@@ -247,6 +249,21 @@ export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyInc
animationSpeed: EdgeAnimationSpeed.medium
}
if (target) result.push(node);
+ } else {
+ const uri: string = (ton.step as any).uri;
+ if (uri?.startsWith("direct") || uri?.startsWith("seda")) {
+ const name = (ton.step as any).parameters.name;
+ const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
+ const node: EdgeModel = {
+ id: 'internal-' + ton.id + '-' + index,
+ type: 'edge',
+ source: 'route-' + ton.routeId,
+ target: target,
+ edgeStyle: EdgeStyle.solid,
+ animationSpeed: EdgeAnimationSpeed.medium
+ }
+ if (target) result.push(node);
+ }
}
});
return result;
@@ -308,7 +325,7 @@ export function getModel(files: IntegrationFile[], grouping?: boolean): Model {
edges.push(...getRestEdges(trestns, tins));
edges.push(...getInternalEdges(tons, tins));
edges.push(...getInternalEdges(trcons, tins));
- edges.push(...getExternalEdges(tons,tins));
+ // edges.push(...getExternalEdges(tons,tins));
return {nodes: nodes, edges: edges, graph: {id: 'g1', type: 'graph', layout: 'Dagre'}};
}
diff --git a/karavan-app/src/main/webui/src/topology/TopologyStore.ts b/karavan-app/src/main/webui/src/topology/TopologyStore.ts
index 63b7ed4f..0ba80503 100644
--- a/karavan-app/src/main/webui/src/topology/TopologyStore.ts
+++ b/karavan-app/src/main/webui/src/topology/TopologyStore.ts
@@ -56,7 +56,7 @@ export const useTopologyStore = createWithEqualityFn<TopologyState>((set) => ({
return {nodeData: nodeData};
});
},
- showGroups: false,
+ showGroups: true,
setShowGroups: (showGroups: boolean) => {
set((state: TopologyState) => {
return {showGroups: showGroups};
diff --git a/karavan-core/src/core/api/TopologyUtils.ts b/karavan-core/src/core/api/TopologyUtils.ts
index 4d0b22e0..4ec740a9 100644
--- a/karavan-core/src/core/api/TopologyUtils.ts
+++ b/karavan-core/src/core/api/TopologyUtils.ts
@@ -272,9 +272,20 @@ export class TopologyUtils {
const type = TopologyUtils.isElementInternalComponent(e) ? 'internal' : 'external';
const connectorType = TopologyUtils.getConnectorType(e);
const uniqueUri = TopologyUtils.getUniqueUri(e);
- result.push(new TopologyOutgoingNode(id, type, connectorType, rc.id || 'default', title, filename, e, uniqueUri));
+ result.push(new TopologyOutgoingNode(id, type, connectorType, rc.id || 'undefined', title, filename, e, uniqueUri));
})
})
+ if (rc.errorHandler?.deadLetterChannel) {
+ const e = rc.errorHandler?.deadLetterChannel
+ const id = 'outgoing-' + rc.id + '-' + e.id;
+ const title = CamelDisplayUtil.getStepDescription(e);
+ const type = (e?.deadLetterUri?.startsWith('direct:') || e?.deadLetterUri?.startsWith('seda:') )
+ ? 'internal'
+ : 'external';
+ const connectorType = 'component';
+ const uniqueUri = e?.deadLetterUri
+ result.push(new TopologyOutgoingNode(id, type, connectorType, rc.id || 'undefined', title, filename, e, uniqueUri));
+ }
})
})
diff --git a/karavan-designer/public/example/demo.camel.yaml b/karavan-designer/public/example/demo.camel.yaml
index ef7ef78f..a1df214f 100644
--- a/karavan-designer/public/example/demo.camel.yaml
+++ b/karavan-designer/public/example/demo.camel.yaml
@@ -1,55 +1,114 @@
- route:
- id: route-b0b7
- nodePrefixId: route-dfc
+ id: route-654e
+ description: Error Handler
+ nodePrefixId: route-a06
from:
- id: from-70b1
- uri: kamelet:timer-source
+ id: from-6dd1
+ description: DLQ
+ uri: direct
parameters:
- message: Hello
- period: 1
+ name: dlq
steps:
- - to:
- id: to-df39
- uri: amqp
- - to:
- id: to-1600
- uri: kamelet:kafka-sink
- - choice:
- id: choice-41b7
- when:
- - id: when-29c0
- expression:
- simple:
- id: simple-289b
- steps:
- - aggregate:
- id: aggregate-1193
- completionSize: 121212
- completionTimeout: "{{bean:beanName.method}}"
- steps:
- - bean:
- id: bean-a9e0
- - to:
- id: to-df17
- uri: amqp
- otherwise:
- id: otherwise-b00c
- steps:
- - aggregate:
- id: aggregate-46cb
- completionSize: 1
- steps:
- - to:
- id: to-5565
- uri: activemq
+ - log:
+ id: log-bf00
+ message: "ERROR: ${exception}"
- route:
- id: test
+ id: route-c11a
+ description: From Warehouse
+ nodePrefixId: route-ae1
+ autoStartup: true
from:
- id: from-aeed
- uri: direct
+ id: from-b6f1
+ description: Command received
+ uri: kamelet:kafka-not-secured-source
parameters:
- name: test
+ topic: wh_commands
+ bootstrapServers: kafka:9092
+ autoCommitEnable: true
+ consumerGroup: lightstep
steps:
+ - log:
+ id: log-c7b9
+ description: Log request
+ message: "Received command: ${body}, current sequence: ${variable.sequence}"
+ - setVariable:
+ id: setVariable-61a9
+ description: Set command
+ name: command
+ expression:
+ simple:
+ id: simple-965d
+ expression: ${body}
+ - setBody:
+ id: setBody-0515
+ description: Prepare message
+ expression:
+ groovy:
+ id: groovy-bb4f
+ expression: >-
+ def seq = String.format("%03d",
+ camelContext.getVariable("sequence"));
+
+ def length = String.format("%04d",
+ variables.command.length());
+
+
+ return String.valueOf((char)0x02)
+ .concat(seq)
+ .concat(length)
+ .concat(variables.command)
+ .concat(String.valueOf((char)0x03));
+ - log:
+ id: log-7190
+ description: Log message
+ message: "Message: ${body}"
- to:
- id: to-1daf
- uri: kamelet:aws-bedrock-agent-runtime-sink
+ id: to-bb55
+ description: Call Controller
+ uri: netty
+ parameters:
+ protocol: tcp
+ host: 208.167.255.177
+ port: "15003"
+ disconnect: false
+ keepAlive: false
+ requestTimeout: "10000"
+ useByteBuf: false
+ autoAppendDelimiter: true
+ allowDefaultCodec: true
+ reuseAddress: true
+ - setVariable:
+ id: setVariable-048c
+ description: Update sequence
+ name: global:sequence
+ expression:
+ simple:
+ id: simple-340f
+ expression: ${variable.sequence} + 1
+ - log:
+ id: log-b944
+ description: Log result
+ message: "Response: ${body}, next sequence: ${variable.sequence}"
+- route:
+ id: route-42e3
+ description: Events from JunctionBox
+ nodePrefixId: route-de0
+ autoStartup: false
+ from:
+ id: from-5b8a
+ description: Event received
+ uri: netty
+ parameters:
+ protocol: tcp
+ host: 208.167.255.177
+ port: "15003"
+ clientMode: true
+ steps:
+ - log:
+ id: log-63db
+ message: ${body}
+- routeConfiguration:
+ errorHandler:
+ deadLetterChannel:
+ id: deadLetterChannel-3bf9
+ deadLetterUri: direct:dlq
diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx
index bc6d9f7b..b7344e30 100644
--- a/karavan-designer/src/App.tsx
+++ b/karavan-designer/src/App.tsx
@@ -58,7 +58,7 @@ class MenuItem {
export function App() {
- const [pageId, setPageId] = useState<string>('designer');
+ const [pageId, setPageId] = useState<string>('topology');
const [name, setName] = useState<string>('example.yaml');
const [key, setKey] = useState<string>('');
const [yaml, setYaml] = useState<string>('');
diff --git a/karavan-designer/src/topology/TopologyApi.tsx b/karavan-designer/src/topology/TopologyApi.tsx
index fa5ca2d2..174ad6a6 100644
--- a/karavan-designer/src/topology/TopologyApi.tsx
+++ b/karavan-designer/src/topology/TopologyApi.tsx
@@ -234,11 +234,13 @@ export function getRestEdges(rest: TopologyRestNode[], tins: TopologyIncomingNod
export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyIncomingNode[]): EdgeModel[] {
const result: EdgeModel[] = [];
tons.filter(ton => ton.type === 'internal').forEach((ton, index) => {
- const uri: string = (ton.step as any).uri;
- if (uri.startsWith("direct") || uri.startsWith("seda")) {
- const name = (ton.step as any).parameters.name;
+ const step = (ton.step as any);
+ if (step?.dslName === 'DeadLetterChannelDefinition') {
+ const parts = step.deadLetterUri?.split(":");
+ const uri: string = parts[0];
+ const name: string = parts[1];
const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
- const node: EdgeModel = {
+ const node: EdgeModel = {
id: 'internal-' + ton.id + '-' + index,
type: 'edge',
source: 'route-' + ton.routeId,
@@ -247,6 +249,21 @@ export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyInc
animationSpeed: EdgeAnimationSpeed.medium
}
if (target) result.push(node);
+ } else {
+ const uri: string = (ton.step as any).uri;
+ if (uri?.startsWith("direct") || uri?.startsWith("seda")) {
+ const name = (ton.step as any).parameters.name;
+ const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
+ const node: EdgeModel = {
+ id: 'internal-' + ton.id + '-' + index,
+ type: 'edge',
+ source: 'route-' + ton.routeId,
+ target: target,
+ edgeStyle: EdgeStyle.solid,
+ animationSpeed: EdgeAnimationSpeed.medium
+ }
+ if (target) result.push(node);
+ }
}
});
return result;
diff --git a/karavan-space/src/topology/TopologyApi.tsx b/karavan-space/src/topology/TopologyApi.tsx
index 26d5c40c..174ad6a6 100644
--- a/karavan-space/src/topology/TopologyApi.tsx
+++ b/karavan-space/src/topology/TopologyApi.tsx
@@ -234,11 +234,13 @@ export function getRestEdges(rest: TopologyRestNode[], tins: TopologyIncomingNod
export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyIncomingNode[]): EdgeModel[] {
const result: EdgeModel[] = [];
tons.filter(ton => ton.type === 'internal').forEach((ton, index) => {
- const uri: string = (ton.step as any).uri;
- if (uri.startsWith("direct") || uri.startsWith("seda")) {
- const name = (ton.step as any).parameters.name;
+ const step = (ton.step as any);
+ if (step?.dslName === 'DeadLetterChannelDefinition') {
+ const parts = step.deadLetterUri?.split(":");
+ const uri: string = parts[0];
+ const name: string = parts[1];
const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
- const node: EdgeModel = {
+ const node: EdgeModel = {
id: 'internal-' + ton.id + '-' + index,
type: 'edge',
source: 'route-' + ton.routeId,
@@ -247,6 +249,21 @@ export function getInternalEdges(tons: TopologyOutgoingNode[], tins: TopologyInc
animationSpeed: EdgeAnimationSpeed.medium
}
if (target) result.push(node);
+ } else {
+ const uri: string = (ton.step as any).uri;
+ if (uri?.startsWith("direct") || uri?.startsWith("seda")) {
+ const name = (ton.step as any).parameters.name;
+ const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, name);
+ const node: EdgeModel = {
+ id: 'internal-' + ton.id + '-' + index,
+ type: 'edge',
+ source: 'route-' + ton.routeId,
+ target: target,
+ edgeStyle: EdgeStyle.solid,
+ animationSpeed: EdgeAnimationSpeed.medium
+ }
+ if (target) result.push(node);
+ }
}
});
return result;
@@ -308,7 +325,7 @@ export function getModel(files: IntegrationFile[], grouping?: boolean): Model {
edges.push(...getRestEdges(trestns, tins));
edges.push(...getInternalEdges(tons, tins));
edges.push(...getInternalEdges(trcons, tins));
- edges.push(...getExternalEdges(tons,tins));
+ // edges.push(...getExternalEdges(tons,tins));
return {nodes: nodes, edges: edges, graph: {id: 'g1', type: 'graph', layout: 'Dagre'}};
}
diff --git a/karavan-space/src/topology/TopologyStore.ts b/karavan-space/src/topology/TopologyStore.ts
index 63b7ed4f..0ba80503 100644
--- a/karavan-space/src/topology/TopologyStore.ts
+++ b/karavan-space/src/topology/TopologyStore.ts
@@ -56,7 +56,7 @@ export const useTopologyStore = createWithEqualityFn<TopologyState>((set) => ({
return {nodeData: nodeData};
});
},
- showGroups: false,
+ showGroups: true,
setShowGroups: (showGroups: boolean) => {
set((state: TopologyState) => {
return {showGroups: showGroups};