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
JsonType of request overrides response type when using amqp inbound gateway in combination with json converters (jackson2) [INT-3285] #7262
Comments
Jan Philipp commented Component 2 has the following configuration
And, to make it complete:
|
Jan Philipp commented
|
Artem Bilan commented Actually AMQP If you don't use Do I understand you correctly? |
Jan Philipp commented The statics of Okay. How do I "intercept" the reply message converting? Must I exclude the header from the reply (there is that mapped-reply-headers in the inbound-gateway directive)?
Perhaps I did not get it right, but they are not compatible with Jackson2? |
Artem Bilan commented
It depends on if you need to provide the
Not sure what you mean. By default Actually exactly This can help you to do it yourself: Jackson2JsonObjectMapper |
Jan Philipp commented
Hm, I'm actually not even sure myself at the moment. :) I was migration a 2.2 setup to 3.0 and was issued with transformation issues (Joda DateTime) and Jackson1 mappings. Perhaps the last one was my own failure because both Jacksons were accidentally available in the classpath and INT found v1 before v2. Nevertheless, then I found the new message converters which looks exactly what I need. Also, I have to define my own message converter because of Joda Module (out of the box it does not work). However, a (custom) message converter is not used automatically. But, I still do not get it. What I'm doing wrong here? I not happy to intercept stuff if there would be a better, "framework recommended" way.
Actually, I only want to provide the method API "public Response process(Request request)" via AMQP and using Jackson2 (incl. Joda bindings) as transport/serialization. By the way, thank you for the quick responses so far! :) |
Artem Bilan commented OK. Got it. One more time: Let us know and we close the issue as 'Works as Designed' |
Jan Philipp commented Ah, okay. Yes, thank you! Work as designed, actually. Close it. Just for the records (I'm also don't like unresolved questions :p) 1: Provide Joda (or even other custom) mappings for Jackson2: just and only this configuration snippet
2: Provide the "constructor" argument (well, I'd actually read the xml parser to understand what do you mean with that) For each usage of directives json-to-object-transformer or object-to-json-transformer, add a explicit object-mapper (otherwise the transformers invokes
Perhaps the last one could be resolved automatically (at least if custom defined) in the future? |
Artem Bilan commented Do you mean try to resolve the bean with name jsonObjectMapper, if there is no Anyway, thank you for pointing out the Spring Integration + Spring AMQP symmetry one more time. |
Jan Philipp commented Okay, that is right. Perhaps something like a default for a custom factory, i.e. for all json converters? Currently it is resolved statically. Well, that's.. static :) One of the missing points on my side was that I'd forgot totally json-to-object-transformer is only a shortcut for a real bean creation. |
Artem Bilan commented Reopened as there is really a case (this the SO link) where Gary Russell, how do you think? Will it be OK, if we ignore Or at least provide the option Jan Philipp, my apologize: I wasn't right yesterday and |
Artem Bilan commented Actually the |
Gary Russell commented I am not sure I have completely followed this entire thread of comments but it sounds like this is a similar problem to one we had with HTTP some time ago whereby the inbound We solved that by adding
This is a little different because the headers are generated by the MessageConverter, but it sounds similar. |
Marty Pitt commented Hi I believe this may be a regression, as the configuration I'm using in my most recent project (as shown on the SO post) is taken directly from another SI project. The previous project was running under SI 2.2, and the current one on SI 3.0.0-RELEASE. |
Marty Pitt commented Confirmed -- I just rolled back to SI 2.2.6.RELEASE, and the issue went away. |
Artem Bilan commented PR: #1050 |
Gary Russell commented Merged into master and 3.0.x |
Jan Philipp opened INT-3285 and commented
Okay, I'm still note sure if I get this right.
The scenario: If have two components communication via Spring Integration, via RabbitMQ (AMQP), via AMAP Inbound and Outbound Gateways, via a Jackson2 Message Converter.
(No conversion service is involved, it's a standard setup without spring wev)
Component 1: Sends a message via an AMQP Outbound Gateway with a configured Jackson2 message converter. Requesting type is A, returning type is B. Works fine, internally toJSON() like we would expected.
Component 2: Receives messages via an AMQP Inbound Gateway with a configured Jackson2 message converter. Requesting type is A and returning type BB. Internal fromJson() works fine, and the actual processing works without problems.
Well.. however, until the reply message is processed. The reply message will be created containing the (correct JSON) of the payload (an object of type B) but with a type hint header (TypeId) of the requesting type A.
So far I can tell you: Actually, the reply message was correctly transformed via toJSON by the configured Jackson2 converter (I could verify the jackson2 converter was a) used and b) processed the payload correctly including adding a message header). However, in AmqpInboundGateway.java:100
headerMapper.fromHeadersToReply()
will be invoked. Called with a correct value ofheaders.__TypeId__
(!) representing the type B, it will be in this call be overridden in AbstractHeaderMapper.java:141-149 with the corresponding value of the request type AA (made by the message converter I think).Coming from the old approach with two more or less simple directives from-json/to-json, this is now very confusing. :( Is this a bug or a miss configuration of myself?
Affects: 3.0.1
Reference URL: http://stackoverflow.com/questions/21595553/spring-integration-amqp-wrong-json-type-on-response
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: