-
Notifications
You must be signed in to change notification settings - Fork 5
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
Simplify the API #14
Simplify the API #14
Conversation
@jmazzitelli this is not for M5. And I do not have Agent working on top of this yet. This is a very rough idea how the cmd gw could be simplified. Could you please have a look if I am not oversimplifying somewhere? |
Actually after this change, the gw does not depend on Inventory anymore and could go back to bus |
"type": "object", | ||
"description": "A binary attachment metadata", | ||
"enum": ["UI", "FEED"] | ||
}, |
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 adds complexity where I don't think it is needed. What is the use-case for needing to define recipient type? first, there could be messages that could flow in either direction (for example, the simple EchoCommand, but in the future we could have Notification type commands where either a ui or feed will be given a notification message. Second, even for those messages that are destined for just one side or the other, it will be obvious by the command type itself (for example "DeployApplication" is clearly not going to have the UI as a recipient). So to me this just adds complexity where it isn't needed.
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 is not carved in stone, you may well be right, that we can live without that. My motivation for introducing it was to make the command gateway as stupid and generic as possible. I think that the gateway should be just that: transfer the messages between the web sockets and the bus, do some authentication (and perhaps authorization) but nothing more. If the messages know where they go from and to, the gateway does not need to know which makes the gateway simpler.
Yeah, and recipientType
allows for sending one message type to both kind of destinations, regardless from where it was sent.
c91498d
to
4db0e03
Compare
4db0e03 fails because it depends on hawkular/hawkular-bus#44 |
An important message about 4db0e03 is that I have all except for AddJdbcDriver itests working on top of it in hawkular/hawkular-agent#65 @jmazzitelli I hope, 4db0e03 is much more acceptable for you than the previous proposal. |
} | ||
|
||
@Override | ||
public void onMessage(Message message) { |
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.
the AbstractBasicMessageListener has its own onMessage() impmementation that does alot of stuff. overriding it here scares me because you are no longer doing any of it anymore. Where is the "onBasicMessage" implementation?
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.
AbstractBasicMessageListener has its own onMessage()
You certainly mean BasicMessageListener
that has its onMessage()
and onBasicMessage()
. I could not use those because they take the BasicMessage class to deserialize into type T
from type argument T extends BasicMessage
of the listener, which in turn assumes that listeners are implemented one per message class, which is not the case in my proposal. I rather have one listener for all message classes, that dynamically selects the command to handle the given message. But of course, to deserialize the message, I need another source of the class to deserialize into: I introduced a dedicated JMS message header to store that info #14 (diff)
4db0e03
to
a9dce88
Compare
* @author <a href="https://github.com/ppalaga">Peter Palaga</a> | ||
*/ | ||
public interface UiSessionOrigin extends BasicMessage { | ||
String getSenderRequestId(); |
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.
curious why there is no setter here for this? setSenderRequestId() is missing. Is this on purpose?
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.
An interesting topic :) I am a proponent of making classes immutable by default. Here on messages that can perhaps get processed asynchronously, the immutability would make especially good sense. I had no time so far to have a look how and if at all the jsonschema2pojo-maven-plugin supports immutability, but to make a potential switch to immutable message classes easier, I am adding only those setters that I need in the server code for now (before we have builders or other similar mechanism in place that can produce a modified copy of an immutable object).
|
||
/** | ||
* Creates a new {@link BusCommandContext} with the given {@code queue}. | ||
* @param queue the queue the present request came from |
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.
again, rename "queue" to just "endpoint" so we don't lock ourselves out of being able to use topics in the future.
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.
done
a9dce88
to
8c4ae14
Compare
8c4ae14 is the next iteration that adds/removes the bus listeners dynamincally as the WebSocket clients connect/disconnect. It also renamed fields and variables from queue to endpoint. |
On Ws Session open, these In this way, |
Another important note about 8c4ae14 is that I had to introduce some explicit locking to solve the problem that a parallel thread can add a new entry to This problem existed before the present change already: 8c4ae14#diff-23032fb61a809dbbda23f3ef3686b9b0L127 |
The itests in ppalaga/hawkular-agent@4d1776d are passing on top of the present changeset 8c4ae14 |
8c4ae14
to
821d261
Compare
} | ||
|
||
/** | ||
* When a binary message is received from a UI client, this method will execute the command the client is asking |
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 mentions "UI Client" but this class is for both feeds and UI clients, so just make the javadocs more general. Same thing in the @return description
821d261
to
90a3e1b
Compare
No description provided.