-
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
JMS 3.0 [proposal] @MessageConverter Annotation and interface #259
Comments
what you have in mind? some sort of interceptor? where you would add such converter? would it be like connection.addConverter(converter); or would be at the consumer level? some brokers have interceptor and plugins as a feature.. having this kind of thing could be a valid enhancement for the API if you are talking about interceptors. but if what you have in mind is at the handler's level.. it could be something only towards MDBs? (that's a question really) |
Actually now that you mention it, it is sort of like an interceptor, but really it modifying the message before it's handed off to the POJO... so kinda. I think it would definitely be on a consumer level, not a connection level (maybe). You can have multiple consumers on a connection, and the current proposal is to have consumers/MDBs be more like POJOs. Since POJOs can take object arguments, I think it makes sense to have a step to marshal to/from an arbitrary format, much in the way JAX-RS marshals textual representations of objects into a Java objects before handing them off to user code |
Opened pull request #264 :) |
@exabrial Message conversion is definitely needed. I sent a message to the dev@ list titled 'Proposals repository' When that gets created, let's have you redo the PR over there. |
I would like use the If no any annotations, treat the listener arguments as subclass of Message. |
How about reducing the number of annotations down to one?
|
Make it is simple as possible.
@JmsListener(
destination="hello", // queue or topic name declared by CDI bean names, or by @JMSDestinationDefinition
converter=MyEventConverter.class,
acknowledgmentMode=...,
replyDestination=..., // if return a none-void result
condition="headers['xxx']=='yyyy' && payload.type!='test'" // an el to determine execute the method.
properties={
@JmsListener.Property("maxSessions", "100"),
@JmsListener.Property(name, value)
}
)
void receiveMessage(@Payload OrderConfirmedEvent data, @Headers Map<String, Object> headers, @Header("someHeaderProperty") String someheader)
// or
void receiveMessage(OrderConfirmedEvent data) // treat as payload by default
// or
void receiveMessage(TextMessage message)
// or
OtherMessage receiveMessage(TextMessage message) // if set the replyDestination |
@dblevins I'm not sure if this is the correct place to raise an idea, please let me know. This is related to #243
After reading through the spec, one thing I think is missing is the concept of message body converters. JAX-RS has the ability to allow people to create JSON, XML, FormURLEconding, YAML, etc representations and automatically convert them to Java objects before the developer's code is called.
Why is this important?
Interaction with third party systems! For instance, if you're communicating with a ruby or python program at the other end of your message broker, you're definitely not going to be using Java serialization.
Another very important reason is viewing of messages on the Message Broker itself. Most message broker consoles allow you to peer into the contents of a message. Having first class support for encoding Java objects as JSON, XML, or whatever allows a developer to have them in a human readable format, more aligned with RESTful principles.
I would propose a @MessageConverter annotation that takes a class argument (works well for non-CDI environments). A CDI-ish way to bind a bean as a converter would also be nice so we can support injection on Converters.
The text was updated successfully, but these errors were encountered: