How to place components at certain positions

0 votes
asked Oct 17 in Question / help by Cecil Westerhof

I have the following code:

@startuml

[Producer 1]
[Producer 2]
[Producer ...]
[Producer n]

cloud {
  [Internet] as Internet1
}

node RabbitMQ #LightSteelBlue {
  [Exchange]
  [Queue 1]
  [Queue 2]
  [Queue ...]
  [Queue n]
}

cloud {
  [Internet] as Internet2
}

[Consumer 1]
[Consumer 2]
[Consumer ...]
[Consumer n]


[Producer 1]    -[hidden]-> [Producer 2]
[Producer 2]    -[hidden]-> [Producer ...]
[Producer ...]  -[hidden]-> [Producer n]

[Producer 1]     -> [Internet1]     : Publish
' [Producer 2]     -> [Internet1]     : Publish
' [Producer ...]   -> [Internet1]     : Publish
' [Producer n]     -> [Internet1]     : Publish
[Internet1]      -> [Exchange]      : Publish
[Exchange]       -> [Queue 1]       : Route
' [Exchange]       -> [Queue 2]       : Route
' [Exchange]       -> [Queue ...]     : Route
' [Exchange]       -> [Queue n]       : Route

[Queue 1]    -[hidden]-> [Queue 2]
[Queue 2]    -[hidden]-> [Queue ...]
[Queue ...]  -[hidden]-> [Queue n]

[Queue 1]        -> [Internet2]     : Consume
' [Queue 2]        -> [Internet2]     : Consume
' [Queue ...]      -> [Internet2]     : Consume
' [Queue n]        -> [Internet2]     : Consume


[Consumer 1]    -[hidden]-> [Consumer 2]
[Consumer 2]    -[hidden]-> [Consumer ...]
[Consumer ...]  -[hidden]-> [Consumer n]

[Internet2]      -> [Consumer 1]    : Consume
' [Internet2]      -> [Consumer 2]    : Consume
' [Internet2]      -> [Consumer ...]  : Consume
' [Internet2]      -> [Consumer n]    : Consume

@enduml

This does mostly what I want. With a few exceptions:

  • I like all producers to connect to internet1
  • I like Exchange to connect to all queues
  • I like all queues to connect to internet2
  • I like internet2 to connect to all consumers
I tried this with the stuff that is now in comment. But that did not work.
How could I implement this?
Also: what is the reason that there is such a big distance between the queues?
commented Oct 18 by Cecil Westerhof

I found a way to get a reasonable result:

@startuml

component [Producer 1\nProducer 2\nProducer ...\nProducer n] as Producers

cloud {
  [Internet] as Internet1
}

node RabbitMQ #LightSteelBlue {
  [Exchange]
  [Queue 1\nQueue 2\nQueue ...\nQueue n] as Queues
}

cloud {
  [Internet] as Internet2
}

[Consumer 1\nConsumer 2\nConsumer ...\nConsumer n] as Consumers


[Producers] -> [Internet1]  : Publish
[Internet1] -> [Exchange]   : Publish
[Exchange]  -> [Queues]     : Route
[Queues]    -> [Internet2]  : Consume
[Internet2] -> [Consumers]  : Consume

@enduml

I put the four producers/queues/consumers in one component. But if there is a better way …

1 Answer

0 votes
answered Oct 18 by cprn (230 points)

I'm not sure I understand what you mean but doesn't grouping with "together" work here?

together group_name1 {
    element1
    element2
    element3
}

together group_name2 {
    element4
    element5
}

group_name1 -[hidden]- group_name2

element1 -- element4
element3 -- element4

etc.

...