Skip to content

Better Exception Message for JMS Jackson Converter Error [SPR-14672] #19236

@spring-projects-issues

Description

@spring-projects-issues

Michael Böckling opened SPR-14672 and commented

In org.springframework.jms.support.converter.MappingJackson2MessageConverter#getJavaTypeForMessage, an exception is thrown if a message lacks the property that has been configured as the typeIdPropertyName, and thus Jackson has no idea to which Java type to map the message to.

The error message is "Could not find type id property [" + this.typeIdPropertyName + "]", which lacks sufficient diagnostic context to really track down the issue once it appears in a logfile. It would be very useful to have the name of the JMS queue, so I can make a guess which application forgot to set that ID.
The Message ID might also be useful for some cases.

Proposal:

protected JavaType getJavaTypeForMessage(Message message) throws JMSException {
     String typeId = message.getStringProperty(this.typeIdPropertyName);
     if (typeId == null) {
          throw new MessageConversionException("Could not find type id property [" + this.typeIdPropertyName + "] on message " + message.getJMSMessageID() + " from destination " + message.getJMSDestination().toString());
     }

Affects: 4.2.6

Backported to: 4.2.8

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions