Closed khauser closed 3 years ago
@stliu could you please help route @khauser's issue migrating from Track1 to the new Track 2 azure-servicebus-jms-spring-boot-starter
Hi @khauser thanks for reporting this, could you provide a tiny sample project reproducing this bug, which includes how you send messages to Azure Service Bus and the way you use azure-servicebus-jms-spring-boot-starter to receive and convert messags from SB?
demo-sender.zip demo-receiver.zip
If I remove this file it works:
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.MessageType;
@EnableJms
@Configuration
public class JmsConfiguration
{
@Bean
public DefaultJmsListenerContainerFactory myFactory(DefaultJmsListenerContainerFactoryConfigurer configurer)
{
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setMessageConverter(jacksonJmsMessageConverter());
return factory;
}
@Bean // Serialize message content to json using TextMessage
public MessageConverter jacksonJmsMessageConverter()
{
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
}
Hi @khauser , this error is due to if you want to use the "_type" property, you need also set it in the sending side. Currently the message doesn't contain this property as below:
And as for why it can work in the older version, that's because in version 2.3.5, the JmsTemplate doesn't pick up your message converter bean, so it actually doesn't work. You can debug into the function JmsTemplate.getRequiredMessageConverter and see the actual message converter is the default one provided by Spring Jms. From version 3.2.0, we modified the auto-configuration so that the message converter bean can be picked up by JmsTemplate.
Hi @yiliuTo, thanks for the explanation. I will now try to remove the JmsConfiguration as the converter wasn't used in the past.
Hi,
we have problem upgrading our current message receiver using the methods which worked before.
Message sender uses:
compile 'com.azure:azure-messaging-servicebus:7.1.0'
Message receiver uses:
implementation group: 'com.azure.spring', name: 'azure-spring-boot-starter-servicebus-jms', version: "3.9.0"
We upgraded from
compile group: 'com.microsoft.azure', name: 'azure-servicebus-jms-spring-boot-starter', version: "2.3.5"
The receiver now complains about a missing {{type}} field.
Do we miss something?
Best Karsten