-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Custom Message Processor for Hub & Things services. #35
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you very much for your contribution! I reviewed the pull request and have some general remarks/questions, apart from the comments made to the code directly:
- the Hub changed its endpoint format, the
control
endpoints are now deprecated (I know, at the time of your pull request, they were not, sorry for the late review 😇) and will be removed soon. Could you adopt the processor to the new endpoint format? (see https://www.eclipse.org/hono/docs/api/command-and-control/) - I do not yet understand why we need two amqp clients (hub and internal). FMPOV this makes the architecture more complex than necessary. Both directions (upstream and downstream) could be achieved with one ProtonServer and one ProtonClient. Maybe I missed something?
- the MessageProcessingService does the processing only in one direction? But we have upstream and downstream messages? Maybe we need two methods?
- is it necessary that the processor always opens the connection to the Hub on its own and not only on command, when there is a connection from Things
- we discussed if it is possible to also forward authentication to avoid specifying the credentials for the Hub connection. Did you try this or was this out of scope?
Regards, Dominik
message-processor/pom.xml
Outdated
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-proton</artifactId> | ||
<version>3.8.2</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ${stack.version}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use properties for the other versions as well?
public class Constants { | ||
public static final String TELEMETRY_ENDPOINT = "telemetry/"; | ||
public static final String EVENT_ENDPOINT = "event/"; | ||
public static final String CONTROL_ENDPOINT = "control/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
control
endpoint is deprecated, replace with command
/command_response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did notice some changes must have been made recently, as some things didn't work accordingly!
Will have a look at the new endpoints and make the necessary adjustments!
thanks
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class MessageProcessingService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to define an interface for this service, as this will be a custom implementation, depending on the use case. Furthermore we need two methods for both directions (upstream/downstream) to e.g. decrypt/encrypt, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that could be done!
At the time I was just aiming to introduce the message processing in as simple as possible manner and later figure out the details.
}); | ||
} | ||
|
||
public boolean isConnected(int timeout) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should always start a connection, or only when a connection is requested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this one is essentially going be to replacing the "out of the box" connection being defined on initial provisioning of the Asset Communication Package. Thus, I thought this connection would need to be set up and ready to handle traffic at all times?
@Value(value = "${hub.client.host}") | ||
private String hubHost; | ||
|
||
@Value(value = "${hub.client.port}") | ||
private Integer hubPort; | ||
|
||
@Value(value = "${hub.client.username}") | ||
private String hubUsername; | ||
|
||
@Value(value = "${hub.client.password}") | ||
private String hubPassword; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to "forward" the credentials? Then we would not have to configure it for every instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have a look and see what I could do about it!
} | ||
|
||
private void sendMessage(Message msg, String address) { | ||
if (address.startsWith(CONTROL_ENDPOINT) && !address.endsWith(CONTROL_REPLY_ENDPOINT)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not be necessary if we wire the associated receivers/senders on creation (e.g. a receiver on Things side will never receive a telemetry or event message and a receiver on hub side will never receive a command message).
@dguggemos |
No, a client can only be connected to one server at a time. But the basic idea is
So there is no need to have multiple clients. The other direction works the same, but with a receiver at the server and a sender at the client. |
Address some more issues mentioned in PR comments.
I get your point! |
Initialize Hub connection upon Things connecting to internal amqp server.
@dguggemos
|
Please, refer to https://wiki.bosch-si.com/display/GTM/Custom+Message+Processor+in+Detail !