question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If consumer and producer agree on the content type of a message coercion should be automatic

See original GitHub issue

If a consumer and producer don’t specify a content type (via spring.cloud.stream.bindings.*.contentType) then as long as they share a class definition for the payload (a domain object) then the message will flow. That’s uncomfortable for 2 reasons: first it forces them to share the domain class (or have an identical class with the same FQCN), and second it uses a default content type which is not interopable (Java serialization basically, not JSON or protobuf or whatever).

As soon as you specify the content type (e.g. as application/json for interop / human readable messages), the system breaks because JSON gets converted to a String and the receiver can’t process it as a domain object any more (he has to manually convert the String to a domain object, going through 2 layers of conversion, from String to JSON to Object).

I propose that if the consumer and producer agree on the content type (e.g. application/json) then Spring Cloud Stream (or Spring Integration) should be able to handle the conversion and type coercion.

Marius has pointed out that you have a similar situation in REST endpoints where the solution is HttpMessageConverters that are mime-type as well as Java type aware. The payload is essentially bytes (or Strings) as far as the “dumb pipes” model is concerned (Spring Cloud Stream), but it carries content type headers, a bit like an HTTP request.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:26 (24 by maintainers)

github_iconTop GitHub Comments

2reactions
artembilancommented, Mar 8, 2017

The @Filter and other Messaging Annotations configuration, or even better - any POJO method invocation, will support content negotiation since Spring Integration 5.0: https://jira.spring.io/browse/INT-4225

1reaction
dsyercommented, Mar 8, 2017

@Filter is not a Spring Cloud Stream annotation. It does not support content negotiation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Cloud Stream Reference Guide
To run a Spring Cloud Stream application in production, you can create an executable (or ... Using @StreamListener for Automatic Content Type Handling....
Read more >
Consumer Fraud and Deceptive Business Practices Act.
If a consumer in a retail installment sales transaction gives the seller a negotiable instrument in part or full payment for the merchandise...
Read more >
NRS: CHAPTER 598 - DECEPTIVE TRADE PRACTICES
A person engages in a “deceptive trade practice” if, during a solicitation by telephone or text message or during a sales presentation, he...
Read more >
Consumer Compliance Examination Manual | FDIC
This section provides sample forms and templates to be used during Compliance Examinations, including Pre-. Examination Information Package, a model entry ...
Read more >
Communication as Commodity: Should the Media be on - jstor
Democratic-content-seeking consumers are auto-paternalist but the market serves their auto-paternalism well. A second type of consumer is simply too lazy, short ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found