diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java index 2ddbc4bddb..4d95292986 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java @@ -205,7 +205,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat nodes.add(handlerNode); MessageChannelNode channelNode = channelNodes.get(handlerNode.getInput()); if (channelNode != null) { - links.add(new LinkNode(channelNode.getNodeId(), handlerNode.getNodeId())); + links.add(new LinkNode(channelNode.getNodeId(), handlerNode.getNodeId(), LinkNode.Type.input)); } producerLink(links, channelNodes, handlerNode); } @@ -217,19 +217,19 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat if (endpointNode.getOutput() != null) { channelNode = channelNodes.get(endpointNode.getOutput()); if (channelNode != null) { - links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId())); + links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId(), LinkNode.Type.output)); } } if (endpointNode instanceof ErrorCapableNode) { channelNode = channelNodes.get(((ErrorCapableNode) endpointNode).getErrors()); if (channelNode != null) { - links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId())); + links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId(), LinkNode.Type.error)); } } if (endpointNode instanceof DiscardingMessageHandlerNode) { channelNode = channelNodes.get(((DiscardingMessageHandlerNode) endpointNode).getDiscards()); if (channelNode != null) { - links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId())); + links.add(new LinkNode(endpointNode.getNodeId(), channelNode.getNodeId(), LinkNode.Type.discard)); } } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/LinkNode.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/LinkNode.java index e2f6103c42..fa9c16f8d7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/LinkNode.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/LinkNode.java @@ -29,9 +29,12 @@ public class LinkNode { private final int to; - public LinkNode(int from, int to) { + private final Type type; + + public LinkNode(int from, int to, Type type) { this.from = from; this.to = to; + this.type = type; } public int getFrom() { @@ -42,4 +45,12 @@ public class LinkNode { return this.to; } + public Type getType() { + return this.type; + } + + public enum Type { + input, output, error, discard + } + } diff --git a/src/reference/asciidoc/graph.adoc b/src/reference/asciidoc/graph.adoc index 8fcbfa67b5..75e1bceeec 100644 --- a/src/reference/asciidoc/graph.adoc +++ b/src/reference/asciidoc/graph.adoc @@ -61,7 +61,8 @@ A simple Spring Integration application with only the default components would e "links": [ { "from": 2, - "to": 3 + "to": 3, + "type": "input" } ] } @@ -76,7 +77,32 @@ Other properties are provided by the framework and allows you to distinguish a s The `links` graph element represents connections between nodes from the `nodes` graph element and, therefore, between integration components in the source Spring Integration application. For example _from_ a `MessageChannel` _to_ an `EventDrivenConsumer` with some `MessageHandler`; or _from_ an `AbstractReplyProducingMessageHandler` _to_ a `MessageChannel`. +For the convenience and to allow to determine a link purpose, the model is supplied with the `type` attribute. +The possible types are: + +- _input_ - identify the direction from `MessageChannel` to the endpoint; `inputChannel` or `requestChannel` property; +- _output_ - the direction from `MessageHandler`, `MessageProducer` or `SourcePollingChannelAdapter` to the `MessageChannel` via an `outputChannel` or `replyChannel` property; +- _error_ - from `MessageHandler` on `PollingConsumer` or `MessageProducer` or `SourcePollingChannelAdapter` to the `MessageChannel` via an `errorChannel` property; +- _discard_ - from `DiscardingMessageHandler` (e.g. `MessageFilter`) to the `MessageChannel` via `errorChannel` property. + The information from this element can be used by a visualizing tool to render connections between nodes from the `nodes` graph element, where the `from` and `to` numbers represent the value from the `nodeId` property of the linked nodes. +For example the link `type` can be used to determine the proper _port_ on the target node: + +---- + +---(discard) + | + +----o----+ + | | + | | + | | +(input)--o o---(output) + | | + | | + | | + +----o----+ + | + +---(error) +---- The `nodes` graph element is perhaps the most interesting because its elements contain not only the runtime components with their `componentType` s and `name` s, but can also optionally contain metrics exposed by the component. To enable the metrics, add an `@EnableIntegrationManagement` to some `@Configuration` class or add an `` element to your XML configuration.